[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <tencent_922C496DA096A0EB6EED26CFBC78666D7C0A@qq.com>
Date: Sat, 4 Jan 2025 20:21:00 +0800
From: Edward Adam Davis <eadavis@...com>
To: syzbot+2e65930fda17880da336@...kaller.appspotmail.com
Cc: linux-kernel@...r.kernel.org,
luto@...nel.org,
peterz@...radead.org,
syzkaller-bugs@...glegroups.com,
tglx@...utronix.de
Subject: [PATCH] utsname: Prevents using NULL value nsproxy
syzbot reported a null-ptr-deref in get_uts. [1]
Before exit_task_work() is executed, exit_task_namespaces() has been executed,
which will cause task->nsproxy to be NULL.
To avoid this issue, check nsproxy of the task in proc_do_uts_string().
[1]
Oops: general protection fault, probably for non-canonical address 0xdffffc0000000001: 0000 [#1] PREEMPT SMP KASAN PTI
KASAN: null-ptr-deref in range [0x0000000000000008-0x000000000000000f]
CPU: 1 UID: 0 PID: 5943 Comm: syz-executor Not tainted 6.13.0-rc5-syzkaller-00004-gccb98ccef0e5 #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 09/13/2024
RIP: 0010:get_uts kernel/utsname_sysctl.c:23 [inline]
RIP: 0010:proc_do_uts_string+0x137/0x4e0 kernel/utsname_sysctl.c:50
Code: 48 c1 ee 03 80 3c 0e 00 0f 85 56 03 00 00 48 8b 92 08 09 00 00 48 b9 00 00 00 00 00 fc ff df 48 8d 7a 08 48 89 fe 48 c1 ee 03 <80> 3c 0e 00 0f 85 12 03 00 00 48 be 00 00 00 00 00 fc ff df 48 2d
RSP: 0018:ffffc900038f7468 EFLAGS: 00010202
RAX: ffffffff90022485 RBX: 1ffff9200071ee92 RCX: dffffc0000000000
RDX: 0000000000000000 RSI: 0000000000000001 RDI: 0000000000000008
RBP: ffffffff8de39fd8 R08: 0000000000000001 R09: fffffbfff1b8e071
R10: ffffffff8dc7038f R11: 0000000000000002 R12: 0000000000000001
R13: ffffc900038f7520 R14: dffffc0000000000 R15: ffffffff8de39fe0
FS: 0000000000000000(0000) GS:ffff8880b8700000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 00007f0544972008 CR3: 000000000db7e000 CR4: 00000000003526f0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
Call Trace:
<TASK>
proc_sys_call_handler+0x403/0x5d0 fs/proc/proc_sysctl.c:601
__kernel_write_iter+0x318/0xa80 fs/read_write.c:612
__kernel_write+0xf6/0x140 fs/read_write.c:632
do_acct_process+0xcb0/0x14a0 kernel/acct.c:539
acct_pin_kill+0x2d/0x100 kernel/acct.c:192
pin_kill+0x194/0x7c0 fs/fs_pin.c:44
mnt_pin_kill+0x61/0x1e0 fs/fs_pin.c:81
cleanup_mnt+0x3ac/0x450 fs/namespace.c:1366
task_work_run+0x14e/0x250 kernel/task_work.c:239
exit_task_work include/linux/task_work.h:43 [inline]
do_exit+0xad8/0x2d70 kernel/exit.c:938
do_group_exit+0xd3/0x2a0 kernel/exit.c:1087
get_signal+0x2576/0x2610 kernel/signal.c:3017
arch_do_signal_or_restart+0x90/0x7e0 arch/x86/kernel/signal.c:337
exit_to_user_mode_loop kernel/entry/common.c:111 [inline]
exit_to_user_mode_prepare include/linux/entry-common.h:329 [inline]
__syscall_exit_to_user_mode_work kernel/entry/common.c:207 [inline]
syscall_exit_to_user_mode+0x150/0x2a0 kernel/entry/common.c:218
do_syscall_64+0xda/0x250 arch/x86/entry/common.c:89
Reported-by: syzbot+2e65930fda17880da336@...kaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=2e65930fda17880da336
Tested-by: syzbot+2e65930fda17880da336@...kaller.appspotmail.com
Signed-off-by: Edward Adam Davis <eadavis@...com>
---
kernel/utsname_sysctl.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/kernel/utsname_sysctl.c b/kernel/utsname_sysctl.c
index 7282f61a8650..da2a9c92227f 100644
--- a/kernel/utsname_sysctl.c
+++ b/kernel/utsname_sysctl.c
@@ -37,6 +37,9 @@ static int proc_do_uts_string(const struct ctl_table *table, int write,
int r;
char tmp_data[__NEW_UTS_LEN + 1];
+ if (!current->nsproxy)
+ return -EINVAL;
+
memcpy(&uts_table, table, sizeof(uts_table));
uts_table.data = tmp_data;
--
2.47.0
Powered by blists - more mailing lists