Eric Dumazet
34a5ee69ec
net: add vlan_get_protocol_and_depth() helper
[ Upstream commit 4063384ef762cc5946fc7a3f89879e76c6ec51e2 ]
Before blamed commit, pskb_may_pull() was used instead
of skb_header_pointer() in __vlan_get_protocol() and friends.
Few callers depended on skb->head being populated with MAC header,
syzbot caught one of them (skb_mac_gso_segment())
Add vlan_get_protocol_and_depth() to make the intent clearer
and use it where sensible.
This is a more generic fix than commit e9d3f80935b6
("net/af_packet: make sure to pull mac header") which was
dealing with a similar issue.
kernel BUG at include/linux/skbuff.h:2655 !
invalid opcode: 0000 [#1] SMP KASAN
CPU: 0 PID: 1441 Comm: syz-executor199 Not tainted 6.1.24-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 04/14/2023
RIP: 0010:__skb_pull include/linux/skbuff.h:2655 [inline]
RIP: 0010:skb_mac_gso_segment+0x68f/0x6a0 net/core/gro.c:136
Code: fd 48 8b 5c 24 10 44 89 6b 70 48 c7 c7 c0 ae 0d 86 44 89 e6 e8 a1 91 d0 00 48 c7 c7 00 af 0d 86 48 89 de 31 d2 e8 d1 4a e9 ff <0f> 0b 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 44 00 00 55 48 89 e5 41
RSP: 0018:ffffc90001bd7520 EFLAGS: 00010286
RAX: ffffffff8469736a RBX: ffff88810f31dac0 RCX: ffff888115a18b00
RDX: 0000000000000000 RSI: 0000000000000000 RDI: 0000000000000000
RBP: ffffc90001bd75e8 R08: ffffffff84697183 R09: fffff5200037adf9
R10: 0000000000000000 R11: dffffc0000000001 R12: 0000000000000012
R13: 000000000000fee5 R14: 0000000000005865 R15: 000000000000fed7
FS: 000055555633f300(0000) GS:ffff8881f6a00000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 0000000020000000 CR3: 0000000116fea000 CR4: 00000000003506f0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
Call Trace:
<TASK>
[<ffffffff847018dd>] __skb_gso_segment+0x32d/0x4c0 net/core/dev.c:3419
[<ffffffff8470398a>] skb_gso_segment include/linux/netdevice.h:4819 [inline]
[<ffffffff8470398a>] validate_xmit_skb+0x3aa/0xee0 net/core/dev.c:3725
[<ffffffff84707042>] __dev_queue_xmit+0x1332/0x3300 net/core/dev.c:4313
[<ffffffff851a9ec7>] dev_queue_xmit+0x17/0x20 include/linux/netdevice.h:3029
[<ffffffff851b4a82>] packet_snd net/packet/af_packet.c:3111 [inline]
[<ffffffff851b4a82>] packet_sendmsg+0x49d2/0x6470 net/packet/af_packet.c:3142
[<ffffffff84669a12>] sock_sendmsg_nosec net/socket.c:716 [inline]
[<ffffffff84669a12>] sock_sendmsg net/socket.c:736 [inline]
[<ffffffff84669a12>] __sys_sendto+0x472/0x5f0 net/socket.c:2139
[<ffffffff84669c75>] __do_sys_sendto net/socket.c:2151 [inline]
[<ffffffff84669c75>] __se_sys_sendto net/socket.c:2147 [inline]
[<ffffffff84669c75>] __x64_sys_sendto+0xe5/0x100 net/socket.c:2147
[<ffffffff8551d40f>] do_syscall_x64 arch/x86/entry/common.c:50 [inline]
[<ffffffff8551d40f>] do_syscall_64+0x2f/0x50 arch/x86/entry/common.c:80
[<ffffffff85600087>] entry_SYSCALL_64_after_hwframe+0x63/0xcd
Fixes: 469aceddfa
("vlan: consolidate VLAN parsing code and limit max parsing depth")
Reported-by: syzbot <syzkaller@googlegroups.com>
Signed-off-by: Eric Dumazet <edumazet@google.com>
Cc: Toke Høiland-Jørgensen <toke@redhat.com>
Cc: Willem de Bruijn <willemb@google.com>
Reviewed-by: Simon Horman <simon.horman@corigine.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2023-05-30 12:57:46 +01:00
..
2022-08-31 17:15:20 +02:00
2021-02-17 11:02:28 +01:00
2019-03-27 13:49:44 -07:00
2020-09-28 15:00:15 -07:00
2022-09-28 11:10:35 +02:00
2023-05-30 12:57:46 +01:00
2022-08-25 11:37:57 +02:00
2022-02-23 12:01:02 +01:00
2021-12-08 09:03:22 +01:00
2021-03-30 14:32:05 +02:00
2019-04-10 22:12:26 -07:00
2019-10-04 11:10:56 -07:00
2021-12-08 09:03:21 +01:00
2023-03-03 11:44:51 +01:00
2022-12-02 17:40:00 +01:00
2022-06-14 18:32:40 +02:00
2021-01-27 11:55:23 +01:00
2020-04-28 14:39:46 -07:00
2022-08-31 17:15:19 +02:00
2019-06-09 19:40:10 -07:00
2021-08-18 08:59:13 +02:00
2022-05-09 09:05:02 +02:00
2022-01-11 15:25:00 +01:00
2019-12-12 17:07:05 -08:00
2023-03-03 11:44:51 +01:00
2023-02-01 08:23:24 +01:00
2022-02-01 17:25:44 +01:00
2022-03-16 14:16:00 +01:00
2020-02-26 20:07:25 -08:00
2019-06-19 11:23:13 -04:00
2020-04-21 15:44:30 -07:00
2019-05-30 11:26:32 -07:00
2023-04-20 12:10:21 +02:00
2020-05-09 20:59:21 -07:00
2021-05-19 10:13:17 +02:00
2021-03-07 12:34:09 +01:00
2020-08-19 16:07:49 -07:00
2019-10-13 10:13:08 -07:00
2022-07-29 17:19:07 +02:00
2020-07-13 11:03:44 -07:00
2022-07-29 17:19:21 +02:00
2023-05-17 11:47:54 +02:00
2022-09-05 10:28:56 +02:00
2020-09-30 11:50:35 -07:00
2023-05-17 11:47:52 +02:00
2022-10-30 09:41:19 +01:00
2023-03-11 16:39:26 +01:00
2023-05-30 12:57:46 +01:00
2022-08-31 17:15:19 +02:00
2019-12-25 19:51:33 -08:00
2020-06-18 20:46:23 -07:00
2020-01-24 20:54:30 +01:00
2021-04-14 08:42:09 +02:00