[syzbot] kernel BUG in pskb_expand_head

Started by syzbot on Nov 15, 2021 · 8 messages from 4 authors · Last reply Jan 5, 2022

open the first message on its own page

Message details and related content
Hello,

syzbot found the following issue on:

HEAD commit:    debe436e77c7 Merge tag 'ext4_for_linus' of git://git.kerne..
git tree:       upstream
console output: https://syzkaller.appspot.com/x/log.txt?x=17cdbcf1b00000
kernel config:  https://syzkaller.appspot.com/x/.config?x=dcce4e862d74e466
dashboard link: https://syzkaller.appspot.com/bug?extid=4c63f36709a642f801c5
compiler:       gcc (Debian 10.2.1-6) 10.2.1 20210110, GNU ld (GNU Binutils for Debian) 2.35.2

Unfortunately, I don't have any reproducer for this issue yet.

IMPORTANT: if you fix the issue, please add the following tag to the commit:
Reported-by: <redacted>

------------[ cut here ]------------
kernel BUG at net/core/skbuff.c:1695!
invalid opcode: 0000 [#1] PREEMPT SMP KASAN
CPU: 0 PID: 13268 Comm: syz-executor.1 Not tainted 5.15.0-syzkaller #0
Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.14.0-2 04/01/2014
RIP: 0010:pskb_expand_head+0xb28/0x1060 net/core/skbuff.c:1695
Code: 8d 75 ff e9 60 fe ff ff e8 75 dd 5a fa 48 c7 c6 a0 60 8c 8a 4c 89 f7 e8 c6 d6 8d fa 0f 0b e8 5f dd 5a fa 0f 0b e8 58 dd 5a fa <0f> 0b e8 51 dd 5a fa 41 81 cc 00 00 02 00 e9 f6 f5 ff ff e8 40 dd
RSP: 0018:ffffc90005a6f2e0 EFLAGS: 00010212
RAX: 0000000000030e8b RBX: ffff88801fa215c0 RCX: ffffc90020bf5000
RDX: 0000000000040000 RSI: ffffffff871c2298 RDI: 0000000000000003
RBP: 00000000ffffffbb R08: 0000000000000001 R09: ffff88801fa2169f
R10: ffffffff871c1842 R11: 0000000000000000 R12: 0000000000000a20
R13: 0000000000000002 R14: 0000000000000001 R15: 0000000000000000
FS:  00007f39135d8700(0000) GS:ffff88802ca00000(0000) knlGS:0000000000000000
CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 0000000020004038 CR3: 0000000065ef5000 CR4: 0000000000150ef0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000600
Call Trace:
 <TASK>
 __skb_pad+0x181/0x5f0 net/core/skbuff.c:1929
 __skb_put_padto include/linux/skbuff.h:3331 [inline]
 skb_put_padto include/linux/skbuff.h:3350 [inline]
 eth_skb_pad include/linux/etherdevice.h:584 [inline]

57 more lines

Message details and related content
syzbot has found a reproducer for the following issue on:

HEAD commit:    434ed2138994 Merge branch 'tc-action-offload'
git tree:       net-next
console output: https://syzkaller.appspot.com/x/log.txt?x=1722300db00000
kernel config:  https://syzkaller.appspot.com/x/.config?x=7488eea316146357
dashboard link: https://syzkaller.appspot.com/bug?extid=4c63f36709a642f801c5
compiler:       gcc (Debian 10.2.1-6) 10.2.1 20210110, GNU ld (GNU Binutils for Debian) 2.35.2
syz repro:      https://syzkaller.appspot.com/x/repro.syz?x=14141ca3b00000

IMPORTANT: if you fix the issue, please add the following tag to the commit:
Reported-by: <redacted>

skbuff: skb_over_panic: text:ffffffff88257728 len:4096 put:4096 head:ffff8880769c1400 data:ffff8880769c1400 tail:0x1000 end:0xc0 dev:<NULL>
------------[ cut here ]------------
kernel BUG at net/core/skbuff.c:113!
invalid opcode: 0000 [#1] PREEMPT SMP KASAN
CPU: 0 PID: 13 Comm: ksoftirqd/0 Not tainted 5.16.0-rc5-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
RIP: 0010:skb_panic+0x16c/0x16e net/core/skbuff.c:113 net/core/skbuff.c:113
Code: f8 4c 8b 4c 24 10 8b 4b 70 41 56 45 89 e8 4c 89 e2 41 57 48 89 ee 48 c7 c7 a0 82 ad 8a ff 74 24 10 ff 74 24 20 e8 13 20 c2 ff <0f> 0b e8 6c 3d 35 f8 4c 8b 64 24 18 e8 f2 9e 7c f8 48 c7 c1 40 8f
RSP: 0018:ffffc90000d279e0 EFLAGS: 00010286
RAX: 000000000000008b RBX: ffff88801c5b8640 RCX: 0000000000000000
RDX: ffff888011938000 RSI: ffffffff815f21d8 RDI: fffff520001a4f2e
RBP: ffffffff8aad8f80 R08: 000000000000008b R09: 0000000000000000
R10: ffffffff815ebf7e R11: 0000000000000000 R12: ffffffff88257728
R13: 0000000000001000 R14: ffffffff8aad8260 R15: 00000000000000c0
FS:  0000000000000000(0000) GS:ffff8880b9c00000(0000) knlGS:0000000000000000
CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 00007f14858bf718 CR3: 0000000072e5c000 CR4: 00000000003506f0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
Call Trace:
 <TASK>
 skb_over_panic net/core/skbuff.c:118 [inline]
 skb_over_panic net/core/skbuff.c:118 [inline] net/core/skbuff.c:1986
 skb_put.cold+0x24/0x24 net/core/skbuff.c:1986 net/core/skbuff.c:1986
 isotp_rcv_cf net/can/isotp.c:570 [inline]
 isotp_rcv_cf net/can/isotp.c:570 [inline] net/can/isotp.c:668
 isotp_rcv+0xa38/0x1e30 net/can/isotp.c:668 net/can/isotp.c:668

36 more lines

Message details and related content
syzbot has bisected this issue to:

commit e4b8954074f6d0db01c8c97d338a67f9389c042f
Author: Eric Dumazet [off-list ref]
Date:   Tue Dec 7 01:30:37 2021 +0000

    netlink: add net device refcount tracker to struct ethnl_req_info

bisection log:  https://syzkaller.appspot.com/x/bisect.txt?x=109e6fcbb00000
start commit:   434ed2138994 Merge branch 'tc-action-offload'
git tree:       net-next
final oops:     https://syzkaller.appspot.com/x/report.txt?x=129e6fcbb00000
console output: https://syzkaller.appspot.com/x/log.txt?x=149e6fcbb00000
kernel config:  https://syzkaller.appspot.com/x/.config?x=7488eea316146357
dashboard link: https://syzkaller.appspot.com/bug?extid=4c63f36709a642f801c5
syz repro:      https://syzkaller.appspot.com/x/repro.syz?x=14141ca3b00000

Reported-by: <redacted>
Fixes: e4b8954074f6 ("netlink: add net device refcount tracker to struct ethnl_req_info")

For information about bisection process see: https://goo.gl/tpsmEJ#bisection
Message details and related content
syzbot has found a reproducer for the following issue on:

HEAD commit:    c9e6606c7fe9 Linux 5.16-rc8
git tree:       upstream
console output: https://syzkaller.appspot.com/x/log.txt?x=148351c3b00000
kernel config:  https://syzkaller.appspot.com/x/.config?x=32f9fa260d7413b4
dashboard link: https://syzkaller.appspot.com/bug?extid=4c63f36709a642f801c5
compiler:       gcc (Debian 10.2.1-6) 10.2.1 20210110, GNU ld (GNU Binutils for Debian) 2.35.2
syz repro:      https://syzkaller.appspot.com/x/repro.syz?x=15435e2bb00000
C reproducer:   https://syzkaller.appspot.com/x/repro.c?x=12f4508db00000

The issue was bisected to:

commit e4b8954074f6d0db01c8c97d338a67f9389c042f
Author: Eric Dumazet [off-list ref]
Date:   Tue Dec 7 01:30:37 2021 +0000

    netlink: add net device refcount tracker to struct ethnl_req_info

bisection log:  https://syzkaller.appspot.com/x/bisect.txt?x=109e6fcbb00000
final oops:     https://syzkaller.appspot.com/x/report.txt?x=129e6fcbb00000
console output: https://syzkaller.appspot.com/x/log.txt?x=149e6fcbb00000

IMPORTANT: if you fix the issue, please add the following tag to the commit:
Reported-by: <redacted>
Fixes: e4b8954074f6 ("netlink: add net device refcount tracker to struct ethnl_req_info")

skbuff: skb_over_panic: text:ffffffff88235fb8 len:4096 put:4096 head:ffff888021cb8400 data:ffff888021cb8400 tail:0x1000 end:0xc0 dev:<NULL>
------------[ cut here ]------------
kernel BUG at net/core/skbuff.c:113!
invalid opcode: 0000 [#1] PREEMPT SMP KASAN
CPU: 1 PID: 19 Comm: ksoftirqd/1 Not tainted 5.16.0-rc8-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
RIP: 0010:skb_panic+0x16c/0x16e net/core/skbuff.c:113
Code: f8 4c 8b 4c 24 10 8b 4b 70 41 56 45 89 e8 4c 89 e2 41 57 48 89 ee 48 c7 c7 e0 4b ad 8a ff 74 24 10 ff 74 24 20 e8 6e 24 c2 ff <0f> 0b e8 74 92 38 f8 4c 8b 64 24 18 e8 da 47 7f f8 48 c7 c1 80 58
RSP: 0018:ffffc90000d979e0 EFLAGS: 00010286
RAX: 000000000000008b RBX: ffff888021ccb500 RCX: 0000000000000000
RDX: ffff88801196d700 RSI: ffffffff815f0948 RDI: fffff520001b2f2e
RBP: ffffffff8aad58c0 R08: 000000000000008b R09: 0000000000000000
R10: ffffffff815ea6ee R11: 0000000000000000 R12: ffffffff88235fb8

45 more lines

Message details and related content
On 19.12.2021 16:19:20, syzbot wrote:
 skb_over_panic net/core/skbuff.c:118 [inline]
 skb_over_panic net/core/skbuff.c:118 [inline] net/core/skbuff.c:1986
 skb_put.cold+0x24/0x24 net/core/skbuff.c:1986 net/core/skbuff.c:1986
 isotp_rcv_cf net/can/isotp.c:570 [inline]
 isotp_rcv_cf net/can/isotp.c:570 [inline] net/can/isotp.c:668
 isotp_rcv+0xa38/0x1e30 net/can/isotp.c:668 net/can/isotp.c:668
struct tpcon {
	int idx;
	int len;
        ^^^
	u32 state;
	u8 bs;
	u8 sn;
	u8 ll_dl;
	u8 buf[MAX_MSG_LENGTH + 1];
};

static int isotp_rcv_ff(struct sock *sk, struct canfd_frame *cf, int ae)
{
[...]
	/* Check for FF_DL escape sequence supporting 32 bit PDU length */
	if (so->rx.len) {
		ff_pci_sz = FF_PCI_SZ12;
	} else {
		/* FF_DL = 0 => get real length from next 4 bytes */
		so->rx.len = cf->data[ae + 2] << 24;
		so->rx.len += cf->data[ae + 3] << 16;
		so->rx.len += cf->data[ae + 4] << 8;
		so->rx.len += cf->data[ae + 5];
		ff_pci_sz = FF_PCI_SZ32;
	}
Full 32 Bit PDUs don't work with struct tpcon::len being an "int". I
think converting it to "unsigned int" should be done.

[...]
}

static int isotp_rcv_cf(struct sock *sk, struct canfd_frame *cf, int ae,
			struct sk_buff *skb)
{
	struct isotp_sock *so = isotp_sk(sk);
	struct sk_buff *nskb;
	int i;

	if (so->rx.state != ISOTP_WAIT_DATA)
		return 0;

	/* drop if timestamp gap is less than force_rx_stmin nano secs */
	if (so->opt.flags & CAN_ISOTP_FORCE_RXSTMIN) {
		if (ktime_to_ns(ktime_sub(skb->tstamp, so->lastrxcf_tstamp)) <
		    so->force_rx_stmin)
			return 0;

		so->lastrxcf_tstamp = skb->tstamp;
	}

	hrtimer_cancel(&so->rxtimer);

	/* CFs are never longer than the FF */
	if (cf->len > so->rx.ll_dl)
		return 1;

	/* CFs have usually the LL_DL length */
	if (cf->len < so->rx.ll_dl) {
		/* this is only allowed for the last CF */
		if (so->rx.len - so->rx.idx > so->rx.ll_dl - ae - N_PCI_SZ)
			return 1;
	}

	if ((cf->data[ae] & 0x0F) != so->rx.sn) {
		/* wrong sn detected - report 'illegal byte sequence' */
		sk->sk_err = EILSEQ;
		if (!sock_flag(sk, SOCK_DEAD))
			sk_error_report(sk);

31 more quoted lines

                       ^^^^^^^
		       so->rx.len);
This is where the skb_over_panic() happens.

regards,
Marc

-- 
Pengutronix e.K.                 | Marc Kleine-Budde           |
Embedded Linux                   | https://www.pengutronix.de  |
Vertretung West/Dortmund         | Phone: +49-231-2826-924     |
Amtsgericht Hildesheim, HRA 2686 | Fax:   +49-5121-206917-5555 |
Message details and related content

On 05.01.22 12:44, Marc Kleine-Budde wrote:
On 19.12.2021 16:19:20, syzbot wrote:
quoted
  skb_over_panic net/core/skbuff.c:118 [inline]
  skb_over_panic net/core/skbuff.c:118 [inline] net/core/skbuff.c:1986
  skb_put.cold+0x24/0x24 net/core/skbuff.c:1986 net/core/skbuff.c:1986
  isotp_rcv_cf net/can/isotp.c:570 [inline]
  isotp_rcv_cf net/can/isotp.c:570 [inline] net/can/isotp.c:668
  isotp_rcv+0xa38/0x1e30 net/can/isotp.c:668 net/can/isotp.c:668
quoted
struct tpcon {
	int idx;
	int len;
         ^^^
quoted
	u32 state;
	u8 bs;
	u8 sn;
	u8 ll_dl;
	u8 buf[MAX_MSG_LENGTH + 1];
};

static int isotp_rcv_ff(struct sock *sk, struct canfd_frame *cf, int ae)
{
[...]
quoted
	/* Check for FF_DL escape sequence supporting 32 bit PDU length */
	if (so->rx.len) {
		ff_pci_sz = FF_PCI_SZ12;
	} else {
		/* FF_DL = 0 => get real length from next 4 bytes */
		so->rx.len = cf->data[ae + 2] << 24;
		so->rx.len += cf->data[ae + 3] << 16;
		so->rx.len += cf->data[ae + 4] << 8;
		so->rx.len += cf->data[ae + 5];
		ff_pci_sz = FF_PCI_SZ32;
	}
Full 32 Bit PDUs don't work with struct tpcon::len being an "int". I
think converting it to "unsigned int" should be done.

[...]

77 more quoted lines

Thanks Marc!

Yes I went to this piece of code too - but was not able to find anything wrong, as the values at this point should be far(!!) away from INT_MAX.

Due to this check in isotp_rcv_ff():

if (so->rx.len > MAX_MSG_LENGTH) { ... exit

And MAX_MSG_LENGTH is define as 8200.

Btw. making tpcon:len an unsigned int is really the solution to this! Which makes the above if-statement act correctly also with values like 0x80001234.

m(

Thanks for the finding!

Best regards,
Oliver
Message details and related content
On Wed, Jan 5, 2022 at 3:20 AM syzbot
[off-list ref] wrote:
syzbot has found a reproducer for the following issue on:

HEAD commit:    c9e6606c7fe9 Linux 5.16-rc8
git tree:       upstream
console output: https://syzkaller.appspot.com/x/log.txt?x=148351c3b00000
kernel config:  https://syzkaller.appspot.com/x/.config?x=32f9fa260d7413b4
dashboard link: https://syzkaller.appspot.com/bug?extid=4c63f36709a642f801c5
compiler:       gcc (Debian 10.2.1-6) 10.2.1 20210110, GNU ld (GNU Binutils for Debian) 2.35.2
syz repro:      https://syzkaller.appspot.com/x/repro.syz?x=15435e2bb00000
C reproducer:   https://syzkaller.appspot.com/x/repro.c?x=12f4508db00000
This C repro looks legit, bug should be in CAN layer.
The issue was bisected to:

commit e4b8954074f6d0db01c8c97d338a67f9389c042f
Author: Eric Dumazet [off-list ref]
Date:   Tue Dec 7 01:30:37 2021 +0000

    netlink: add net device refcount tracker to struct ethnl_req_info
Ignore this bisection, an unrelated commit whent in its way.
bisection log:  https://syzkaller.appspot.com/x/bisect.txt?x=109e6fcbb00000
final oops:     https://syzkaller.appspot.com/x/report.txt?x=129e6fcbb00000
console output: https://syzkaller.appspot.com/x/log.txt?x=149e6fcbb00000

IMPORTANT: if you fix the issue, please add the following tag to the commit:
Reported-by: <redacted>
Fixes: e4b8954074f6 ("netlink: add net device refcount tracker to struct ethnl_req_info")

skbuff: skb_over_panic: text:ffffffff88235fb8 len:4096 put:4096 head:ffff888021cb8400 data:ffff888021cb8400 tail:0x1000 end:0xc0 dev:<NULL>
------------[ cut here ]------------
kernel BUG at net/core/skbuff.c:113!
invalid opcode: 0000 [#1] PREEMPT SMP KASAN
CPU: 1 PID: 19 Comm: ksoftirqd/1 Not tainted 5.16.0-rc8-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
RIP: 0010:skb_panic+0x16c/0x16e net/core/skbuff.c:113
Code: f8 4c 8b 4c 24 10 8b 4b 70 41 56 45 89 e8 4c 89 e2 41 57 48 89 ee 48 c7 c7 e0 4b ad 8a ff 74 24 10 ff 74 24 20 e8 6e 24 c2 ff <0f> 0b e8 74 92 38 f8 4c 8b 64 24 18 e8 da 47 7f f8 48 c7 c1 80 58
RSP: 0018:ffffc90000d979e0 EFLAGS: 00010286
RAX: 000000000000008b RBX: ffff888021ccb500 RCX: 0000000000000000
RDX: ffff88801196d700 RSI: ffffffff815f0948 RDI: fffff520001b2f2e
RBP: ffffffff8aad58c0 R08: 000000000000008b R09: 0000000000000000
R10: ffffffff815ea6ee R11: 0000000000000000 R12: ffffffff88235fb8
R13: 0000000000001000 R14: ffffffff8aad4ba0 R15: 00000000000000c0
FS:  0000000000000000(0000) GS:ffff8880b9d00000(0000) knlGS:0000000000000000
CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 00007f886c8cc718 CR3: 000000007ad6d000 CR4: 00000000003506e0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
Call Trace:
 <TASK>
 skb_over_panic net/core/skbuff.c:118 [inline]
 skb_put.cold+0x24/0x24 net/core/skbuff.c:1990
 isotp_rcv_cf net/can/isotp.c:570 [inline]
 isotp_rcv+0xa38/0x1e30 net/can/isotp.c:668
 deliver net/can/af_can.c:574 [inline]
 can_rcv_filter+0x445/0x8d0 net/can/af_can.c:635
 can_receive+0x31d/0x580 net/can/af_can.c:665
 can_rcv+0x120/0x1c0 net/can/af_can.c:696
 __netif_receive_skb_one_core+0x114/0x180 net/core/dev.c:5465
 __netif_receive_skb+0x24/0x1b0 net/core/dev.c:5579

27 more quoted lines

Message details and related content
On 05.01.2022 05:59:35, Eric Dumazet wrote:
On Wed, Jan 5, 2022 at 3:20 AM syzbot
[off-list ref] wrote:
quoted
syzbot has found a reproducer for the following issue on:

HEAD commit:    c9e6606c7fe9 Linux 5.16-rc8
git tree:       upstream
console output: https://syzkaller.appspot.com/x/log.txt?x=148351c3b00000
kernel config:  https://syzkaller.appspot.com/x/.config?x=32f9fa260d7413b4
dashboard link: https://syzkaller.appspot.com/bug?extid=4c63f36709a642f801c5
compiler:       gcc (Debian 10.2.1-6) 10.2.1 20210110, GNU ld (GNU Binutils for Debian) 2.35.2
syz repro:      https://syzkaller.appspot.com/x/repro.syz?x=15435e2bb00000
C reproducer:   https://syzkaller.appspot.com/x/repro.c?x=12f4508db00000
This C repro looks legit, bug should be in CAN layer.
ACK - it's bug in CAN's ISOTP
quoted
The issue was bisected to:

commit e4b8954074f6d0db01c8c97d338a67f9389c042f
Author: Eric Dumazet [off-list ref]
Date:   Tue Dec 7 01:30:37 2021 +0000

    netlink: add net device refcount tracker to struct ethnl_req_info
Ignore this bisection, an unrelated commit whent in its way.
ACK - We have a RFC fix for this:

https://lore.kernel.org/all/20220105132429.1170627-1-mkl@pengutronix.de

regards,
Marc

-- 
Pengutronix e.K.                 | Marc Kleine-Budde           |
Embedded Linux                   | https://www.pengutronix.de  |
Vertretung West/Dortmund         | Phone: +49-231-2826-924     |
Amtsgericht Hildesheim, HRA 2686 | Fax:   +49-5121-206917-5555 |
Keyboard shortcuts
hback out one level
jnext message in thread / next series-diff position
kprevious message in thread / previous series-diff position
ldrill in
Escclose help / fold thread tree
?toggle this help