diff options
author | Helge Deller <deller@gmx.de> | 2010-08-02 16:46:41 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2010-08-03 12:11:42 -0400 |
commit | 4b4fd27c0b5ec638a1f06ced9226fd95229dbbf0 (patch) | |
tree | 8fbdbf091b7378e03b9bfb80a12f791d942ba86c | |
parent | 9fe6206f400646a2322096b56c59891d530e8d51 (diff) |
PARISC: led.c - fix potential stack overflow in led_proc_write()
avoid potential stack overflow by correctly checking count parameter
Reported-by: Ilja <ilja@netric.org>
Signed-off-by: Helge Deller <deller@gmx.de>
Acked-by: Kyle McMartin <kyle@mcmartin.ca>
Cc: James E.J. Bottomley <jejb@parisc-linux.org>
Cc: stable@kernel.org
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r-- | drivers/parisc/led.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/drivers/parisc/led.c b/drivers/parisc/led.c index 188bc8496a26..d02be78a4138 100644 --- a/drivers/parisc/led.c +++ b/drivers/parisc/led.c | |||
@@ -176,16 +176,18 @@ static ssize_t led_proc_write(struct file *file, const char *buf, | |||
176 | size_t count, loff_t *pos) | 176 | size_t count, loff_t *pos) |
177 | { | 177 | { |
178 | void *data = PDE(file->f_path.dentry->d_inode)->data; | 178 | void *data = PDE(file->f_path.dentry->d_inode)->data; |
179 | char *cur, lbuf[count + 1]; | 179 | char *cur, lbuf[32]; |
180 | int d; | 180 | int d; |
181 | 181 | ||
182 | if (!capable(CAP_SYS_ADMIN)) | 182 | if (!capable(CAP_SYS_ADMIN)) |
183 | return -EACCES; | 183 | return -EACCES; |
184 | 184 | ||
185 | memset(lbuf, 0, count + 1); | 185 | if (count >= sizeof(lbuf)) |
186 | count = sizeof(lbuf)-1; | ||
186 | 187 | ||
187 | if (copy_from_user(lbuf, buf, count)) | 188 | if (copy_from_user(lbuf, buf, count)) |
188 | return -EFAULT; | 189 | return -EFAULT; |
190 | lbuf[count] = 0; | ||
189 | 191 | ||
190 | cur = lbuf; | 192 | cur = lbuf; |
191 | 193 | ||