| From ad283292428421e824bf67aebac1b0bead944e16 Mon Sep 17 00:00:00 2001 |
| From: Alexander Potapenko <glider@google.com> |
| Date: Tue, 21 Mar 2017 17:14:27 +0100 |
| Subject: [PATCH] ipv6: make sure to initialize sockc.tsflags before first use |
| |
| commit d515684d78148884d5fc425ba904c50f03844020 upstream. |
| |
| In the case udp_sk(sk)->pending is AF_INET6, udpv6_sendmsg() would |
| jump to do_append_data, skipping the initialization of sockc.tsflags. |
| Fix the problem by moving sockc.tsflags initialization earlier. |
| |
| The bug was detected with KMSAN. |
| |
| Fixes: c14ac9451c34 ("sock: enable timestamping using control messages") |
| Signed-off-by: Alexander Potapenko <glider@google.com> |
| Acked-by: Soheil Hassas Yeganeh <soheil@google.com> |
| Signed-off-by: David S. Miller <davem@davemloft.net> |
| Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com> |
| |
| diff --git a/net/ipv6/udp.c b/net/ipv6/udp.c |
| index fa39ab8ec1fc..f10f5dbb35c9 100644 |
| --- a/net/ipv6/udp.c |
| +++ b/net/ipv6/udp.c |
| @@ -1037,6 +1037,7 @@ int udpv6_sendmsg(struct sock *sk, struct msghdr *msg, size_t len) |
| ipc6.hlimit = -1; |
| ipc6.tclass = -1; |
| ipc6.dontfrag = -1; |
| + sockc.tsflags = sk->sk_tsflags; |
| |
| /* destination address check */ |
| if (sin6) { |
| @@ -1156,7 +1157,6 @@ do_udp_sendmsg: |
| fl6.flowi6_oif = np->sticky_pktinfo.ipi6_ifindex; |
| |
| fl6.flowi6_mark = sk->sk_mark; |
| - sockc.tsflags = sk->sk_tsflags; |
| |
| if (msg->msg_controllen) { |
| opt = &opt_space; |
| -- |
| 2.12.0 |
| |