Bluetooth: fix possible info leak in bt_sock_recvmsg()
authorMathias Krause <minipli@googlemail.com>
Sun, 7 Apr 2013 01:51:49 +0000 (01:51 +0000)
committerBen Hutchings <ben@decadent.org.uk>
Mon, 13 May 2013 14:02:39 +0000 (15:02 +0100)
commit95ee0fb7a014cdf80be37b329fa462ff3847f7c0
tree4f2c81a531c60ab722f60dbda19a9f93ee7299b7
parente72f86d5b6602c86efb08443c58086c40228b81b
Bluetooth: fix possible info leak in bt_sock_recvmsg()

[ Upstream commit 4683f42fde3977bdb4e8a09622788cc8b5313778 ]

In case the socket is already shutting down, bt_sock_recvmsg() returns
with 0 without updating msg_namelen leading to net/socket.c leaking the
local, uninitialized sockaddr_storage variable to userland -- 128 bytes
of kernel stack memory.

Fix this by moving the msg_namelen assignment in front of the shutdown
test.

Cc: Marcel Holtmann <marcel@holtmann.org>
Cc: Gustavo Padovan <gustavo@padovan.org>
Cc: Johan Hedberg <johan.hedberg@gmail.com>
Signed-off-by: Mathias Krause <minipli@googlemail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
net/bluetooth/af_bluetooth.c