linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] floppy: Do not copy a kernel pointer to user memory in FDGETPRM ioctl
@ 2018-03-08  0:02 Brian Belleville
  2018-03-22 19:59 ` Brian Belleville
  2018-05-29 13:27 ` Andy Whitcroft
  0 siblings, 2 replies; 7+ messages in thread
From: Brian Belleville @ 2018-03-08  0:02 UTC (permalink / raw)
  To: Jiri Kosina, linux-kernel; +Cc: Brian Belleville

The final field of a floppy_struct is the field "name", which is a
pointer to a string in kernel memory. The kernel pointer should not be
copied to user memory. The FDGETPRM ioctl copies a floppy_struct to
user memory, including the "name" field. This pointer cannot be used
by the user, and it will leak a kernel address to user-space, which
will reveal the location of kernel code and data and undermine KASLR
protection. Instead, copy the floppy_struct except for the "name"
field.

Signed-off-by: Brian Belleville <bbellevi@uci.edu>
---
 drivers/block/floppy.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/block/floppy.c b/drivers/block/floppy.c
index eae484a..4d4a422 100644
--- a/drivers/block/floppy.c
+++ b/drivers/block/floppy.c
@@ -3470,6 +3470,7 @@ static int fd_locked_ioctl(struct block_device *bdev, fmode_t mode, unsigned int
 					  (struct floppy_struct **)&outparam);
 		if (ret)
 			return ret;
+		size = offsetof(struct floppy_struct, name);
 		break;
 	case FDMSGON:
 		UDP->flags |= FTD_MSG;
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2018-09-20 15:10 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-03-08  0:02 [PATCH] floppy: Do not copy a kernel pointer to user memory in FDGETPRM ioctl Brian Belleville
2018-03-22 19:59 ` Brian Belleville
2018-05-29 13:27 ` Andy Whitcroft
2018-07-09 23:14   ` Ben Hutchings
2018-08-27  7:45   ` Kees Cook
2018-09-20 14:01     ` Joe Lawrence
2018-09-20 15:10       ` Jens Axboe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).