public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 2.6.28] bluetooth: fix leak of uninitialized data to userspace
@ 2008-10-05 15:38 Vegard Nossum
  2008-10-05 16:24 ` Marcel Holtmann
  0 siblings, 1 reply; 2+ messages in thread
From: Vegard Nossum @ 2008-10-05 15:38 UTC (permalink / raw)
  To: Marcel Holtmann; +Cc: Ingo Molnar, Pekka Enberg, linux-kernel

>From 45be27894a18f87b71b855fcc4afd50f860254b4 Mon Sep 17 00:00:00 2001
From: Vegard Nossum <vegard.nossum@gmail.com>
Date: Sun, 5 Oct 2008 17:25:45 +0200
Subject: [PATCH] bluetooth: fix leak of uninitialized data to userspace

    struct hci_dev_list_req {
            __u16  dev_num;
            struct hci_dev_req dev_req[0];  /* hci_dev_req structures */
    };

sizeof(struct hci_dev_list_req) == 4, so the two bytes immediately
following "dev_num" will never be initialized. When this structure
is copied to userspace, these uninitialized bytes are leaked.

Fix by using kzalloc() instead of kmalloc(). Found using kmemcheck.

Signed-off-by: Vegard Nossum <vegard.nossum@gmail.com>
---
 net/bluetooth/hci_core.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
index 278a3ac..7bb0f1c 100644
--- a/net/bluetooth/hci_core.c
+++ b/net/bluetooth/hci_core.c
@@ -756,7 +756,7 @@ int hci_get_dev_list(void __user *arg)
 
 	size = sizeof(*dl) + dev_num * sizeof(*dr);
 
-	if (!(dl = kmalloc(size, GFP_KERNEL)))
+	if (!(dl = kzalloc(size, GFP_KERNEL)))
 		return -ENOMEM;
 
 	dr = dl->dev_req;
-- 
1.5.5.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH 2.6.28] bluetooth: fix leak of uninitialized data to userspace
  2008-10-05 15:38 [PATCH 2.6.28] bluetooth: fix leak of uninitialized data to userspace Vegard Nossum
@ 2008-10-05 16:24 ` Marcel Holtmann
  0 siblings, 0 replies; 2+ messages in thread
From: Marcel Holtmann @ 2008-10-05 16:24 UTC (permalink / raw)
  To: Vegard Nossum; +Cc: Ingo Molnar, Pekka Enberg, linux-kernel

Hi Vegard,

> From 45be27894a18f87b71b855fcc4afd50f860254b4 Mon Sep 17 00:00:00 2001
> From: Vegard Nossum <vegard.nossum@gmail.com>
> Date: Sun, 5 Oct 2008 17:25:45 +0200
> Subject: [PATCH] bluetooth: fix leak of uninitialized data to userspace
> 
>     struct hci_dev_list_req {
>             __u16  dev_num;
>             struct hci_dev_req dev_req[0];  /* hci_dev_req structures */
>     };
> 
> sizeof(struct hci_dev_list_req) == 4, so the two bytes immediately
> following "dev_num" will never be initialized. When this structure
> is copied to userspace, these uninitialized bytes are leaked.
> 
> Fix by using kzalloc() instead of kmalloc(). Found using kmemcheck.

good catch. I thought we moved everything over to kzalloc, but as it
seems we forgot at least one. Applied your patch to me tree. Thanks.

Regards

Marcel



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2008-10-05 16:32 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-10-05 15:38 [PATCH 2.6.28] bluetooth: fix leak of uninitialized data to userspace Vegard Nossum
2008-10-05 16:24 ` Marcel Holtmann

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox