aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric W. Biederman <ebiederm@xmission.com>2017-11-15 22:17:48 -0600
committerMoyster <oysterized@gmail.com>2019-05-02 16:59:52 +0200
commit154dfe76fe2697d105b8ce13964de26f5b993551 (patch)
tree31d0fb9523432f4c6a8d6ec8251f0f90112b4fd4
parent73b6968927a070042578b9a2803527739533f844 (diff)
net/sctp: Always set scope_id in sctp_inet6_skb_msgname
commit 7c8a61d9ee1df0fb4747879fa67a99614eb62fec upstream. Alexandar Potapenko while testing the kernel with KMSAN and syzkaller discovered that in some configurations sctp would leak 4 bytes of kernel stack. Working with his reproducer I discovered that those 4 bytes that are leaked is the scope id of an ipv6 address returned by recvmsg. With a little code inspection and a shrewd guess I discovered that sctp_inet6_skb_msgname only initializes the scope_id field for link local ipv6 addresses to the interface index the link local address pertains to instead of initializing the scope_id field for all ipv6 addresses. That is almost reasonable as scope_id's are meaniningful only for link local addresses. Set the scope_id in all other cases to 0 which is not a valid interface index to make it clear there is nothing useful in the scope_id field. There should be no danger of breaking userspace as the stack leak guaranteed that previously meaningless random data was being returned. Fixes: 372f525b495c ("SCTP: Resync with LKSCTP tree.") Change-Id: I24fe3eb3a92fb0435dc162ef62ed3a5b44b612c3 History-tree: https://git.kernel.org/pub/scm/linux/kernel/git/tglx/history.git Reported-by: Alexander Potapenko <glider@google.com> Tested-by: Alexander Potapenko <glider@google.com> Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com> Signed-off-by: David S. Miller <davem@davemloft.net> [bwh: Backported to 3.16: - Adjust context - Add braces] Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
-rw-r--r--net/sctp/ipv6.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/net/sctp/ipv6.c b/net/sctp/ipv6.c
index 206a755dc..9c22a633b 100644
--- a/net/sctp/ipv6.c
+++ b/net/sctp/ipv6.c
@@ -794,6 +794,8 @@ static void sctp_inet6_skb_msgname(struct sk_buff *skb, char *msgname,
if (ipv6_addr_type(&sin6->sin6_addr) & IPV6_ADDR_LINKLOCAL) {
struct sctp_ulpevent *ev = sctp_skb2event(skb);
sin6->sin6_scope_id = ev->iif;
+ } else {
+ sin6->sin6_scope_id = 0;
}
}
}