kernel BUG in free_bprm
Subsystems (3)
syzbot
syzbotHello,
syzbot found the following issue on:
HEAD commit: c88416ba074a Add linux-next specific files for 20241101 git tree: linux-next console+strace: https://syzkaller.appspot.com/x/log.txt?x=17911630580000 kernel config: https://syzkaller.appspot.com/x/.config?x=3ebcda5c61915e91 dashboard link: https://syzkaller.appspot.com/bug?extid=03e1af5c332f7e0eb84b compiler: Debian clang version 15.0.6, GNU ld (GNU Binutils for Debian) 2.40 syz repro: https://syzkaller.appspot.com/x/repro.syz?x=1626d340580000 C reproducer: https://syzkaller.appspot.com/x/repro.c?x=10156187980000
Downloadable assets:
disk image: https://storage.googleapis.com/syzbot-assets/02f4cb9cc7aa/disk-c88416ba.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/253f54d7165b/vmlinux-c88416ba.xz
kernel image: https://storage.googleapis.com/syzbot-assets/9f9612540588/bzImage-c88416ba.xz
The issue was bisected to:
commit 7bdc6fc85c9a1008e00e624612f82932136d7545
Author: Tycho Andersen <[email protected]> Date: Wed Oct 30 20:37:31 2024 +0000
exec: fix up /proc/pid/comm in the execveat(AT_EMPTY_PATH) case
bisection log: https://syzkaller.appspot.com/x/bisect.txt?x=13f1aaa7980000 final oops: https://syzkaller.appspot.com/x/report.txt?x=1009aaa7980000 console output: https://syzkaller.appspot.com/x/log.txt?x=17f1aaa7980000
IMPORTANT: if you fix the issue, please add the following tag to the commit:
process 'syz-executor210' launched '/dev/fd/3' with NULL argv: empty string added
------------[ cut here ]------------ kernel BUG at arch/x86/mm/physaddr.c:23! Oops: invalid opcode: 0000 [#1] PREEMPT SMP KASAN PTI CPU: 1 UID: 0 PID: 5846 Comm: syz-executor210 Not tainted 6.12.0-rc5-next-20241101-syzkaller #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 09/13/2024 RIP: 0010:__phys_addr+0x16a/0x170 arch/x86/mm/physaddr.c:23 Code: 40 a8 7a 8e 4c 89 f6 4c 89 fa e8 b1 4d aa 03 e9 45 ff ff ff e8 a7 1a 52 00 90 0f 0b e8 9f 1a 52 00 90 0f 0b e8 97 1a 52 00 90 <0f> 0b 0f 1f 40 00 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 RSP: 0018:ffffc90003dd7da0 EFLAGS: 00010293 RAX: ffffffff8143a369 RBX: 000000007ffffff2 RCX: ffff88807bf53c00 RDX: 0000000000000000 RSI: 000000007ffffff2 RDI: 000000001fffffff RBP: 1ffff1100546a409 R08: ffffffff8143a305 R09: 1ffffffff203a1f6 R10: dffffc0000000000 R11: fffffbfff203a1f7 R12: dffffc0000000000 R13: fffffffffffffff2 R14: 000000007ffffff2 R15: ffff8880760fc158 FS: 000055557e80e380(0000) GS:ffff8880b8700000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 00007f81836d5440 CR3: 000000002f60c000 CR4: 00000000003526f0 DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 Call Trace: <TASK> virt_to_folio include/linux/mm.h:1294 [inline] kfree+0x71/0x420 mm/slub.c:4738 free_bprm+0x2b5/0x300 fs/exec.c:1499 do_execveat_common+0x3ae/0x750 fs/exec.c:1978 do_execveat fs/exec.c:2061 [inline] __do_sys_execveat fs/exec.c:2135 [inline] __se_sys_execveat fs/exec.c:2129 [inline] __x64_sys_execveat+0xc4/0xe0 fs/exec.c:2129 do_syscall_x64 arch/x86/entry/common.c:52 [inline] do_syscall_64+0xf3/0x230 arch/x86/entry/common.c:83 entry_SYSCALL_64_after_hwframe+0x77/0x7f RIP: 0033:0x7f432f022329 Code: 48 83 c4 28 c3 e8 37 17 00 00 0f 1f 80 00 00 00 00 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 c7 c1 b8 ff ff ff f7 d8 64 89 01 48 RSP: 002b:00007ffd7487b7e8 EFLAGS: 00000246 ORIG_RAX: 0000000000000142 RAX: ffffffffffffffda RBX: 00007ffd7487b9b8 RCX: 00007f432f022329 RDX: 0000000000000000 RSI: 0000000020000000 RDI: 0000000000000003 RBP: 00007f432f095610 R08: 0000000000001000 R09: 00007ffd7487b9b8 R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000001 R13: 00007ffd7487b9a8 R14: 0000000000000001 R15: 0000000000000001 </TASK> Modules linked in: ---[ end trace 0000000000000000 ]--- RIP: 0010:__phys_addr+0x16a/0x170 arch/x86/mm/physaddr.c:23 Code: 40 a8 7a 8e 4c 89 f6 4c 89 fa e8 b1 4d aa 03 e9 45 ff ff ff e8 a7 1a 52 00 90 0f 0b e8 9f 1a 52 00 90 0f 0b e8 97 1a 52 00 90 <0f> 0b 0f 1f 40 00 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 RSP: 0018:ffffc90003dd7da0 EFLAGS: 00010293 RAX: ffffffff8143a369 RBX: 000000007ffffff2 RCX: ffff88807bf53c00 RDX: 0000000000000000 RSI: 000000007ffffff2 RDI: 000000001fffffff RBP: 1ffff1100546a409 R08: ffffffff8143a305 R09: 1ffffffff203a1f6 R10: dffffc0000000000 R11: fffffbfff203a1f7 R12: dffffc0000000000 R13: fffffffffffffff2 R14: 000000007ffffff2 R15: ffff8880760fc158 FS: 000055557e80e380(0000) GS:ffff8880b8700000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 00007f81836d5440 CR3: 000000002f60c000 CR4: 00000000003526f0 DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
---
This report is generated by a bot. It may contain errors. See https://goo.gl/tpsmEJ for more information about syzbot. syzbot engineers can be reached at [email protected].
syzbot will keep track of this issue. See:
https://goo.gl/tpsmEJ#status for how to communicate with syzbot. For information about bisection process see: https://goo.gl/tpsmEJ#bisection
If the report is already addressed, let syzbot know by replying with:
#syz fix: exact-commit-title
If you want syzbot to run the reproducer, reply with:
#syz test: git://repo/address.git branch-or-commit-hash
If you attach or paste a git patch, syzbot will apply it before testing.
If you want to overwrite report's subsystems, reply with:
#syz set subsystems: new-subsystem
(See the list of subsystem names on the web dashboard)
If the report is a duplicate of another one, reply with:
#syz dup: exact-subject-of-another-report
If you want to undo deduplication, reply with:
#syz undup
syzbot
syzbotRe: [syzbot] Re: kernel BUG in free_bprm()
For archival purposes, forwarding an incoming command email to [email protected], [email protected].
For archival purposes, forwarding an incoming command email to [email protected], [email protected].
***
Subject: Re: kernel BUG in free_bprm()
Author: [email protected]
#syz test https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next 850f22c42f4b0a14a015aecc26f46f9948ded6dd
fs/exec.c +2 -1
@@ -1496,7 +1496,8 @@ static void free_bprm(struct linux_binprm *bprm)if (bprm->interp != bprm->filename)kfree (bprm->interp);kfree (bprm->fdpath); -kfree (bprm->argv0); +if (!IS_ERR (bprm->argv0)) +kfree (bprm->argv0);kfree (bprm); }
Re: [syzbot] Re: kernel BUG in free_bprm()
Quoted 15 lines · syzbot
For archival purposes, forwarding an incoming command email to [email protected], [email protected].
***
Subject: Re: kernel BUG in
free_bprm()
Author: [email protected]#syz test https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next
850f22c42f4b0a14a015aecc26f46f9948ded6ddfs/exec.c +0
-0
fs/exec.c static void free_bprm(struct linux_binprm *bprm) · line 1502
Quoted 8 lines
fs/exec.c +2
-1@@ -1496,7 +1496,8 @@ static void free_bprm(struct linux_binprm *bprm)if (bprm->interp != bprm->filename)kfree (bprm->interp);kfree (bprm->fdpath); -kfree (bprm->argv0); +if (!IS_ERR (bprm->argv0)) +kfree (bprm->argv0);kfree (bprm); }
It's better to avoid setting bprm->argv0 if strndup_user() fails.
fs/exec.c +5 -3
@@ -1504,6 +1504,7 @@ static int bprm_add_fixup_comm(struct linux_binprm *bprm, struct user_arg_ptr argv) {const char __user *p =get_user_arg_ptr (argv,0 ); +char *argv0;/* * If p == NULL, let's just fall back to fdpath.
@@ -1511,10 +1512,11 @@ static int bprm_add_fixup_comm(struct linux_binprm *bprm,if (!p)return 0 ; - bprm->argv0 =strndup_user (p,MAX_ARG_STRLEN ); -if (IS_ERR (bprm->argv0)) -return PTR_ERR (bprm->argv0); + argv0 =strndup_user (p,MAX_ARG_STRLEN ); +if (IS_ERR (argv0)) +return PTR_ERR (argv0); + bprm->argv0 = argv0;return 0 ; }
Signature · 1 line
Kiryl Shutsemau / Kirill A. Shutemov