yshigeru / linux-devel

Linux kernel source tree
Other
0 stars 0 forks source link

general protection fault in netdev_register_kobject #6

Closed yshigeru closed 1 year ago

yshigeru commented 1 year ago
RBP: 0000000000000002 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 000000000057bf8c
R13: ffffffffffffffb8 R14: 000000000057bf80 R15: 00007ffee17ac7d0
 </TASK>
general protection fault, probably for non-canonical address 0xdffffc0000000000: 0000 [#1] PREEMPT SMP KASAN
KASAN: null-ptr-deref in range [0x0000000000000000-0x0000000000000007]
CPU: 0 PID: 11382 Comm: syz-executor.7 Not tainted 6.5.0-11704-g3f86ed6ec0b3 #250
Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.16.2-1.fc38 04/01/2014
RIP: 0010:strchr+0x1b/0xb0 lib/string.c:329
Code: af f7 48 8b 74 24 08 48 8b 14 24 eb 8a 66 90 f3 0f 1e fa 48 b8 00 00 00 00 00 fc ff df 48 89 fa 55 48 c1 ea 03 53 48 83 ec 10 <0f> b6 04 02 48 89 fa 83 e2 07 38 d0 7f 04 84 c0 75 51 0f b6 07 89
RSP: 0018:ffffc9000c7c78c0 EFLAGS: 00010286
RAX: dffffc0000000000 RBX: 0000000000000000 RCX: ffffc900124ee000
RDX: 0000000000000000 RSI: 0000000000000025 RDI: 0000000000000000
RBP: ffffc9000c7c7950 R08: 0000000000000001 R09: 0000000000000000
R10: 0000000000000001 R11: 0000000000000000 R12: ffffc9000c7c7950
R13: 0000000000000cc0 R14: ffff8880401f2680 R15: 0000000000000001
FS:  00007ff60594f6c0(0000) GS:ffff88802ca00000(0000) knlGS:0000000000000000
CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 00007fca3875e008 CR3: 000000001eefd000 CR4: 0000000000750ef0
PKRU: 55555554
Call Trace:
 <TASK>
 kvasprintf_const+0x25/0x190 lib/kasprintf.c:45
 kobject_set_name_vargs+0x5a/0x130 lib/kobject.c:272
 kobject_add_varg lib/kobject.c:366 [inline]
 kobject_add+0x12a/0x240 lib/kobject.c:424
 device_add+0x290/0x1ac0 drivers/base/core.c:3560
 netdev_register_kobject+0x183/0x3f0 net/core/net-sysfs.c:2044
 register_netdevice+0xbce/0x1480 net/core/dev.c:10136
 slip_open+0xb7e/0x1120 drivers/net/slip/slip.c:833
 tty_ldisc_open+0x9b/0x100 drivers/tty/tty_ldisc.c:432
 tty_set_ldisc+0x364/0x7c0 drivers/tty/tty_ldisc.c:557
 tiocsetd drivers/tty/tty_io.c:2431 [inline]
 tty_ioctl+0x244/0x1570 drivers/tty/tty_io.c:2712
 vfs_ioctl fs/ioctl.c:51 [inline]
 __do_sys_ioctl fs/ioctl.c:871 [inline]
 __se_sys_ioctl fs/ioctl.c:857 [inline]
 __x64_sys_ioctl+0x18f/0x210 fs/ioctl.c:857
 do_syscall_x64 arch/x86/entry/common.c:50 [inline]
 do_syscall_64+0x39/0xb0 arch/x86/entry/common.c:80
 entry_SYSCALL_64_after_hwframe+0x63/0xcd
RIP: 0033:0x4448cd
Code: 2e 0f 1f 84 00 00 00 00 00 0f 1f 40 00 f3 0f 1e fa 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:00007ff60594f0c8 EFLAGS: 00000246 ORIG_RAX: 0000000000000010
RAX: ffffffffffffffda RBX: 000000000057bf80 RCX: 00000000004448cd
RDX: 0000000020000040 RSI: 0000000000005423 RDI: 0000000000000003
RBP: 0000000000000002 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 000000000057bf8c
R13: ffffffffffffffb8 R14: 000000000057bf80 R15: 00007ffee17ac7d0
 </TASK>
Modules linked in:
---[ end trace 0000000000000000 ]---
RIP: 0010:strchr+0x1b/0xb0 lib/string.c:329
Code: af f7 48 8b 74 24 08 48 8b 14 24 eb 8a 66 90 f3 0f 1e fa 48 b8 00 00 00 00 00 fc ff df 48 89 fa 55 48 c1 ea 03 53 48 83 ec 10 <0f> b6 04 02 48 89 fa 83 e2 07 38 d0 7f 04 84 c0 75 51 0f b6 07 89
RSP: 0018:ffffc9000c7c78c0 EFLAGS: 00010286
RAX: dffffc0000000000 RBX: 0000000000000000 RCX: ffffc900124ee000
RDX: 0000000000000000 RSI: 0000000000000025 RDI: 0000000000000000
RBP: ffffc9000c7c7950 R08: 0000000000000001 R09: 0000000000000000
R10: 0000000000000001 R11: 0000000000000000 R12: ffffc9000c7c7950
R13: 0000000000000cc0 R14: ffff8880401f2680 R15: 0000000000000001
FS:  00007ff60594f6c0(0000) GS:ffff88802ca00000(0000) knlGS:0000000000000000
CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 00007fca3875e008 CR3: 000000001eefd000 CR4: 0000000000750ef0
PKRU: 55555554
----------------
Code disassembly (best guess):
   0:   af                      scas   %es:(%rdi),%eax
   1:   f7 48 8b 74 24 08 48    testl  $0x48082474,-0x75(%rax)
   8:   8b 14 24                mov    (%rsp),%edx
   b:   eb 8a                   jmp    0xffffff97
   d:   66 90                   xchg   %ax,%ax
   f:   f3 0f 1e fa             endbr64
  13:   48 b8 00 00 00 00 00    movabs $0xdffffc0000000000,%rax
  1a:   fc ff df
  1d:   48 89 fa                mov    %rdi,%rdx
  20:   55                      push   %rbp
  21:   48 c1 ea 03             shr    $0x3,%rdx
  25:   53                      push   %rbx
  26:   48 83 ec 10             sub    $0x10,%rsp
* 2a:   0f b6 04 02             movzbl (%rdx,%rax,1),%eax <-- trapping instruction
  2e:   48 89 fa                mov    %rdi,%rdx
  31:   83 e2 07                and    $0x7,%edx
  34:   38 d0                   cmp    %dl,%al
  36:   7f 04                   jg     0x3c
  38:   84 c0                   test   %al,%al
  3a:   75 51                   jne    0x8d
  3c:   0f b6 07                movzbl (%rdi),%eax
  3f:   89                      .byte 0x89
yshigeru commented 1 year ago

repro.c.gz

yshigeru commented 1 year ago

参考:https://github.com/yshigeru/linux-devel/commit/95bf9798779af166b1d6d184d794834214a1a261

yshigeru commented 1 year ago

Fixed by this: https://lore.kernel.org/all/20230828145824.3895288-1-andriy.shevchenko@linux.intel.com/