[feisty][PATCH] -Bluetooth-Fix-L2CAP-and-HCI-setsockopt-information-leaks (CVE-2007-1353)

Phillip lougher phillip at lougher.demon.co.uk
Tue Jun 5 13:08:39 UTC 2007


>From 0409c030ce6800ee4cb2bd70bbdfb50821d8a8c0 Mon Sep 17 00:00:00 2001
From: Marcel Holtmann <marcel at holtmann.org>
Date: Sat, 5 May 2007 00:35:59 +0200
Subject: [PATCH] [Bluetooth] Fix L2CAP and HCI setsockopt() information leaks (CVE-2007-1353)

The L2CAP and HCI setsockopt() implementations have a small information
leak that makes it possible to leak kernel stack memory to userspace.

If the optlen parameter is 0, no data will be copied by copy_from_user(),
but the uninitialized stack buffer will be read and stored later. A call
to getsockopt() can now retrieve the leaked information.

To fix this problem the stack buffer given to copy_from_user() must be
initialized with the current settings.

Signed-off-by: Marcel Holtmann <marcel at holtmann.org>
(cherry picked from commit 0878b6667f28772aa7d6b735abff53efc7bf6d91)
---
 net/bluetooth/hci_sock.c |    9 +++++++++
 net/bluetooth/l2cap.c    |    6 ++++++
 2 files changed, 15 insertions(+), 0 deletions(-)

diff --git a/net/bluetooth/hci_sock.c b/net/bluetooth/hci_sock.c
index dbf98c4..926ffac 100644
--- a/net/bluetooth/hci_sock.c
+++ b/net/bluetooth/hci_sock.c
@@ -500,6 +500,15 @@ static int hci_sock_setsockopt(struct socket *sock, int level, int optname, char
 		break;
 
 	case HCI_FILTER:
+		{
+			struct hci_filter *f = &hci_pi(sk)->filter;
+
+			uf.type_mask = f->type_mask;
+			uf.opcode    = f->opcode;
+			uf.event_mask[0] = *((u32 *) f->event_mask + 0);
+			uf.event_mask[1] = *((u32 *) f->event_mask + 1);
+		}
+
 		len = min_t(unsigned int, len, sizeof(uf));
 		if (copy_from_user(&uf, optval, len)) {
 			err = -EFAULT;
diff --git a/net/bluetooth/l2cap.c b/net/bluetooth/l2cap.c
index f8c25d5..ffaee66 100644
--- a/net/bluetooth/l2cap.c
+++ b/net/bluetooth/l2cap.c
@@ -954,11 +954,17 @@ static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname, ch
 
 	switch (optname) {
 	case L2CAP_OPTIONS:
+		opts.imtu     = l2cap_pi(sk)->imtu;
+		opts.omtu     = l2cap_pi(sk)->omtu;
+		opts.flush_to = l2cap_pi(sk)->flush_to;
+		opts.mode     = 0x00;
+
 		len = min_t(unsigned int, sizeof(opts), optlen);
 		if (copy_from_user((char *) &opts, optval, len)) {
 			err = -EFAULT;
 			break;
 		}
+
 		l2cap_pi(sk)->imtu  = opts.imtu;
 		l2cap_pi(sk)->omtu  = opts.omtu;
 		break;
-- 
1.4.4.2





More information about the kernel-team mailing list