inet: prevent leakage of uninitialized memory to user in recv syscalls
authorHannes Frederic Sowa <hannes@stressinduktion.org>
Mon, 18 Nov 2013 03:20:45 +0000 (04:20 +0100)
committerWilly Tarreau <w@1wt.eu>
Mon, 19 May 2014 05:53:59 +0000 (07:53 +0200)
commitf8e4f8fc477a233429d60e7ed4acdc5e09337af9
tree4d923f70d71af91803333e56f060d8dbb5cb8f1b
parentc091517bfcde5e59ef4f8f1355761dbe2b04c6ff
inet: prevent leakage of uninitialized memory to user in recv syscalls

[ Upstream commit bceaa90240b6019ed73b49965eac7d167610be69 ]

Only update *addr_len when we actually fill in sockaddr, otherwise we
can return uninitialized memory from the stack to the caller in the
recvfrom, recvmmsg and recvmsg syscalls. Drop the the (addr_len == NULL)
checks because we only get called with a valid addr_len pointer either
from sock_common_recvmsg or inet_recvmsg.

If a blocking read waits on a socket which is concurrently shut down we
now return zero and set msg_msgnamelen to 0.

Reported-by: mpb <mpb.mail@gmail.com>
Suggested-by: Eric Dumazet <eric.dumazet@gmail.com>
Signed-off-by: Hannes Frederic Sowa <hannes@stressinduktion.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
[wt: no ieee802154, ping nor l2tp in 2.6.32]
Signed-off-by: Willy Tarreau <w@1wt.eu>
net/ipv4/raw.c
net/ipv4/udp.c
net/ipv6/raw.c
net/ipv6/udp.c
net/phonet/datagram.c