mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-29 19:21:31 -04:00
inet: prevent leakage of uninitialized memory to user in recv syscalls
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 <[email protected]> Suggested-by: Eric Dumazet <[email protected]> Signed-off-by: Hannes Frederic Sowa <[email protected]> Signed-off-by: David S. Miller <[email protected]>
This commit is contained in:
parent
bcd081a3ae
commit
bceaa90240
8 changed files with 17 additions and 38 deletions
|
|
@ -139,9 +139,6 @@ static int pn_recvmsg(struct kiocb *iocb, struct sock *sk,
|
|||
MSG_CMSG_COMPAT))
|
||||
goto out_nofree;
|
||||
|
||||
if (addr_len)
|
||||
*addr_len = sizeof(sa);
|
||||
|
||||
skb = skb_recv_datagram(sk, flags, noblock, &rval);
|
||||
if (skb == NULL)
|
||||
goto out_nofree;
|
||||
|
|
@ -162,8 +159,10 @@ static int pn_recvmsg(struct kiocb *iocb, struct sock *sk,
|
|||
|
||||
rval = (flags & MSG_TRUNC) ? skb->len : copylen;
|
||||
|
||||
if (msg->msg_name != NULL)
|
||||
memcpy(msg->msg_name, &sa, sizeof(struct sockaddr_pn));
|
||||
if (msg->msg_name != NULL) {
|
||||
memcpy(msg->msg_name, &sa, sizeof(sa));
|
||||
*addr_len = sizeof(sa);
|
||||
}
|
||||
|
||||
out:
|
||||
skb_free_datagram(sk, skb);
|
||||
|
|
|
|||
Loading…
Reference in a new issue