]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
ipv6: Fix potential uninit-value access in __ip6_make_skb()
authorShigeru Yoshida <syoshida@redhat.com>
Mon, 6 May 2024 14:11:29 +0000 (23:11 +0900)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 22 May 2025 12:10:10 +0000 (14:10 +0200)
commit 4e13d3a9c25b7080f8a619f961e943fe08c2672c upstream.

As it was done in commit fc1092f51567 ("ipv4: Fix uninit-value access in
__ip_make_skb()") for IPv4, check FLOWI_FLAG_KNOWN_NH on fl6->flowi6_flags
instead of testing HDRINCL on the socket to avoid a race condition which
causes uninit-value access.

Fixes: ea30388baebc ("ipv6: Fix an uninit variable access bug in __ip6_make_skb()")
Signed-off-by: Shigeru Yoshida <syoshida@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Zhaoyang Li <lizy04@hust.edu.cn>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
net/ipv6/ip6_output.c

index d7f7a714bd2326cfaa46abe3cd38663eeb8ce0d8..f7a225da8525b5ae2cfee760c2cf71e6128b77e9 100644 (file)
@@ -1985,7 +1985,8 @@ struct sk_buff *__ip6_make_skb(struct sock *sk,
                struct inet6_dev *idev = ip6_dst_idev(skb_dst(skb));
                u8 icmp6_type;
 
-               if (sk->sk_socket->type == SOCK_RAW && !inet_sk(sk)->hdrincl)
+               if (sk->sk_socket->type == SOCK_RAW &&
+                   !(fl6->flowi6_flags & FLOWI_FLAG_KNOWN_NH))
                        icmp6_type = fl6->fl6_icmp_type;
                else
                        icmp6_type = icmp6_hdr(skb)->icmp6_type;