From: Matthew Daley Date: Mon, 28 Apr 2014 07:05:21 +0000 (+1200) Subject: floppy: don't write kernel-only members to FDRAWCMD ioctl output X-Git-Tag: firefly_0821_release~3679^2~2383 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=50c648e394a0968f19d448b70bec82da88219963;p=firefly-linux-kernel-4.4.55.git floppy: don't write kernel-only members to FDRAWCMD ioctl output commit 2145e15e0557a01b9195d1c7199a1b92cb9be81f upstream. 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 Signed-off-by: Linus Torvalds Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/block/floppy.c b/drivers/block/floppy.c index 1a8ab67d1651..eb3575b3fbf0 100644 --- a/drivers/block/floppy.c +++ b/drivers/block/floppy.c @@ -3053,7 +3053,10 @@ static int raw_cmd_copyout(int cmd, void __user *param, int ret; while (ptr) { - ret = copy_to_user(param, ptr, sizeof(*ptr)); + struct floppy_raw_cmd cmd = *ptr; + cmd.next = NULL; + cmd.kernel_data = NULL; + ret = copy_to_user(param, &cmd, sizeof(cmd)); if (ret) return -EFAULT; param += sizeof(struct floppy_raw_cmd);