æ©ç¨®ä¾åã§ãããfedoraã§5.4ç³»ã®ã«ã¼ãã«ã§èµ·åæã«ã«ã¼ãã«ãããã¯ããããã«ãªããèªåããã®ãã°ã«å½ãã£ãã®ã§ä¿®æ£ãã¦ããããlkmlã«æ稿ãã¾ããã ãã®ãããã¯Linux5.5.ã«åãè¾¼ã¾ãã¾ããð
ã¤ãã§ãªã®ã§ã©ããªæãã§ãããã°ãããã®è¨é²ã§ãã10æ¥åãããã®è©±ã ãããããã°æã®æèã®æç³»åã¯å¤å°éãæ°ããã¾ããã ããããããªæãã¨ãããã¨ã§ã
ç°å¢
ãããªæãã§ãã
ãã°ã®å 容
èªåããã®ãã°ã«å½ãã£ãã¨ãã«ã¯fedoraã®bugzillaã«ãã§ã«ãã°ç»é²ããã¦ã¾ãã
5.4ç³»ã®ã«ã¼ãã«ã ã¨èµ·åæã«ã«ã¼ãã«ãããã¯ããâ ã¨ããå 容ã§ããå®éãããªæãã§ããã
ãã ãèªåãæ®æ®µä½¿ã£ã¦ããã¹ã¯ãããPCã§ãåãã«ã¼ãã«ã使ã£ã¦ã¾ãããã¡ãã§ã¯åæ§ã®ç¾è±¡ã¯èµ·ãã¦ã¾ããã§ãããã¨ãããã¨ã§æ©ç¨®ä¾åã£ã½ãæãããã¾ããããã¦ãbugzillaãè¦ã¦ãã¨å ±éç¹ãè¦ãã¦ãã¾ããã ããã¯æ¬¡ã®äºç¹ã§ãã
æ«å®å¯¾ç
ä¸ã«è²¼ãä»ããoopsã¯ã«ã¼ãã«ã®ã³ãã³ãã©ã¤ã³ãªãã·ã§ã³ã«quietãä»ãã¦ããã®ã§è¡¨ç¤ºããã¦ããªãã§ãããquietãå¤ãã¨âã®printk()ã®é¨åã表示ããã¾ããã
/* sched_clock_stable() is determined in late_initcall */ if (!trace_boot_clock && !sched_clock_stable()) { printk(KERN_WARNING "Unstable clock detected, switching default tracing clock to \"global\"\n" "If you want to keep using the local clock, then add:\n" " \"trace_clock=local\"\n" "on the kernel command line\n"); tracing_set_clock(&global_trace, "global"); }
ã£ã¦ãã¨ã§ãããã試ãã¨èµ·åæåããã®ã§bugzillaã«trace_clock=locakãä»ããã大ä¸å¤«ã ã£ããã¨ã³ã¡ã³ããã¾ãããã¾ããä»ã®äººã¯Secure bootãç¡å¹ã«ãããã¨ã§å¯¾å¿ãããããã¦ã¾ããã
åå ãæ¢ã
NULL pointer dereference ã®åå ç®æ
ring_buffer_set_clock()ã¯ãããªé¢æ°ã§ãã
void ring_buffer_set_clock(struct ring_buffer *buffer, u64 (*clock)(void)) { buffer->clock = clock; }
ã©ãã§ã¨ã©ã¼ã«ãªã£ããä¸ç®çç¶ã§ããã
ãã®é¢æ°ã«è³ãæµãã¯tracing_set_default_clock()ããå§ã¾ãã tracing_set_clock() -> ring_buffer_set_clock()ã¨ãªãã¾ãã
åæåããã¦ããªãç¶æ ã§ring_buffer_set_clock()ãå¼ã°ãã¦ãæãã§ããã
ã¡ãªã¿ã«ããã§å¤æ´ãããã¨ãã¦ããclockã¯/sys/kernel/debug/tracing/trace_clockã¨ãã¦è¦ãã¾ãã
masami@moon:~$ sudo cat /sys/kernel/debug/tracing/trace_clock [local] global counter uptime perf mono mono_raw boot x86-tsc
Unstable clock detected?
5.3ç³»ã§ã¯åé¡ãªãã£ãã®ã§5.4ç³»ããã®ãã°ã§ã¯ããã®ã§ãããã¾ã以ä¸ã®é¨åã§Unstable clock detectedã¨ãªãã®ã¯5.3ã§ã¯ã©ãã ã£ãã®ãï¼ã¨ããã®ã調ã¹ã¾ããtrace_boot_clockã¯trace_clockãªãã·ã§ã³ãªã®ã§æ®æ®µã¯è¨å®ãã¦ãªãã®ã§æ°ã«ãã¾ããã
if (!trace_boot_clock && !sched_clock_stable()) {
調ã¹ãã¨ãã£ã¦ãã5.3ç³»ã«ã¼ãã«ã®èµ·åæã«quietãªãã·ã§ã³ãå¤ãã ãã§ãããããã¦çµæã¯ã©ãã ã£ããã¨è¨ãã¨5.3ç³»ã§ã5.4.7ã§ãåããã¹ãéã£ã¦ãã¾ããããã®PCã¯Unstable clock detectedã¨å¤æãããããã§ããããã¹ã¯ãããPCï¼cpuã¯i7-9700Kï¼ã®ã»ãã¯ãã®ãã¹ã¯éã£ã¦ã¾ããã§ããã
upstraem / ä»ã®ãã£ã¹ããªãã¥ã¼ã·ã§ã³ã®æ§å
ã¨ãã«åããããªã¨ã©ã¼ãåºã¦ãæãã¯ããã¾ããã§ããã
ããã¾ã§ã®ã¾ã¨ã
以ä¸ã®æ¡ä»¶ã«å½ã¦ã¯ã¾ã人ããã°ã«å½ãã£ã¦ããæãã§ãã
- fedoraã§5.4ç³»ã«ã¼ãã«ãå©ç¨
- Thinkpadã§cpuã¯Ryzen
- Secure Bootæå¹
åé¿çã¯trace_clock=localãè¨å®ãããSecure Bootãç¡å¹ã«ããã
åå ç¹å®ã®ããã®ãããã°
Secure Bootç°å¢ã§åãã«ã¼ãã«ãä½ãæ¹æ³ã調ã¹ã
Secure Bootãç¡å¹ã«ãã¡ãã£ããåç¾ããªãã®ã§èªåã§ãã«ãããã«ã¼ãã«ã¸ã®ç½²åæ¹æ³ã調ã¹ã¾ãã調ã¹ãçµæã¯âã«ã¾ã¨ãã¾ããã
upstreamã«ã¼ãã«ã試ã
ã¾ãã¯ãã¼ã¸ã§ã³åããã®ã使ã£ã¦ãã«ã¼ãã«ã®ã³ã³ãã£ã°ã¯fedoraã®5.4.7ã®ã³ã³ãã£ã°ã使ãã¾ãããã«ããã¦ãã®ã«ã¼ãã«ããèµ·åãã¦ã¿ãã¨ç¡äºã«èµ·åãã¾ãããã¨ãããã¨ã§ã次ã®æé ã«é²ã¿ã¾ãã
fedoraåºæã®ãããã調ã¹ã
調ã¹ãã¨è¨ããããããä¸æ¦å¤ããã ãå¤ãã¦ãã足ãã¦ããã¨ããããªæãã§ãããfedoraã®ã«ã¼ãã«ããã±ã¼ã¸ã®ã½ã¼ã¹ä¸å¼ã¯gitãªãã¸ããªã«ããã®ã§ã¯ãã¼ã³ãã¦ãã¦ãf31ãã©ã³ããããã©ã³ããåæä½æ¥ãã¦ããã¾ãããã®æç¹ã§f31ãã©ã³ãã¯5.4.12ã«ã¼ãã«ã«ãªã£ã¦ãã¾ããã
æé çã«ã¯specãã¡ã¤ã«ã§ããããã³ã¡ã³ãã¢ã¦ããã¦ãfedpkgã§srpmãä½ãã¾ããããã¦ãå¿ è¦æå°éã®ããã±ã¼ã¸ã ãä½ãããã£ãã®ã§åºæ¥ãsrpmãã¤ã³ã¹ãã¼ã«ãã¦rpmbuildã§ãã«ãããã¨ããæ¹æ³ãåãã¾ãããfedpkgã§åããããªãã¨ãã§ãããã§ããããï¼ ããã¯ã¨ãããrpmbuildã¯ãããªãªãã·ã§ã³ã§ããã¾ããã
$ rpmbuild -bb --with baseonly --without debuginfo --target=$(uname -m) kernel.spec
arm64-Add-option-of-13-for-FORCE_MAX_ZONEORDER.patchã®ããã«å¤ãã¨ä»ã«ç´ããªãããããªãã¨ãããåºã¦ãããããããã£ããããã®ã§ãããã¾ããã®è¾ºã¯ä»åã®ãã°ã«é¢ä¿ãªãã ãã£ã¦ãã¨ã§ãããããããã¯å¤ããã«é²ãã¾ãããããã¦ãefi-secureboot.patchãå¤ãã°åé¡ãªãã¨ããã¨ããã¾ã§å¤æãã¾ããã
efi-secureboot.patchã®å 容ã調ã¹ã
efi-secureboot.patchã¯Linux 5.4ããå ¥ã£ãlockdownã«é¢ä¿ãããããã§ãã
lockdownã«ã¤ãã¦ã¯ãã¡ããåç §ãã¦ãããã¨ãã¦ãã
ãã®ãããã®å 容ã¯å¤§ããåããã¨
- lockdownã®è¨å®ããã¨ããè¡ããé¢æ°ï¼security_lock_kernel_down()ï¼ã追å
- ã«ã¼ãã«ã®ã³ã³ãã£ã°ãªãã·ã§ã³ã¨ãã¦CONFIG_LOCK_DOWN_IN_EFI_SECURE_BOOTã追å
- CONFIG_LOCK_DOWN_IN_EFI_SECURE_BOOTãtrueãªãsecurity_lock_kernel_down()ãå¼ã¶å¦çã追å
æå¾ã®CONFIG_LOCK_DOWN_IN_EFI_SECURE_BOOTã®å¤ã«å¿ãã¦å¦çãã¦ãé¨åã¯ä»¥ä¸ã®ifdefã®ã¨ããã§ãã
diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c index 77ea96b794bd..a119e1bc9623 100644 --- a/arch/x86/kernel/setup.c +++ b/arch/x86/kernel/setup.c @@ -73,6 +73,7 @@ #include <linux/jiffies.h> #include <linux/mem_encrypt.h> #include <linux/sizes.h> +#include <linux/security.h> #include <linux/usb/xhci-dbgp.h> #include <video/edid.h> @@ -1027,6 +1028,13 @@ void __init setup_arch(char **cmdline_p) if (efi_enabled(EFI_BOOT)) efi_init(); + efi_set_secure_boot(boot_params.secure_boot); + +#ifdef CONFIG_LOCK_DOWN_IN_EFI_SECURE_BOOT + if (efi_enabled(EFI_SECURE_BOOT)) + security_lock_kernel_down("EFI Secure Boot mode", LOCKDOWN_CONFIDENTIALITY_MAX); +#endif + dmi_setup(); /*
ä¸è¨ã®ã³ã¼ãã¯ã«ã¼ãã«ãuefiã®secure bootç°å¢ã§èµ·åããã¦ããlockdownãã¦ã¾ãã
ããã¾ã§ããã¨CONFIG_LOCK_DOWN_IN_EFI_SECURE_BOOTãçãããæããã¦ãã¾ããããã§ãã®ãªãã·ã§ã³ã¯é¸æããã«ã«ã¼ãã«ããã«ããã¾ãããªãã·ã§ã³ã¯kernel-x86_64-fedora.configã«ã¦ãã®ããã«è¡ããã¦ãã¾ãã
CONFIG_LOCK_DOWN_IN_EFI_SECURE_BOOT=y # CONFIG_LOCK_DOWN_KERNEL_FORCE_CONFIDENTIALITY is not set # CONFIG_LOCK_DOWN_KERNEL_FORCE_INTEGRITY is not set CONFIG_LOCK_DOWN_KERNEL_FORCE_NONE=y
ãªãã·ã§ã³ã®è¨å®ã¯kernel-x86_64-fedora.configã§CONFIG_LOCK_DOWN_IN_EFI_SECURE_BOOTãã³ã¡ã³ãã¢ã¦ããã¦srpmãä½ã£ã¦ãããã«ããã¾ãããããããäºæ³éãèµ·åã§ããã®ã§ããããªããããã°ã«å ¥ãã¾ãã
upstreamã®ã½ã¼ã¹ãå確èª
5.4.12ã®ã³ã¼ããè¦ã¦ãããããªã³ã¼ããå ¥ã£ã¦ãããã§ãããããã¯register_tracer()ã®ã³ã¼ãã§ãã
if (security_locked_down(LOCKDOWN_TRACEFS)) { pr_warning("Can not register tracer %s due to lockdown\n", type->name); return -EPERM; }
ä»ã«ãåããããªãã§ãã¯ãããã¤ãããã¾ãããããã§lockdownããã¦ããã¨tracerã®åæåããªããã ãªã¨ãããã¨ãã£ã¦ããããåæåããã¦ããªãã®ã«trace clockãå¤æ´ãããã¨ãããããã«ãã«ãªãã¨ãããã¨ãªãã ãªã¨ç解ãã¾ããã
upsteamã§åç¾ã§ããã確èª
ãã®ã¨ãã¯5.4.7ã§ã¯ãªãã¦fedoraã®ã«ã¼ãã«ããã±ã¼ã¸ã®gitã§ã¯5.4.12ã ã£ãã®ã§stable treeã®5.4.12ã使ãã¾ãããåå ã¯ã»ã¼æ´ããã¨ããã¨ãããªãã§ãããupstreamã§åç¾ãããã©ããå度æ¤è¨¼ãã¾ãã
ã¾ãlockdownæ©è½ã«é¢ããã³ã³ãã£ã°ã調ã¹ã¾ããlockdownã§ã¯CONFIG_SECURITY_LOCKDOWN_LSMãæéè¦ã®è¨å®ã§Y/Nã®2æã§ããããã§Yãé¸ã¹ã°lockdownã®æ©è½ã使ãã¾ããYãé¸æããã¨æ´ã«ã©ã®ã¬ãã«ã§lockãããã¨ããé¸æãããã¾ããé¸æè¢ã¯3åã§ããã©ã«ãã¯Noneã§ããfedoraã®ã«ã¼ãã«ãCONFIG_LOCK_DOWN_KERNEL_FORCE_NONEãé¸æãã¦ãã¾ããã
- CONFIG_LOCK_DOWN_KERNEL_FORCE_NONE
- CONFIG_LOCK_DOWN_KERNEL_FORCE_INTEGRITY
- CONFIG_LOCK_DOWN_KERNEL_FORCE_CONFIDENTIALITY
fedoraã®å ´åã¯CONFIG_LOCK_DOWN_IN_EFI_SECURE_BOOTã4åç®ã®é¸æè¢ã£ã¦ã¨ããã§ããããã
ãªãã·ã§ã³ã®å 容ã§ããKconfigã«ããã¨CONFIG_LOCK_DOWN_KERNEL_FORCE_NONEã¯ä½ããã¾ãããCONFIG_LOCK_DOWN_KERNEL_FORCE_INTEGRITYã¯ãFeatures that allow the kernel to be modified at runtime are disabled.ãã¨ãããCONFIG_LOCK_DOWN_KERNEL_FORCE_CONFIDENTIALITYãFeatures that allow the kernel to be modified at runtime or that permit userland code to read confidential material held inside the kernel are disabledãã§ä¸çªå¶éãå³ãããªã£ã¦ãã¾ãã
æåã«fedoraã®ã³ã³ãã£ã°ã§mainlineã«ã¼ãã«ããã«ãããã¨ãã¯CONFIG_LOCK_DOWN_KERNEL_FORCE_NONEãé¸æããã¦ãã®ã§æ®ãã®2ãã¿ã¼ã³ã試ããã¨ããCONFIG_LOCK_DOWN_KERNEL_FORCE_CONFIDENTIALITYãè¨å®ããã¨ãã«åç¾ãã¾ããï½·ï¾ââââ(ï¾âï¾)ââââ!!
ä¿®æ£ãã
lockdownãæå¹ã«ãªã£ã¦ããã¨ãã¯trace_clockãå¤æ´ã§ããªãããã«ããã®ãè¯ãã ããã¨æãããã®ãããªããããæ¸ãã¾ããã
@@ -9420,6 +9420,11 @@ __init static int tracing_set_default_clock(void) { /* sched_clock_stable() is determined in late_initcall */ if (!trace_boot_clock && !sched_clock_stable()) { + if (security_locked_down(LOCKDOWN_TRACEFS)) { + pr_warn("Can not set tracing clock due to lockdown\n"); + return -EPERM; + } + printk(KERN_WARNING "Unstable clock detected, switching default tracing clock to \"global\"\n" "If you want to keep using the local clock, then add:\n"
patchãéã
upstreamã®ã«ã¼ãã«ã§ãåç¾ã§ããã®ã§upstreamã«ããããéãã¾ããlkmlãã¿ã¦ããtracingç³»ã¯lkmlã«ccã§è¯ããã ã£ãã®ã§ccã«ã¯lkmlãtoã¯scripts/get_maintainer.plã§åºã¦ããã¡ã³ããã®äººã«ãã¦git format-patchã§ããããä½ãgit send-emailã§éãã¾ããã
ããããéã£ã¦ãã°ãããããã¡ã³ããã®äººããmainlineã¸ã®pull rquestã«èªåã®ããããå ¥ã£ã¦ããã®ã§acceptããã¨ãããã¨ãããããè¯ãã£ãã£ã¦æãã§ãããã5.5-rc8ãåºãã®ãã¨æã£ã¦ããã©rc8ã¯åºãã«5.5ã2020/01/27ã«ã§ã¦ãããã«ä¿®æ£ãå«ã¾ãã¾ããã
mainlineã«ä¿®æ£ãåãè¾¼ã¾ããã®ã§ãã®ãã¡5.4ã®stable treeã«ãä¿®æ£ãåãè¾¼ã¾ããããããªããã¨æãã¾ãã
ã¾ã¨ã
ä»åã®ãã°ã¯æ©ç¨®ä¾åã»ã«ã¼ãã«ã®è¨å®ä¾åãªé¢ãããã¾ãããããã°ã®åå ã¯ããã£ã¦ãã¾ãã°ç°¡åã ã£ãã®ã¨ä¿®æ£ãåç´ãªæ¹æ³ã§æ¸ã¾ããã¨ãã§ãã¦è¯ãã£ãã§ãð ãã¨fedoraåãã®åç´ãªsecure bootç¨ã®ç½²åæ¹æ³ãããã£ãã®ã¯è¯ãã£ãããã
追è¨
5.5ç³»ã¯5.5ããã5.4ç³»ã¯5.4.16ããããããå ¥ã£ãã
5.5ãªãªã¼ã¹ã¡ã¼ã«
5.4.16ãªãªã¼ã¹ã¡ã¼ã«
https://lwn.net/Articles/811027/
- ä½è :éæ¨ å³°é
- åºç社/ã¡ã¼ã«ã¼: SBã¯ãªã¨ã¤ãã£ã
- çºå£²æ¥: 2017/09/22
- ã¡ãã£ã¢: Kindleç