bisecting cause commit starting from afc997898ece86b15214a5872f21a3011aa2b23d building syzkaller on 44068e196185e2f5a7c94629b6245cdde008b140 testing commit afc997898ece86b15214a5872f21a3011aa2b23d compiler: gcc (GCC) 10.2.1 20210217, GNU ld (GNU Binutils for Debian) 2.35.2 kernel signature: d00e6da321273a969f7f2541ad16de2cfbdcf1d10a31a8bff66a9fcd5e8fbb0c all runs: crashed: general protection fault in reweight_entity testing release v5.10.85 testing commit e4f2aee6612e56c2a9a5da6131ccd80e57d5075b compiler: gcc (GCC) 10.2.1 20210217, GNU ld (GNU Binutils for Debian) 2.35.2 kernel signature: 58deeb79792b2eb697f78ed3b88facabd6dd71ddcb619f94e186b911a4c74638 all runs: crashed: general protection fault in reweight_entity testing release v5.10.84 testing commit a0582e24d371d62a749a14e4187af304bd64ef42 compiler: gcc (GCC) 10.2.1 20210217, GNU ld (GNU Binutils for Debian) 2.35.2 kernel signature: 2f4546f12807803c708faee9a5d11d0a348161522c86c05cc7323adaab9c17aa all runs: crashed: general protection fault in reweight_entity testing release v5.10.83 testing commit a324ad794566ae2ad2d5aa7f7e3c1825fb5cd5b7 compiler: gcc (GCC) 10.2.1 20210217, GNU ld (GNU Binutils for Debian) 2.35.2 kernel signature: 4e5d9a4cace07b1e8fcd5c8d6495453818bad5b587fd4058f2430cc0e47c8662 all runs: crashed: general protection fault in reweight_entity testing release v5.10.82 testing commit d5259a9ba6993a843278203323902bc0c049097e compiler: gcc (GCC) 10.2.1 20210217, GNU ld (GNU Binutils for Debian) 2.35.2 kernel signature: c7f9124bf50b2ac1f99fc59de038cfa63d4558fcf85456c242a05de035bab8fc all runs: crashed: general protection fault in reweight_entity testing release v5.10.81 testing commit 99957dcea4e9702cc9060f576233ac1ac84c2a39 compiler: gcc (GCC) 10.2.1 20210217, GNU ld (GNU Binutils for Debian) 2.35.2 kernel signature: 86321006630958d0898ff3f9a007ab54bf3906c9ca93cf9df0de2ba067927ecb all runs: crashed: general protection fault in reweight_entity testing release v5.10.80 testing commit f884bb85b8d877d4e0c670403754813a7901705b compiler: gcc (GCC) 10.2.1 20210217, GNU ld (GNU Binutils for Debian) 2.35.2 kernel signature: 7fa9fede74c38682c49cd14b2d2c6e87243a2ed85f688d0407fedb24d1781c7f all runs: crashed: general protection fault in reweight_entity testing release v5.10.79 testing commit bd816c278316f20a5575debc64dde4422229a880 compiler: gcc (GCC) 10.2.1 20210217, GNU ld (GNU Binutils for Debian) 2.35.2 kernel signature: 4e410654e865bf64a9d801c5e790dbd47d4fb5d187a62cf8eb983d374caf2c6f all runs: OK # git bisect start f884bb85b8d877d4e0c670403754813a7901705b bd816c278316f20a5575debc64dde4422229a880 Bisecting: 285 revisions left to test after this (roughly 8 steps) [4303b39b50758613ef45990440488a46febe4df9] media: em28xx: add missing em28xx_close_extension testing commit 4303b39b50758613ef45990440488a46febe4df9 compiler: gcc (GCC) 10.2.1 20210217, GNU ld (GNU Binutils for Debian) 2.35.2 kernel signature: dd71091a327cacb2d054bc3b56cd1002a310931959193dd5da9c9be4485532f9 all runs: OK # git bisect good 4303b39b50758613ef45990440488a46febe4df9 Bisecting: 142 revisions left to test after this (roughly 7 steps) [602fefd4561e07debd885e2f80c6b4569d7e0921] ARM: dts: stm32: fix SAI sub nodes register range testing commit 602fefd4561e07debd885e2f80c6b4569d7e0921 compiler: gcc (GCC) 10.2.1 20210217, GNU ld (GNU Binutils for Debian) 2.35.2 kernel signature: dfa060112dbbd73ac221855d903179d345d034ec39c4e8b759a59aebec217cf8 all runs: crashed: general protection fault in reweight_entity # git bisect bad 602fefd4561e07debd885e2f80c6b4569d7e0921 Bisecting: 71 revisions left to test after this (roughly 6 steps) [5b7b4afead622a8ee80eb820d7150f02d7a7628f] tcp: don't free a FIN sk_buff in tcp_remove_empty_skb() testing commit 5b7b4afead622a8ee80eb820d7150f02d7a7628f compiler: gcc (GCC) 10.2.1 20210217, GNU ld (GNU Binutils for Debian) 2.35.2 kernel signature: c198d569c55dacc07b6b9ccee60ea8f8670784a0d9d238ce99c0f50c1ec978ac all runs: crashed: general protection fault in reweight_entity # git bisect bad 5b7b4afead622a8ee80eb820d7150f02d7a7628f Bisecting: 35 revisions left to test after this (roughly 5 steps) [a342cb4772f44915b1e6688b101a41c01f9e71aa] tcp: switch orphan_count to bare per-cpu counters testing commit a342cb4772f44915b1e6688b101a41c01f9e71aa compiler: gcc (GCC) 10.2.1 20210217, GNU ld (GNU Binutils for Debian) 2.35.2 kernel signature: de21a6283c202b7f622cb7a940180e7bb83f7bdc67368383208b71111bf55c8d all runs: crashed: general protection fault in reweight_entity # git bisect bad a342cb4772f44915b1e6688b101a41c01f9e71aa Bisecting: 17 revisions left to test after this (roughly 4 steps) [af756be29c825f267e7a8870f9179d9c35c09eb8] rcu: Always inline rcu_dynticks_task*_{enter,exit}() testing commit af756be29c825f267e7a8870f9179d9c35c09eb8 compiler: gcc (GCC) 10.2.1 20210217, GNU ld (GNU Binutils for Debian) 2.35.2 kernel signature: f2d424133921b4799d6d22ee85cf9123b68a7f9d5f97a18e890a7c6b91fc736a all runs: OK # git bisect good af756be29c825f267e7a8870f9179d9c35c09eb8 Bisecting: 8 revisions left to test after this (roughly 3 steps) [2fd26ec36ef0d6b78509a2953ad1e03c93ea7caf] mmc: sdhci-omap: Fix NULL pointer exception if regulator is not configured testing commit 2fd26ec36ef0d6b78509a2953ad1e03c93ea7caf compiler: gcc (GCC) 10.2.1 20210217, GNU ld (GNU Binutils for Debian) 2.35.2 kernel signature: 3451dcbd1ad88951fa7e5d446fb9489247ebf4dce0cddb48f7cccdb5bc445c24 all runs: OK # git bisect good 2fd26ec36ef0d6b78509a2953ad1e03c93ea7caf Bisecting: 4 revisions left to test after this (roughly 2 steps) [e29352f162db6c06dc259d05ad538d350c82cd0b] net, neigh: Fix NTF_EXT_LEARNED in combination with NTF_USE testing commit e29352f162db6c06dc259d05ad538d350c82cd0b compiler: gcc (GCC) 10.2.1 20210217, GNU ld (GNU Binutils for Debian) 2.35.2 kernel signature: 89b429fb2a2d658b6bcf46118c0f5ec67b1010920dc7d669e58433f31791b217 all runs: OK # git bisect good e29352f162db6c06dc259d05ad538d350c82cd0b Bisecting: 2 revisions left to test after this (roughly 1 step) [786976b25ae0aaa58597a364e81e3ba3328f1211] hwmon: (pmbus/lm25066) Let compiler determine outer dimension of lm25066_coeff testing commit 786976b25ae0aaa58597a364e81e3ba3328f1211 compiler: gcc (GCC) 10.2.1 20210217, GNU ld (GNU Binutils for Debian) 2.35.2 kernel signature: 2804a46b1798787c0561295836a1a1a73c3aa537399aef17c7a512c2dc78707a all runs: OK # git bisect good 786976b25ae0aaa58597a364e81e3ba3328f1211 Bisecting: 0 revisions left to test after this (roughly 1 step) [c85c6fadbef0a3eab41540ea628fa8fe8928c820] kernel/sched: Fix sched_fork() access an invalid sched_task_group testing commit c85c6fadbef0a3eab41540ea628fa8fe8928c820 compiler: gcc (GCC) 10.2.1 20210217, GNU ld (GNU Binutils for Debian) 2.35.2 kernel signature: 8a3ee1ca15397d6221b91b4cc9186db4f259b5530c884a94c39838b9bde2655e all runs: crashed: general protection fault in reweight_entity # git bisect bad c85c6fadbef0a3eab41540ea628fa8fe8928c820 Bisecting: 0 revisions left to test after this (roughly 0 steps) [e1ee11473a88d65d3abc26df976312d199139dd2] ath10k: fix max antenna gain unit testing commit e1ee11473a88d65d3abc26df976312d199139dd2 compiler: gcc (GCC) 10.2.1 20210217, GNU ld (GNU Binutils for Debian) 2.35.2 kernel signature: f1c69816cb51e461e6bbc4ebaf065691c9b9427e94961a3b26afc04dcb976f8f all runs: OK # git bisect good e1ee11473a88d65d3abc26df976312d199139dd2 c85c6fadbef0a3eab41540ea628fa8fe8928c820 is the first bad commit commit c85c6fadbef0a3eab41540ea628fa8fe8928c820 Author: Zhang Qiao Date: Wed Sep 15 14:40:30 2021 +0800 kernel/sched: Fix sched_fork() access an invalid sched_task_group [ Upstream commit 4ef0c5c6b5ba1f38f0ea1cedad0cad722f00c14a ] There is a small race between copy_process() and sched_fork() where child->sched_task_group point to an already freed pointer. parent doing fork() | someone moving the parent | to another cgroup -------------------------------+------------------------------- copy_process() + dup_task_struct()<1> parent move to another cgroup, and free the old cgroup. <2> + sched_fork() + __set_task_cpu()<3> + task_fork_fair() + sched_slice()<4> In the worst case, this bug can lead to "use-after-free" and cause panic as shown above: (1) parent copy its sched_task_group to child at <1>; (2) someone move the parent to another cgroup and free the old cgroup at <2>; (3) the sched_task_group and cfs_rq that belong to the old cgroup will be accessed at <3> and <4>, which cause a panic: [] BUG: unable to handle kernel NULL pointer dereference at 0000000000000000 [] PGD 8000001fa0a86067 P4D 8000001fa0a86067 PUD 2029955067 PMD 0 [] Oops: 0000 [#1] SMP PTI [] CPU: 7 PID: 648398 Comm: ebizzy Kdump: loaded Tainted: G OE --------- - - 4.18.0.x86_64+ #1 [] RIP: 0010:sched_slice+0x84/0xc0 [] Call Trace: [] task_fork_fair+0x81/0x120 [] sched_fork+0x132/0x240 [] copy_process.part.5+0x675/0x20e0 [] ? __handle_mm_fault+0x63f/0x690 [] _do_fork+0xcd/0x3b0 [] do_syscall_64+0x5d/0x1d0 [] entry_SYSCALL_64_after_hwframe+0x65/0xca [] RIP: 0033:0x7f04418cd7e1 Between cgroup_can_fork() and cgroup_post_fork(), the cgroup membership and thus sched_task_group can't change. So update child's sched_task_group at sched_post_fork() and move task_fork() and __set_task_cpu() (where accees the sched_task_group) from sched_fork() to sched_post_fork(). Fixes: 8323f26ce342 ("sched: Fix race in task_group") Signed-off-by: Zhang Qiao Signed-off-by: Peter Zijlstra (Intel) Acked-by: Tejun Heo Link: https://lkml.kernel.org/r/20210915064030.2231-1-zhangqiao22@huawei.com Signed-off-by: Sasha Levin include/linux/sched/task.h | 3 ++- kernel/fork.c | 2 +- kernel/sched/core.c | 43 ++++++++++++++++++++++--------------------- 3 files changed, 25 insertions(+), 23 deletions(-) culprit signature: 8a3ee1ca15397d6221b91b4cc9186db4f259b5530c884a94c39838b9bde2655e parent signature: f1c69816cb51e461e6bbc4ebaf065691c9b9427e94961a3b26afc04dcb976f8f revisions tested: 18, total time: 2h39m59.186851451s (build: 1h30m14.833739937s, test: 1h7m52.93463523s) first bad commit: c85c6fadbef0a3eab41540ea628fa8fe8928c820 kernel/sched: Fix sched_fork() access an invalid sched_task_group recipients (to): ["peterz@infradead.org" "sashal@kernel.org" "tj@kernel.org" "zhangqiao22@huawei.com"] recipients (cc): [] crash: general protection fault in reweight_entity general protection fault, probably for non-canonical address 0xdffffc0000000014: 0000 [#1] PREEMPT SMP KASAN KASAN: null-ptr-deref in range [0x00000000000000a0-0x00000000000000a7] CPU: 1 PID: 32312 Comm: syz-executor329 Not tainted 5.10.79-syzkaller #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011 RIP: 0010:dequeue_load_avg kernel/sched/fair.c:3085 [inline] RIP: 0010:reweight_entity+0x125/0x750 kernel/sched/fair.c:3104 Code: 80 3c 11 00 0f 85 22 06 00 00 4d 8d 94 24 a0 00 00 00 4c 8b ab a0 01 00 00 48 ba 00 00 00 00 00 fc ff df 4c 89 d1 48 c1 e9 03 <80> 3c 11 00 0f 85 74 05 00 00 49 8b 94 24 a0 00 00 00 b9 00 00 00 RSP: 0018:ffffc900038d7c98 EFLAGS: 00010006 RAX: 0000000000003c00 RBX: ffff888110364b80 RCX: 0000000000000014 RDX: dffffc0000000000 RSI: ffff888110364b80 RDI: 0000000000000000 RBP: ffffc900038d7ce8 R08: ffff888110364bb8 R09: ffff888110364d20 R10: 00000000000000a0 R11: 0000000000000001 R12: 0000000000000000 R13: 0000000000000400 R14: 0000000000000000 R15: ffff888110364b80 FS: 00007f85eaf3e700(0000) GS:ffff8881f7100000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 00007f85eaf9f580 CR3: 000000011368d000 CR4: 00000000003506a0 DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 Call Trace: reweight_task+0xbc/0x1e0 kernel/sched/fair.c:3129 set_load_weight+0x1e9/0x320 kernel/sched/core.c:865 set_user_nice+0x233/0x10c0 kernel/sched/core.c:5010 set_one_prio+0x1ad/0x220 kernel/sys.c:192 __do_sys_setpriority+0x201/0x680 kernel/sys.c:233 __se_sys_setpriority kernel/sys.c:197 [inline] __x64_sys_setpriority+0x6e/0xb0 kernel/sys.c:197 do_syscall_64+0x32/0x80 arch/x86/entry/common.c:46 entry_SYSCALL_64_after_hwframe+0x44/0xa9 RIP: 0033:0x7f85eaf8c8b9 Code: 28 00 00 00 75 05 48 83 c4 28 c3 e8 11 15 00 00 90 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:00007f85eaf3e318 EFLAGS: 00000246 ORIG_RAX: 000000000000008d RAX: ffffffffffffffda RBX: 00007f85eb0143e8 RCX: 00007f85eaf8c8b9 RDX: 0000000000008f82 RSI: 0000000000000000 RDI: 0000000000000001 RBP: 00007f85eb0143e0 R08: 00007f85eaf3e700 R09: 0000000000000000 R10: 00007f85eaf3e700 R11: 0000000000000246 R12: 00007f85eb0143ec R13: 00007ffc42dfe37f R14: 00007f85eaf3e400 R15: 0000000000022000 Modules linked in: ---[ end trace feaa9d090c219c76 ]--- RIP: 0010:dequeue_load_avg kernel/sched/fair.c:3085 [inline] RIP: 0010:reweight_entity+0x125/0x750 kernel/sched/fair.c:3104 Code: 80 3c 11 00 0f 85 22 06 00 00 4d 8d 94 24 a0 00 00 00 4c 8b ab a0 01 00 00 48 ba 00 00 00 00 00 fc ff df 4c 89 d1 48 c1 e9 03 <80> 3c 11 00 0f 85 74 05 00 00 49 8b 94 24 a0 00 00 00 b9 00 00 00 RSP: 0018:ffffc900038d7c98 EFLAGS: 00010006 RAX: 0000000000003c00 RBX: ffff888110364b80 RCX: 0000000000000014 RDX: dffffc0000000000 RSI: ffff888110364b80 RDI: 0000000000000000 RBP: ffffc900038d7ce8 R08: ffff888110364bb8 R09: ffff888110364d20 R10: 00000000000000a0 R11: 0000000000000001 R12: 0000000000000000 R13: 0000000000000400 R14: 0000000000000000 R15: ffff888110364b80 FS: 00007f85eaf3e700(0000) GS:ffff8881f7100000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 00007f85eaf9f580 CR3: 000000011368d000 CR4: 00000000003506a0 DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 ---------------- Code disassembly (best guess): 0: 80 3c 11 00 cmpb $0x0,(%rcx,%rdx,1) 4: 0f 85 22 06 00 00 jne 0x62c a: 4d 8d 94 24 a0 00 00 lea 0xa0(%r12),%r10 11: 00 12: 4c 8b ab a0 01 00 00 mov 0x1a0(%rbx),%r13 19: 48 ba 00 00 00 00 00 movabs $0xdffffc0000000000,%rdx 20: fc ff df 23: 4c 89 d1 mov %r10,%rcx 26: 48 c1 e9 03 shr $0x3,%rcx * 2a: 80 3c 11 00 cmpb $0x0,(%rcx,%rdx,1) <-- trapping instruction 2e: 0f 85 74 05 00 00 jne 0x5a8 34: 49 8b 94 24 a0 00 00 mov 0xa0(%r12),%rdx 3b: 00 3c: b9 .byte 0xb9 3d: 00 00 add %al,(%rax)