Patch "net: Fix slab-out-of-bounds in inet[6]_steal_sock" has been added to the 5.15-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    net: Fix slab-out-of-bounds in inet[6]_steal_sock

to the 5.15-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     net-fix-slab-out-of-bounds-in-inet-6-_steal_sock.patch
and it can be found in the queue-5.15 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit 430fce638025f2cbeed253cadc4471699844dddb
Author: Lorenz Bauer <lmb@xxxxxxxxxxxxx>
Date:   Tue Aug 15 09:53:41 2023 +0100

    net: Fix slab-out-of-bounds in inet[6]_steal_sock
    
    [ Upstream commit 8897562f67b3e61ad736cd5c9f307447d33280e4 ]
    
    Kumar reported a KASAN splat in tcp_v6_rcv:
    
      bash-5.2# ./test_progs -t btf_skc_cls_ingress
      ...
      [   51.810085] BUG: KASAN: slab-out-of-bounds in tcp_v6_rcv+0x2d7d/0x3440
      [   51.810458] Read of size 2 at addr ffff8881053f038c by task test_progs/226
    
    The problem is that inet[6]_steal_sock accesses sk->sk_protocol without
    accounting for request or timewait sockets. To fix this we can't just
    check sock_common->skc_reuseport since that flag is present on timewait
    sockets.
    
    Instead, add a fullsock check to avoid the out of bands access of sk_protocol.
    
    Fixes: 9c02bec95954 ("bpf, net: Support SO_REUSEPORT sockets with bpf_sk_assign")
    Reported-by: Kumar Kartikeya Dwivedi <memxor@xxxxxxxxx>
    Signed-off-by: Lorenz Bauer <lmb@xxxxxxxxxxxxx>
    Link: https://lore.kernel.org/r/20230815-bpf-next-v2-1-95126eaa4c1b@xxxxxxxxxxxxx
    Signed-off-by: Martin KaFai Lau <martin.lau@xxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/include/net/inet6_hashtables.h b/include/net/inet6_hashtables.h
index 475e672b4facc..12780b8fb5630 100644
--- a/include/net/inet6_hashtables.h
+++ b/include/net/inet6_hashtables.h
@@ -107,7 +107,7 @@ struct sock *inet6_steal_sock(struct net *net, struct sk_buff *skb, int doff,
 	if (!sk)
 		return NULL;
 
-	if (!prefetched)
+	if (!prefetched || !sk_fullsock(sk))
 		return sk;
 
 	if (sk->sk_protocol == IPPROTO_TCP) {
diff --git a/include/net/inet_hashtables.h b/include/net/inet_hashtables.h
index 06f1ab600481e..0cc2a88d1c37c 100644
--- a/include/net/inet_hashtables.h
+++ b/include/net/inet_hashtables.h
@@ -395,7 +395,7 @@ struct sock *inet_steal_sock(struct net *net, struct sk_buff *skb, int doff,
 	if (!sk)
 		return NULL;
 
-	if (!prefetched)
+	if (!prefetched || !sk_fullsock(sk))
 		return sk;
 
 	if (sk->sk_protocol == IPPROTO_TCP) {



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux