Re: [PATCH] x86: do not leak kernel page mapping locations
On 02/07/2013 09:44 AM, Kees Cook wrote: > Without this patch, it is trivial to determine kernel page mappings by > examining the error code reported to dmesg[1]. Instead, declare the entire > kernel memory space as a violation of a present page. > > Additionally, since show_unhandled_signals is enabled by default, switch > branch hinting to the more realistic expectation, and unobfuscate the > setting of the PF_PROT bit to improve readability. > > [1] http://vulnfactory.org/blog/2013/02/06/a-linux-memory-trick/ > > Reported-by: Dan Rosenberg > Suggested-by: Brad Spengler > Cc: sta...@vger.kernel.org > Signed-off-by: Kees Cook There is, of course, tons of information in dmesg which can be used for nefarious purposes, and it is hard to avoid that without neutering dmesg to uselessness. So the question is to some degree how much this adds in isolation from locking down dmesg (and if dmesg_restrict isn't enough, what more do we need...)? That being said, the patch doesn't seem to do any harm so I acked it and Ingo is going to apply it. -hpa -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH] x86: do not leak kernel page mapping locations
Without this patch, it is trivial to determine kernel page mappings by examining the error code reported to dmesg[1]. Instead, declare the entire kernel memory space as a violation of a present page. Additionally, since show_unhandled_signals is enabled by default, switch branch hinting to the more realistic expectation, and unobfuscate the setting of the PF_PROT bit to improve readability. [1] http://vulnfactory.org/blog/2013/02/06/a-linux-memory-trick/ Reported-by: Dan Rosenberg Suggested-by: Brad Spengler Cc: sta...@vger.kernel.org Signed-off-by: Kees Cook --- arch/x86/mm/fault.c |8 +--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/arch/x86/mm/fault.c b/arch/x86/mm/fault.c index 027088f..fb674fd 100644 --- a/arch/x86/mm/fault.c +++ b/arch/x86/mm/fault.c @@ -748,13 +748,15 @@ __bad_area_nosemaphore(struct pt_regs *regs, unsigned long error_code, return; } #endif + /* Kernel addresses are always protection faults: */ + if (address >= TASK_SIZE) + error_code |= PF_PROT; - if (unlikely(show_unhandled_signals)) + if (likely(show_unhandled_signals)) show_signal_msg(regs, error_code, address, tsk); - /* Kernel addresses are always protection faults: */ tsk->thread.cr2 = address; - tsk->thread.error_code = error_code | (address >= TASK_SIZE); + tsk->thread.error_code = error_code; tsk->thread.trap_nr = X86_TRAP_PF; force_sig_info_fault(SIGSEGV, si_code, address, tsk, 0); -- 1.7.9.5 -- Kees Cook Chrome OS Security -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH] x86: do not leak kernel page mapping locations
On 02/07/2013 09:44 AM, Kees Cook wrote: Without this patch, it is trivial to determine kernel page mappings by examining the error code reported to dmesg[1]. Instead, declare the entire kernel memory space as a violation of a present page. Additionally, since show_unhandled_signals is enabled by default, switch branch hinting to the more realistic expectation, and unobfuscate the setting of the PF_PROT bit to improve readability. [1] http://vulnfactory.org/blog/2013/02/06/a-linux-memory-trick/ Reported-by: Dan Rosenberg dan.j.rosenb...@gmail.com Suggested-by: Brad Spengler spen...@grsecurity.net Cc: sta...@vger.kernel.org Signed-off-by: Kees Cook keesc...@chromium.org There is, of course, tons of information in dmesg which can be used for nefarious purposes, and it is hard to avoid that without neutering dmesg to uselessness. So the question is to some degree how much this adds in isolation from locking down dmesg (and if dmesg_restrict isn't enough, what more do we need...)? That being said, the patch doesn't seem to do any harm so I acked it and Ingo is going to apply it. -hpa -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH] x86: do not leak kernel page mapping locations
Without this patch, it is trivial to determine kernel page mappings by examining the error code reported to dmesg[1]. Instead, declare the entire kernel memory space as a violation of a present page. Additionally, since show_unhandled_signals is enabled by default, switch branch hinting to the more realistic expectation, and unobfuscate the setting of the PF_PROT bit to improve readability. [1] http://vulnfactory.org/blog/2013/02/06/a-linux-memory-trick/ Reported-by: Dan Rosenberg dan.j.rosenb...@gmail.com Suggested-by: Brad Spengler spen...@grsecurity.net Cc: sta...@vger.kernel.org Signed-off-by: Kees Cook keesc...@chromium.org --- arch/x86/mm/fault.c |8 +--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/arch/x86/mm/fault.c b/arch/x86/mm/fault.c index 027088f..fb674fd 100644 --- a/arch/x86/mm/fault.c +++ b/arch/x86/mm/fault.c @@ -748,13 +748,15 @@ __bad_area_nosemaphore(struct pt_regs *regs, unsigned long error_code, return; } #endif + /* Kernel addresses are always protection faults: */ + if (address = TASK_SIZE) + error_code |= PF_PROT; - if (unlikely(show_unhandled_signals)) + if (likely(show_unhandled_signals)) show_signal_msg(regs, error_code, address, tsk); - /* Kernel addresses are always protection faults: */ tsk-thread.cr2 = address; - tsk-thread.error_code = error_code | (address = TASK_SIZE); + tsk-thread.error_code = error_code; tsk-thread.trap_nr = X86_TRAP_PF; force_sig_info_fault(SIGSEGV, si_code, address, tsk, 0); -- 1.7.9.5 -- Kees Cook Chrome OS Security -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/