From 72e471e7dd9c01d68ad554f24cf8e6b56a3a594f Mon Sep 17 00:00:00 2001 From: Bartlomiej Zolnierkiewicz Date: Thu, 24 Apr 2003 08:42:51 -0700 Subject: [PATCH] [PATCH] fix mismatched access_ok() checks in sg_io() I found this while doing bio_map_user() changes. Acked by Jens. --- drivers/block/scsi_ioctl.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/block/scsi_ioctl.c b/drivers/block/scsi_ioctl.c index 0e4fd3232c4c0..78bbe1d6e1bcb 100644 --- a/drivers/block/scsi_ioctl.c +++ b/drivers/block/scsi_ioctl.c @@ -183,9 +183,11 @@ static int sg_io(request_queue_t *q, struct block_device *bdev, } uaddr = (unsigned long) hdr.dxferp; - if (writing && !access_ok(VERIFY_WRITE, uaddr, bytes)) + /* writing to device -> reading from vm */ + if (writing && !access_ok(VERIFY_READ, uaddr, bytes)) return -EFAULT; - else if (reading && !access_ok(VERIFY_READ, uaddr, bytes)) + /* reading from device -> writing to vm */ + else if (reading && !access_ok(VERIFY_WRITE, uaddr, bytes)) return -EFAULT; /* -- 2.53.0