drivers/net/cxgb3/cxgb3_main.c: prevent reading uninitialized stack memory
Subsystems (2)
PATCH v2 1/1 drivers/net/cxgb3/cxgb3_main.c: prevent reading uninitialized stack memory
Fixed formatting (tabs and line breaks).
The CHELSIO_GET_QSET_NUM device ioctl allows unprivileged users to read 4 bytes of uninitialized stack memory, because the "addr" member of the ch_reg struct declared on the stack in cxgb_extension_ioctl() is not altered or zeroed before being copied back to the user. This patch takes care of it.
drivers/net/cxgb3/cxgb3_main.c +2 -0
@@ -2296,6 +2296,8 @@ static int cxgb_extension_ioctl(struct ncase CHELSIO_GET_QSET_NUM :{struct ch_reg edata; +memset (&edata,0 ,sizeof (struct ch_reg )); + edata.cmd =CHELSIO_GET_QSET_NUM ; edata.val = pi->nqsets;if (copy_to_user (useraddr, &edata,sizeof (edata)))
Quoted 13 lines · Dan Rosenberg
Fixed formatting (tabs and line breaks).
The
CHELSIO_GET_QSET_NUMdevice ioctl allows unprivileged users to read 4 bytes of uninitialized stack memory, because the "addr" member of thech_regstruct declared on the stack incxgb_extension_ioctl()is not altered or zeroed before being copied back to the user. This patch takes care of it.Signed-off-by Dan Rosenberg <[email protected]>
drivers/net/cxgb3/cxgb3_main.c static int cxgb_extension_ioctl(struct n · line 2302
Quoted 7 lines
drivers/net/cxgb3/cxgb3_main.c +2
-0@@ -2296,6 +2296,8 @@ static int cxgb_extension_ioctl(struct ncase CHELSIO_GET_QSET_NUM :{struct ch_reg edata; +memset (&edata,0 ,sizeof (struct ch_reg )); + edata.cmd =CHELSIO_GET_QSET_NUM ; edata.val = pi->nqsets;
This is a pretty expensive way to fix it. either...
+ edata.addr = 0;
or:
- struct ch_reg edata;
+ struct ch_reg edata = {
+ .cmd = CHELSIO_GET_QSET_NUM,
+ .val = pi->nqsets
+ };
- edata.cmd = CHELSIO_GET_QSET_NUM;
- edata.val = pi->nqsets;
If you are worried that the struct ch_reg may grow someday.
-- Steve
Quoted 3 lines
drivers/net/cxgb3/cxgb3_main.c +0
-0if (copy_to_user (useraddr, &edata,sizeof (edata)))
From: Dan Rosenberg <[email protected]>
Date: Wed, 15 Sep 2010 17:43:12 -0400
Quoted 9 lines
Fixed formatting (tabs and line breaks).
The
CHELSIO_GET_QSET_NUMdevice ioctl allows unprivileged users to read 4 bytes of uninitialized stack memory, because the "addr" member of thech_regstruct declared on the stack incxgb_extension_ioctl()is not altered or zeroed before being copied back to the user. This patch takes care of it.Signed-off-by Dan Rosenberg <[email protected]>
Applied.