Eric Dumazet
8ce48623f0
ipv6: tcp: restore IP6CB for pktoptions skbs
Baozeng Ding reported following KASAN splat :
BUG: KASAN: use-after-free in ip6_datagram_recv_specific_ctl+0x13f1/0x15c0 at addr ffff880029c84ec8
Read of size 1 by task poc/25548
Call Trace:
[<ffffffff82cf43c9>] dump_stack+0x12e/0x185 /lib/dump_stack.c:15
[< inline >] print_address_description /mm/kasan/report.c:204
[<ffffffff817ced3b>] kasan_report_error+0x48b/0x4b0 /mm/kasan/report.c:283
[< inline >] kasan_report /mm/kasan/report.c:303
[<ffffffff817ced9e>] __asan_report_load1_noabort+0x3e/0x40 /mm/kasan/report.c:321
[<ffffffff85c71da1>] ip6_datagram_recv_specific_ctl+0x13f1/0x15c0 /net/ipv6/datagram.c:687
[<ffffffff85c734c3>] ip6_datagram_recv_ctl+0x33/0x40
[<ffffffff85c0b07c>] do_ipv6_getsockopt.isra.4+0xaec/0x2150
[<ffffffff85c0c7f6>] ipv6_getsockopt+0x116/0x230
[<ffffffff859b5a12>] tcp_getsockopt+0x82/0xd0 /net/ipv4/tcp.c:3035
[<ffffffff855fb385>] sock_common_getsockopt+0x95/0xd0 /net/core/sock.c:2647
[< inline >] SYSC_getsockopt /net/socket.c:1776
[<ffffffff855f8ba2>] SyS_getsockopt+0x142/0x230 /net/socket.c:1758
[<ffffffff8685cdc5>] entry_SYSCALL_64_fastpath+0x23/0xc6
Memory state around the buggy address:
ffff880029c84d80: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
ffff880029c84e00: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
> ffff880029c84e80: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
^
ffff880029c84f00: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
ffff880029c84f80: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
He also provided a syzkaller reproducer.
Issue is that ip6_datagram_recv_specific_ctl() expects to find IP6CB
data that was moved at a different place in tcp_v6_rcv()
This patch moves tcp_v6_restore_cb() up and calls it from
tcp_v6_do_rcv() when np->pktoptions is set.
Fixes: 971f10eca1 ("tcp: better TCP_SKB_CB layout to reduce cache line misses")
Signed-off-by: Eric Dumazet <edumazet@google.com>
Reported-by: Baozeng Ding <sploving1@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2016-10-13 11:07:34 -04:00
..
2016-09-19 20:19:34 +02:00
2016-09-23 13:47:44 -04:00
2016-08-13 15:15:54 -07:00
2016-09-10 21:19:10 -07:00
2016-09-10 21:19:10 -07:00
2016-06-18 20:55:34 -07:00
2016-10-11 15:06:33 -07:00
2016-10-06 11:52:29 +02:00
2016-10-02 22:44:03 -04:00
2016-06-28 05:26:14 -04:00
2016-06-23 11:23:49 +02:00
2016-10-05 23:02:10 +02:00
2016-10-07 21:38:00 -07:00
2016-07-29 17:38:46 -07:00
2016-07-05 14:08:47 -07:00
2016-09-23 08:38:50 -04:00
2016-05-16 14:00:43 -04:00
2016-07-08 13:23:12 +02:00
2016-10-07 21:38:00 -07:00
2016-10-13 11:07:34 -04:00
2016-09-23 06:46:57 -04:00
2016-07-29 17:38:46 -07:00
2016-10-07 15:36:58 -07:00
2016-09-17 10:07:23 -04:00
2016-09-10 23:12:53 -07:00
2016-05-29 22:33:25 -07:00
2016-09-17 10:05:05 -04:00
2016-10-04 09:46:44 +02:00
2016-09-19 20:19:34 +02:00
2016-10-03 02:00:21 -04:00
2016-10-04 02:11:51 -04:00
2016-10-11 04:44:37 -04:00
2016-06-27 15:06:18 -04:00
2016-10-06 20:53:13 -04:00
2016-07-11 02:02:03 +02:00
2016-10-13 10:03:23 -04:00
2016-10-06 20:50:18 -04:00
2016-05-17 14:11:19 -04:00
2016-09-23 13:47:44 -04:00
2016-07-13 11:53:40 -07:00
2016-10-06 08:11:51 +01:00
2016-10-13 10:26:43 -04:00
2016-10-02 22:20:41 -04:00
2016-10-12 01:51:49 -04:00
2016-10-10 20:16:43 -07:00
2016-09-28 04:48:00 -04:00
2016-09-13 11:28:32 -04:00
2016-10-03 20:40:56 -04:00
2016-09-27 07:59:25 -04:00
2016-10-04 09:46:44 +02:00
2016-09-09 18:13:30 -07:00
2016-09-30 01:50:45 -04:00
2016-06-09 23:41:03 -07:00
2016-08-17 19:36:23 -04:00
2016-08-17 19:36:23 -04:00
2016-10-07 21:48:36 -04:00
2016-10-06 09:52:23 -07:00