Re: net: heap-out-of-bounds in sock_setsockopt
From: Cong Wang
Date: Wed Dec 16 2015 - 15:22:48 EST
On Wed, Dec 16, 2015 at 11:34 AM, Dmitry Vyukov <dvyukov@xxxxxxxxxx> wrote:
> BUG: KASAN: slab-out-of-bounds in sock_setsockopt+0x1284/0x13d0 at
> addr ffff88006563ec10
> Read of size 4 by task syzkaller_execu/4755
> =============================================================================
> BUG RAWv6 (Not tainted): kasan: bad access detected
> -----------------------------------------------------------------------------
> INFO: Allocated in sk_prot_alloc+0x69/0x340 age=17 cpu=3 pid=4755
> [< none >] kmem_cache_alloc+0x244/0x2c0 mm/slub.c:2607
> [< none >] sk_prot_alloc+0x69/0x340 net/core/sock.c:1343
> [< none >] sk_alloc+0x3a/0x6b0 net/core/sock.c:1418
> [< none >] inet6_create+0x2c4/0xfd0 net/ipv6/af_inet6.c:170
> [< none >] __sock_create+0x37c/0x640 net/socket.c:1162
> [< inline >] sock_create net/socket.c:1202
> [< inline >] SYSC_socket net/socket.c:1232
> [< none >] SyS_socket+0xef/0x1b0 net/socket.c:1212
> [< none >] entry_SYSCALL_64_fastpath+0x16/0x7a
> arch/x86/entry/entry_64.S:185
>
> Call Trace:
> [<ffffffff816cec2e>] __asan_report_load4_noabort+0x3e/0x40
> mm/kasan/report.c:294
> [<ffffffff84affb14>] sock_setsockopt+0x1284/0x13d0 net/core/sock.c:880
> [< inline >] SYSC_setsockopt net/socket.c:1746
> [<ffffffff84aed7ee>] SyS_setsockopt+0x1fe/0x240 net/socket.c:1729
> [<ffffffff85c18c76>] entry_SYSCALL_64_fastpath+0x16/0x7a
> arch/x86/entry/entry_64.S:185
Hmm, we should exclude the raw socket case, something like the
following, but I am not sure if the check is too strict or not, also
not sure if we should return an error for this raw socket case.
diff --git a/net/core/sock.c b/net/core/sock.c
index 765be83..c26e80a 100644
--- a/net/core/sock.c
+++ b/net/core/sock.c
@@ -872,7 +872,7 @@ int sock_setsockopt(struct socket *sock, int
level, int optname,
if (val & SOF_TIMESTAMPING_OPT_ID &&
!(sk->sk_tsflags & SOF_TIMESTAMPING_OPT_ID)) {
- if (sk->sk_protocol == IPPROTO_TCP) {
+ if (sk->sk_protocol == IPPROTO_TCP &&
sk->sk_type == SOCK_STREAM) {
if (sk->sk_state != TCP_ESTABLISHED) {
ret = -EINVAL;
break;
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/