]>
Commit | Line | Data |
---|---|---|
eeff790c GKH |
1 | From 2145e15e0557a01b9195d1c7199a1b92cb9be81f Mon Sep 17 00:00:00 2001 |
2 | From: Matthew Daley <mattd@bugfuzz.com> | |
3 | Date: Mon, 28 Apr 2014 19:05:21 +1200 | |
4 | Subject: floppy: don't write kernel-only members to FDRAWCMD ioctl output | |
5 | ||
6 | From: Matthew Daley <mattd@bugfuzz.com> | |
7 | ||
8 | commit 2145e15e0557a01b9195d1c7199a1b92cb9be81f upstream. | |
9 | ||
10 | Do not leak kernel-only floppy_raw_cmd structure members to userspace. | |
11 | This includes the linked-list pointer and the pointer to the allocated | |
12 | DMA space. | |
13 | ||
14 | Signed-off-by: Matthew Daley <mattd@bugfuzz.com> | |
15 | Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> | |
16 | Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> | |
17 | ||
18 | --- | |
19 | drivers/block/floppy.c | 5 ++++- | |
20 | 1 file changed, 4 insertions(+), 1 deletion(-) | |
21 | ||
22 | --- a/drivers/block/floppy.c | |
23 | +++ b/drivers/block/floppy.c | |
24 | @@ -3053,7 +3053,10 @@ static int raw_cmd_copyout(int cmd, void | |
25 | int ret; | |
26 | ||
27 | while (ptr) { | |
28 | - ret = copy_to_user(param, ptr, sizeof(*ptr)); | |
29 | + struct floppy_raw_cmd cmd = *ptr; | |
30 | + cmd.next = NULL; | |
31 | + cmd.kernel_data = NULL; | |
32 | + ret = copy_to_user(param, &cmd, sizeof(cmd)); | |
33 | if (ret) | |
34 | return -EFAULT; | |
35 | param += sizeof(struct floppy_raw_cmd); |