Re: [BUG] null-ptr-deref bug in sctp_packet_bundle_auth
Chen Zhen <[email protected]>
| Newsgroups | org.kernel.vger.linux-sctp |
|---|---|
| Message-ID | <[email protected]> |
On 25/12/18 0:53, Xin Long wrote: > On Wed, Dec 17, 2025 at 8:13 AM Chen Zhen <[email protected]> wrote: >> >> Hi all, >> >> We tested with syzkaller on linux-6.6 and it reported a null-ptr-deref bug: >> >> ================================================================== >> general protection fault, probably for non-canonical address 0xdffffc0000000003: 0000 [#1] SMP KASAN PTI >> KASAN: null-ptr-deref in range [0x0000000000000018-0x000000000000001f] >> CPU: 0 PID: 16 Comm: ksoftirqd/0 Tainted: G W 6.6.0 #2 >> Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.13.0-1ubuntu1.1 04/01/2014 >> RIP: 0010:sctp_packet_bundle_auth net/sctp/output.c:264 [inline] >> RIP: 0010:sctp_packet_append_chunk+0xb36/0x1260 net/sctp/output.c:401 >> Code: 4c 89 f2 48 c1 ea 03 80 3c 02 00 0f 85 93 05 00 00 48 b8 00 00 00 00 00 fc ff df 4c 8b 7b 40 49 8d 7f 1c 48 89 fa 48 c1 ea 03 <0f> b6 14 02 48 89 f8 83 e0 07 83 c0 01 38 d0 7c 08 84 d2 0f 85 57 >> RSP: 0018:ffffc9000010efe8 EFLAGS: 00010207 >> RAX: dffffc0000000000 RBX: ffff88810c746000 RCX: ffffffff8d758fca >> RDX: 0000000000000003 RSI: ffff888100d1cd40 RDI: 000000000000001c >> RBP: ffff88811dea8b78 R08: 0000000000000000 R09: fffffbfff27f8b7d >> R10: fffffbfff27f8b7c R11: ffffffff93fc5be7 R12: ffff88804247c000 >> R13: ffff88811dea8bb8 R14: ffff88810c746040 R15: 0000000000000000 >> FS: 0000000000000000(0000) GS:ffff88816e600000(0000) knlGS:0000000000000000 >> CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 >> CR2: 0000000021000000 CR3: 000000011dfb4002 CR4: 0000000000170ef0 >> DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 >> DR3: 0000000000000000 DR6: 00000000ffff0ff0 DR7: 0000000000000600 >> Call Trace: >> >> sctp_packet_transmit_chunk+0x31/0x250 net/sctp/output.c:189 >> sctp_outq_flush_data+0xa29/0x26d0 net/sctp/outqueue.c:1111 >> sctp_outq_flush+0xc80/0x1240 net/sctp/outqueue.c:1217 >> sctp_cmd_interpreter.isra.0+0x19a5/0x62c0 net/sctp/sm_sideeffect.c:1787 >> sctp_side_effects net/sctp/sm_sideeffect.c:1198 [inline] >> sctp_do_sm+0x1a3/0x670 net/sctp/sm_sideeffect.c:1169 >> sctp_assoc_bh_rcv+0x33e/0x640 net/sctp/associola.c:1052 >> sctp_inq_push+0x1dd/0x280 net/sctp/inqueue.c:88 >> sctp_rcv+0x11ae/0x3100 net/sctp/input.c:243 >> sctp6_rcv+0x3d/0x60 net/sctp/ipv6.c:1127 >> ip6_protocol_deliver_rcu+0x12c1/0x1e40 net/ipv6/ip6_input.c:438 >> ip6_input_finish+0xc8/0x260 net/ipv6/ip6_input.c:483 >> NF_HOOK include/linux/netfilter.h:308 [inline] >> ip6_input+0xd1/0x430 net/ipv6/ip6_input.c:492 >> dst_input include/net/dst.h:487 [inline] >> ip6_rcv_finish+0x1b9/0x5c0 net/ipv6/ip6_input.c:79 >> NF_HOOK include/linux/netfilter.h:308 [inline] >> ipv6_rcv+0xf8/0x440 net/ipv6/ip6_input.c:310 >> __netif_receive_skb_one_core+0x133/0x1f0 net/core/dev.c:5603 >> __netif_receive_skb+0x24/0x1c0 net/core/dev.c:5717 >> process_backlog+0x21d/0x7e0 net/core/dev.c:6045 >> __napi_poll+0xc2/0x690 net/core/dev.c:6607 >> napi_poll net/core/dev.c:6674 [inline] >> net_rx_action+0x87d/0xce0 net/core/dev.c:6810 >> handle_softirqs+0x1b4/0x700 kernel/softirq.c:578 >> run_ksoftirqd kernel/softirq.c:997 [inline] >> run_ksoftirqd+0x2f/0x60 kernel/softirq.c:989 >> smpboot_thread_fn+0x3b9/0x860 kernel/smpboot.c:164 >> kthread+0x324/0x420 kernel/kthread.c:388 >> ret_from_fork+0x49/0x80 arch/x86/kernel/process.c:152 >> ret_from_fork_asm+0x1b/0x30 arch/x86/entry/entry_64.S:293 >> >> Modules linked in: >> kernel fault(0x1) notification starting on CPU 0 >> kernel fault(0x1) notification finished on CPU 0 >> ---[ end trace 0000000000000000 ]--- >> RIP: 0010:sctp_packet_bundle_auth net/sctp/output.c:264 [inline] >> RIP: 0010:sctp_packet_append_chunk+0xb36/0x1260 net/sctp/output.c:401 >> Code: 4c 89 f2 48 c1 ea 03 80 3c 02 00 0f 85 93 05 00 00 48 b8 00 00 00 00 00 fc ff df 4c 8b 7b 40 49 8d 7f 1c 48 89 fa 48 c1 ea 03 <0f> b6 14 02 48 89 f8 83 e0 07 83 c0 01 38 d0 7c 08 84 d2 0f 85 57 >> RSP: 0018:ffffc9000010efe8 EFLAGS: 00010207 >> RAX: dffffc0000000000 RBX: ffff88810c746000 RCX: ffffffff8d758fca >> RDX: 0000000000000003 RSI: ffff888100d1cd40 RDI: 000000000000001c >> RBP: ffff88811dea8b78 R08: 0000000000000000 R09: fffffbfff27f8b7d >> R10: fffffbfff27f8b7c R11: ffffffff93fc5be7 R12: ffff88804247c000 >> R13: ffff88811dea8bb8 R14: ffff88810c746040 R15: 0000000000000000 >> FS: 0000000000000000(0000) GS:ffff88816e600000(0000) knlGS:0000000000000000 >> CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 >> CR2: 0000000021000000 CR3: 000000011dfb4002 CR4: 0000000000170ef0 >> DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 >> DR3: 0000000000000000 DR6: 00000000ffff0ff0 DR7: 0000000000000600 >> Code disassembly (best guess): >> 0: 4c 89 f2 mov %r14,%rdx >> 3: 48 c1 ea 03 shr $0x3,%rdx >> 7: 80 3c 02 00 cmpb $0x0,(%rdx,%rax,1) >> b: 0f 85 93 05 00 00 jne 0x5a4 >> 11: 48 b8 00 00 00 00 00 movabs $0xdffffc0000000000,%rax >> 18: fc ff df >> 1b: 4c 8b 7b 40 mov 0x40(%rbx),%r15 >> 1f: 49 8d 7f 1c lea 0x1c(%r15),%rdi >> 23: 48 89 fa mov %rdi,%rdx >> 26: 48 c1 ea 03 shr $0x3,%rdx >> >> 2a: 0f b6 14 02 movzbl (%rdx,%rax,1),%edx <-- trapping instruction >> 2e: 48 89 f8 mov %rdi,%rax >> 31: 83 e0 07 and $0x7,%eax >> 34: 83 c0 01 add $0x1,%eax >> 37: 38 d0 cmp %dl,%al >> 39: 7c 08 jl 0x43 >> 3b: 84 d2 test %dl,%dl >> 3d: 0f .byte 0xf >> 3e: 85 .byte 0x85 >> 3f: 57 push %rdi >> ================================================================== >> >> The direct cause is that chunk->shkey is NULL in sctp_packet_bundle_auth(). >> >> if (!chunk->auth) >> return retval; >> >> auth = sctp_make_auth(asoc, chunk->shkey->key_id); <=== BUG >> if (!auth) >> return retval; >> >> It is simple to fix it by adding a null-ptr check before sctp_make_auth() but maybe >> there are better solutions? >> > We need to check how this was triggered? Do you have a reproducer for this? > > Thanks. > . ================== Syzkaller reproducer: {Threaded:false Repeat:true RepeatTimes:0 Procs:10 Slowdown:1 Sandbox:none SandboxArg:0 Leak:false NetInjection:true NetDevices:true NetReset:true Cgroups:true BinfmtMisc:true CloseFDs:true KCSAN:false DevlinkPCI:false NicVF:false USB:false VhciInjection:false Wifi:false IEEE802154:false Sysctl:true Swap:true UseTmpDir:true HandleSegv:true Repro:false Trace:false LegacyOptions:{Collide:false Fault:false FaultCall:0 FaultNth:0}} perf_event_open(0x0, 0x0, 0xffffffffffffffff, 0xffffffffffffffff, 0x0) sendmsg$nl_route_sched(0xffffffffffffffff, 0x0, 0x0) r0 = perf_event_open(0x0, 0x0, 0xffffffffffffffff, 0xffffffffffffffff, 0x0) r1 = socket$key(0xf, 0x3, 0x2) sendmsg$key(r1, 0x0, 0x0) fchown(r0, 0x0, 0xee01) sendmsg$key(r1, 0x0, 0x0) read$FUSE(0xffffffffffffffff, 0x0, 0x0) prlimit64(0x0, 0xe, 0x0, 0x0) sched_setscheduler(0x0, 0x2, 0x0) sched_setscheduler(0x0, 0x2, 0x0) ioctl$FS_IOC_SETFLAGS(0xffffffffffffffff, 0x40086602, 0x0) sendmmsg$unix(0xffffffffffffffff, 0x0, 0x0, 0x0) openat$null(0xffffffffffffff9c, 0x0, 0x600000, 0x0) getpgid(0x0) socket$nl_xfrm(0x10, 0x3, 0x6) perf_event_open(0x0, 0x0, 0xffffffffffffffff, 0xffffffffffffffff, 0x0) perf_event_open(&(0x7f0000000200)={0x1, 0x80, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, @perf_bp={0x0}}, 0x0, 0xffffffffffffffff, 0xffffffffffffffff, 0x0) write$eventfd(0xffffffffffffffff, 0x0, 0x0) perf_event_open(0x0, 0xffffffffffffffff, 0x0, 0xffffffffffffffff, 0x3) perf_event_open(0x0, 0x0, 0xffffffffffffffff, 0xffffffffffffffff, 0x0) socket$vsock_dgram(0x28, 0x2, 0x0) clock_adjtime(0x0, 0x0) perf_event_open(0x0, 0x0, 0xffffffffffffffff, 0xffffffffffffffff, 0x0) perf_event_open(&(0x7f0000000200)={0x1, 0x80, 0x0, 0x0, 0x0, 0x0, 0x0, 0x50d, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, @perf_bp={0x0}}, 0x0, 0xffffffffffffffff, 0xffffffffffffffff, 0x0) r2 = socket$inet6_sctp(0xa, 0x1, 0x84) setsockopt(r2, 0x84, 0x81, &(0x7f00000002c0)="1a00000019000000", 0x8) setsockopt$inet_sctp_SCTP_SOCKOPT_BINDX_ADD(r2, 0x84, 0x64, &(0x7f0000000380)=[@in6={0xa, 0x4e23, 0x0, @loopback}], 0x1c) setsockopt$inet_sctp6_SCTP_AUTH_CHUNK(r2, 0x84, 0x15, &(0x7f00000001c0), 0x1) r3 = syz_open_procfs$procfs_self_proc_file(0xffffffffffffffff, &(0x7f0000000180)='fail-nth\x00') write$cgroup_int(r3, &(0x7f0000000200)=0x48, 0x12) perf_event_open(&(0x7f0000000480)={0x0, 0x80, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, @perf_config_ext}, 0xffffffffffffffff, 0x0, 0xffffffffffffffff, 0x0) r4 = openat$euleros_proc_task_file(0xffffffffffffff9c, &(0x7f0000000440)='/proc/self/patch_state\x00', 0x20000, 0x0) perf_event_open(0x0, 0x0, 0x6, r4, 0x2) setsockopt$inet_sctp6_SCTP_ASSOCINFO(r3, 0x84, 0x1, &(0x7f0000000040)={0x0, 0xd6, 0x2, 0x2d820323, 0x7, 0x1}, 0x14) sendto$inet6(r2, &(0x7f0000000000)=' ', 0x1, 0x0, &(0x7f0000000080)={0xa, 0x4e23, 0x0, @loopback}, 0x1c) sendto$inet6(r2, &(0x7f0000000000)=' ', 0x1, 0x0, &(0x7f0000000080)={0xa, 0x4e23, 0x0, @loopback}, 0x1c) ================== It seems to be rare case because I cannot trigger this bug again with 24h+ of reproducing. Thanks.