From nobody Thu Feb 12 21:41:29 2026 Received: from out203-205-221-239.mail.qq.com (out203-205-221-239.mail.qq.com [203.205.221.239]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2777C1C01 for ; Sat, 4 Jan 2025 12:32:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=203.205.221.239 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735993940; cv=none; b=KTO428ejSOmnzUpq5oskJAfeDj5sEu0ySVue47ka+lowUz072by/eswsaS9xd3YBlFAKXmgMn8a8dYKiScvUx28VLDOTAfuGAuEc4DVzqVLJDNtEzzz7JPGOmFknVuZW+EaScS8Wv+MTo+iy6QlnGUDA8iS52YhHc3rBXFm+K2Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735993940; c=relaxed/simple; bh=IGcIz4/iLnHpJ6V2HvEvGW33f3+RzDsD2+oORqRHRIc=; h=Message-ID:From:To:Cc:Subject:Date:In-Reply-To:References: MIME-Version; b=gJKavW7Ibdl/EJRM5Byf3DVPL+9vYEPgRmcg26Tvs3/Tii2Q6o6WYLpziC5EoPRweackwO4AAi035BYbjyuW29MB9okFtenwm9AZS9rnUz0rZ4Rrjh45hVkIsAacwne6zt98PfPmyIC3albpYTjdUy+A9E0I0nn9oXX+BDKGyQA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=qq.com; spf=pass smtp.mailfrom=qq.com; dkim=pass (1024-bit key) header.d=qq.com header.i=@qq.com header.b=mOPz2Cpy; arc=none smtp.client-ip=203.205.221.239 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=qq.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=qq.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=qq.com header.i=@qq.com header.b="mOPz2Cpy" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qq.com; s=s201512; t=1735993627; bh=TpUUFxqcS4tOMv3lNx1IvP26dCQBWp2QFlH70qTI7yg=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=mOPz2Cpy8NfzkyidrsehG1+sUA+uU48iBgaeFgkY813tNRYMTYgnNKptINXqwqsmq yJu+5Tae2rqFMkWUPPHdTsn6Z4zGHL9HaR1pKvfIAeBK3I6rBoWXYq299JeiASJxjc m8zfGlQTsHBASNTJm4SswjgvzL0gGVE1z7JsbgTE= Received: from pek-lxu-l1.wrs.com ([114.244.57.34]) by newxmesmtplogicsvrszgpua5-1.qq.com (NewEsmtp) with SMTP id 54006000; Sat, 04 Jan 2025 20:21:00 +0800 X-QQ-mid: xmsmtpt1735993260txno08mnv Message-ID: X-QQ-XMAILINFO: MiCjP/dqgPpjwRo2Wyzu3Tjtkv+4Zilt2f/mLxPx6H5tJhX0gQ7+1ppxMprMTp 24d2QPWofVj/Od6OYQjyQBbKjznyw9LR7CixBIH2QXdybCXqOJDm597GL0kOk4YsCWwOIfE74L9B cRWxy2Mn8+VKLJQIfY6fzSNY7oSCHvvg2AQT5MJQBtHN/yGA8HNrXGttVKOplW3suMdHuPHSeu+T ZiY+7gdUNTvVVhdzspU5PTicMZXhnAnn0BtiiN9ha/Oxkj3uvMVi+H84EOONO2E6TeGj3eM+LN1Q M+/E3jLdpdxIA6Ss5Jdqz5He4xZ0uzLiLWZ5gpUfLKVjz7spL8JRlDaUS3G7sFL9xJdSG9ExIYLk inxH2uLwKoouzmui70cfjI4QcN/8f8M/pO0LiK5RbDf42V/i8xbeloL7uBUT+RMlgRaBZQCoEgUr w7xVKvofac8iR9GzDrm9whk4F0YYjMRQ+ZI18v+j6SdLh0d48lo7Era8FI+XNAmYcEnJZ9khmXrx Mm1iwwJSLG8Xv85Ae2Q3SV9/y1ie+E+GxYlpy1keSCKYnjMgjvCDj0x2h+HYbuHFnPKkKl2PQzHC kJBQpWu8p+q3Vvp982NwJ0e8UDMtgyk/xPHawQZ+INkhCUTz7G2v6x5r4LhBGa0od0kE+3s4z+Wv rFp7EA70zNUbLr/2qp7q9JCw4rg+VBsiZAQgiDQW/HZIftk3wffFmpwKJddaMYDbvQYVri8VBqSR z/fOZwc4jnZglV/HNofNvRBTbjFT/sA0o9oUEfYupOHvVUnEk3AAXDDz2mfiJoOk0pJU6NktB1Rb iwla/3xYNQRE59G6pJgk5uUOqWS/VO1+5MSE18sEOFel0iiw96XodDAoGPo/6M/AlyDKewoLyftX p0nUpiHYDf9+zNGSJk1GF7x+9wnD8rug== X-QQ-XMRINFO: M/715EihBoGSf6IYSX1iLFg= From: Edward Adam Davis To: syzbot+2e65930fda17880da336@syzkaller.appspotmail.com Cc: linux-kernel@vger.kernel.org, luto@kernel.org, peterz@infradead.org, syzkaller-bugs@googlegroups.com, tglx@linutronix.de Subject: [PATCH] utsname: Prevents using NULL value nsproxy Date: Sat, 4 Jan 2025 20:21:00 +0800 X-OQ-MSGID: <20250104122059.782625-2-eadavis@qq.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <67788cda.050a0220.3b53b0.0042.GAE@google.com> References: <67788cda.050a0220.3b53b0.0042.GAE@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" syzbot reported a null-ptr-deref in get_uts. [1] Before exit_task_work() is executed, exit_task_namespaces() has been execut= ed, 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 0xdffffc= 0000000001: 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 Goo= gle 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 8= 5 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: 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@syzkaller.appspotmail.com Closes: https://syzkaller.appspot.com/bug?extid=3D2e65930fda17880da336 Tested-by: syzbot+2e65930fda17880da336@syzkaller.appspotmail.com Signed-off-by: Edward Adam Davis --- 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 *tab= le, int write, int r; char tmp_data[__NEW_UTS_LEN + 1]; =20 + if (!current->nsproxy) + return -EINVAL; + memcpy(&uts_table, table, sizeof(uts_table)); uts_table.data =3D tmp_data; =20 --=20 2.47.0