lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <171110515913.10875.11206445395083365696.tip-bot2@tip-bot2>
Date: Fri, 22 Mar 2024 10:59:19 -0000
From: "tip-bot2 for Masami Hiramatsu (Google)" <tip-bot2@...utronix.de>
To: linux-tip-commits@...r.kernel.org
Cc: Qiang Zhang <zzqq0103.hey@...il.com>, Jinghao Jia <jinghao7@...inois.edu>,
 "Masami Hiramatsu (Google)" <mhiramat@...nel.org>,
 Ingo Molnar <mingo@...nel.org>, x86@...nel.org, linux-kernel@...r.kernel.org
Subject: [tip: x86/urgent] kprobes/x86: Use copy_from_kernel_nofault() to read
 from unsafe address

The following commit has been merged into the x86/urgent branch of tip:

Commit-ID:     4e51653d5d871f40f1bd5cf95cc7f2d8b33d063b
Gitweb:        https://git.kernel.org/tip/4e51653d5d871f40f1bd5cf95cc7f2d8b33d063b
Author:        Masami Hiramatsu (Google) <mhiramat@...nel.org>
AuthorDate:    Fri, 15 Mar 2024 00:17:30 +09:00
Committer:     Ingo Molnar <mingo@...nel.org>
CommitterDate: Fri, 22 Mar 2024 11:40:56 +01:00

kprobes/x86: Use copy_from_kernel_nofault() to read from unsafe address

Read from an unsafe address with copy_from_kernel_nofault() in
arch_adjust_kprobe_addr() because this function is used before checking
the address is in text or not. Syzcaller bot found a bug and reported
the case if user specifies inaccessible data area,
arch_adjust_kprobe_addr() will cause a kernel panic.

[ mingo: Clarified the comment. ]

Fixes: cc66bb914578 ("x86/ibt,kprobes: Cure sym+0 equals fentry woes")
Reported-by: Qiang Zhang <zzqq0103.hey@...il.com>
Tested-by: Jinghao Jia <jinghao7@...inois.edu>
Signed-off-by: Masami Hiramatsu (Google) <mhiramat@...nel.org>
Signed-off-by: Ingo Molnar <mingo@...nel.org>
Link: https://lore.kernel.org/r/171042945004.154897.2221804961882915806.stgit@devnote2
---
 arch/x86/kernel/kprobes/core.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/arch/x86/kernel/kprobes/core.c b/arch/x86/kernel/kprobes/core.c
index 091b3ab..d0e49bd 100644
--- a/arch/x86/kernel/kprobes/core.c
+++ b/arch/x86/kernel/kprobes/core.c
@@ -373,7 +373,16 @@ out:
 kprobe_opcode_t *arch_adjust_kprobe_addr(unsigned long addr, unsigned long offset,
 					 bool *on_func_entry)
 {
-	if (is_endbr(*(u32 *)addr)) {
+	u32 insn;
+
+	/*
+	 * Since 'addr' is not guaranteed to be safe to access, use
+	 * copy_from_kernel_nofault() to read the instruction:
+	 */
+	if (copy_from_kernel_nofault(&insn, (void *)addr, sizeof(u32)))
+		return NULL;
+
+	if (is_endbr(insn)) {
 		*on_func_entry = !offset || offset == 4;
 		if (*on_func_entry)
 			offset = 4;

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ