diff options
author | Luciano Coelho <coelho@ti.com> | 2011-04-01 16:42:02 (GMT) |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2011-04-04 19:22:12 (GMT) |
commit | 09b661b33268698d3b453dceb78cda129ad899b4 (patch) | |
tree | e5e1760d61f665bfb3216ef6de7c3a9c6b26d80c | |
parent | 023535732f4db01af4921f20f058bc4561d9add7 (diff) | |
download | linux-fsl-qoriq-09b661b33268698d3b453dceb78cda129ad899b4.tar.xz |
wl12xx: fix potential buffer overflow in testmode nvs push
We were allocating the size of the NVS file struct and not checking
whether the length of the buffer passed was correct before copying it
into the allocated memory. This is a security hole because buffer
overflows can occur if the userspace passes a bigger file than what is
expected.
With this patch, we check if the size of the data passed from
userspace matches the size required.
This bug was introduced in 2.6.36.
Cc: stable@kernel.org
Reported-by: Ido Yariv <ido@wizery.com>
Signed-off-by: Luciano Coelho <coelho@ti.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
-rw-r--r-- | drivers/net/wireless/wl12xx/testmode.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/drivers/net/wireless/wl12xx/testmode.c b/drivers/net/wireless/wl12xx/testmode.c index e64403b..6ec06a4 100644 --- a/drivers/net/wireless/wl12xx/testmode.c +++ b/drivers/net/wireless/wl12xx/testmode.c @@ -204,7 +204,10 @@ static int wl1271_tm_cmd_nvs_push(struct wl1271 *wl, struct nlattr *tb[]) kfree(wl->nvs); - wl->nvs = kzalloc(sizeof(struct wl1271_nvs_file), GFP_KERNEL); + if (len != sizeof(struct wl1271_nvs_file)) + return -EINVAL; + + wl->nvs = kzalloc(len, GFP_KERNEL); if (!wl->nvs) { wl1271_error("could not allocate memory for the nvs file"); ret = -ENOMEM; |