8addbb8
From e11e0455c0d7d3d62276a0c55d9dfbc16779d691 Mon Sep 17 00:00:00 2001
8addbb8
From: Mathias Krause <minipli@googlemail.com>
8addbb8
Date: Sun, 7 Apr 2013 01:51:50 +0000
8addbb8
Subject: [PATCH] Bluetooth: RFCOMM - Fix missing msg_namelen update in
8addbb8
 rfcomm_sock_recvmsg()
8addbb8
8addbb8
If RFCOMM_DEFER_SETUP is set in the flags, rfcomm_sock_recvmsg() returns
8addbb8
early with 0 without updating the possibly set msg_namelen member. This,
8addbb8
in turn, leads to a 128 byte kernel stack leak in net/socket.c.
8addbb8
8addbb8
Fix this by updating msg_namelen in this case. For all other cases it
8addbb8
will be handled in bt_sock_stream_recvmsg().
8addbb8
8addbb8
Cc: Marcel Holtmann <marcel@holtmann.org>
8addbb8
Cc: Gustavo Padovan <gustavo@padovan.org>
8addbb8
Cc: Johan Hedberg <johan.hedberg@gmail.com>
8addbb8
Signed-off-by: Mathias Krause <minipli@googlemail.com>
8addbb8
Signed-off-by: David S. Miller <davem@davemloft.net>
8addbb8
---
8addbb8
 net/bluetooth/rfcomm/sock.c | 1 +
8addbb8
 1 file changed, 1 insertion(+)
8addbb8
8addbb8
diff --git a/net/bluetooth/rfcomm/sock.c b/net/bluetooth/rfcomm/sock.c
8addbb8
index c23bae8..7c9224b 100644
8addbb8
--- a/net/bluetooth/rfcomm/sock.c
8addbb8
+++ b/net/bluetooth/rfcomm/sock.c
8addbb8
@@ -608,6 +608,7 @@ static int rfcomm_sock_recvmsg(struct kiocb *iocb, struct socket *sock,
8addbb8
 
8addbb8
 	if (test_and_clear_bit(RFCOMM_DEFER_SETUP, &d->flags)) {
8addbb8
 		rfcomm_dlc_accept(d);
8addbb8
+		msg->msg_namelen = 0;
8addbb8
 		return 0;
8addbb8
 	}
8addbb8
 
8addbb8
-- 
8addbb8
1.8.1.4
8addbb8