Skip to content

Commit 2145e15

Browse files
megabugtorvalds
authored andcommitted
floppy: don't write kernel-only members to FDRAWCMD ioctl output
Do not leak kernel-only floppy_raw_cmd structure members to userspace. This includes the linked-list pointer and the pointer to the allocated DMA space. Signed-off-by: Matthew Daley <mattd@bugfuzz.com> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent ef87dbe commit 2145e15

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

Diff for: drivers/block/floppy.c

+4-1
Original file line numberDiff line numberDiff line change
@@ -3067,7 +3067,10 @@ static int raw_cmd_copyout(int cmd, void __user *param,
30673067
int ret;
30683068

30693069
while (ptr) {
3070-
ret = copy_to_user(param, ptr, sizeof(*ptr));
3070+
struct floppy_raw_cmd cmd = *ptr;
3071+
cmd.next = NULL;
3072+
cmd.kernel_data = NULL;
3073+
ret = copy_to_user(param, &cmd, sizeof(cmd));
30713074
if (ret)
30723075
return -EFAULT;
30733076
param += sizeof(struct floppy_raw_cmd);

0 commit comments

Comments
 (0)