Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d80caeb9 authored by Alexander Potapenko's avatar Alexander Potapenko Committed by Greg Kroah-Hartman
Browse files

ipv6: make sure to initialize sockc.tsflags before first use



[ Upstream commit d515684d78148884d5fc425ba904c50f03844020 ]

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: c14ac945 ("sock: enable timestamping using control messages")
Signed-off-by: default avatarAlexander Potapenko <glider@google.com>
Acked-by: default avatarSoheil Hassas Yeganeh <soheil@google.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent c87ef873
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -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 @@ int udpv6_sendmsg(struct sock *sk, struct msghdr *msg, size_t len)
		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;