From: michaelc@cs.wisc.edu
To: linux-scsi@vger.kernel.org, jens.axboe@oracle.com, dougg@torque.net
Cc: Mike Christie <michaelc@cs.wisc.edu>
Subject: [PATCH 7/7] mv user buffer copy access_ok test to block helper
Date: Sun, 04 Mar 2007 12:31:24 -0600 [thread overview]
Message-ID: <11730330902393-git-send-email-michaelc@cs.wisc.edu> (raw)
In-Reply-To: <11730330893660-git-send-email-michaelc@cs.wisc.edu>
From: Mike Christie <michaelc@cs.wisc.edu>
sg.c does a access_ok test on the user buffer when doing
indirect IO. bsg and scsi_ioctl.c did not, but it seems
like it would be ok to be common. This patch moves that
test to the block layer helpers.
Signed-off-by: Mike Christie <michaelc@cs.wisc.edu>
---
block/ll_rw_blk.c | 8 +++++++-
1 files changed, 7 insertions(+), 1 deletions(-)
diff --git a/block/ll_rw_blk.c b/block/ll_rw_blk.c
index 35b66ed..4327e23 100644
--- a/block/ll_rw_blk.c
+++ b/block/ll_rw_blk.c
@@ -2527,6 +2527,7 @@ static int copy_user_iov(struct bio *hea
{
unsigned int iov_len = 0;
int ret, i = 0, iov_index = 0;
+ int read = bio_data_dir(head) == READ;
struct bio *bio;
struct bio_vec *bvec;
char __user *p = NULL;
@@ -2560,10 +2561,15 @@ continue_from_bvec:
*/
goto continue_from_bvec;
}
+
+ if (!access_ok(read ?
+ VERIFY_WRITE : VERIFY_READ,
+ p, iov_len))
+ return -EFAULT;
}
copy_bytes = min(iov_len, bvec->bv_len - bvec_offset);
- if (bio_data_dir(head) == READ)
+ if (read)
ret = copy_to_user(p, addr, copy_bytes);
else
ret = copy_from_user(addr, p, copy_bytes);
--
1.4.1.1
next prev parent reply other threads:[~2007-03-04 18:31 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-03-04 18:31 convert sg to block layer helpers - v5 michaelc
2007-03-04 18:31 ` [PATCH 1/7] rm bio hacks in scsi tgt michaelc
2007-03-04 18:31 ` [PATCH 2/7] rm block device arg from bio map user michaelc
2007-03-04 18:31 ` [PATCH 3/7] Support large sg io segments michaelc
2007-03-04 18:31 ` [PATCH 4/7] Add reserve buffer for sg io michaelc
2007-03-04 18:31 ` [PATCH 5/7] Add sg io mmap helper michaelc
2007-03-04 18:31 ` [PATCH 6/7] Convert sg to block layer helpers michaelc
2007-03-04 18:31 ` michaelc [this message]
2007-03-04 22:56 ` [PATCH 7/7] mv user buffer copy access_ok test to block helper Mike Christie
2007-03-04 19:32 ` convert sg to block layer helpers - v5 Douglas Gilbert
2007-03-04 19:56 ` Mike Christie
2007-03-04 20:17 ` Douglas Gilbert
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=11730330902393-git-send-email-michaelc@cs.wisc.edu \
--to=michaelc@cs.wisc.edu \
--cc=dougg@torque.net \
--cc=jens.axboe@oracle.com \
--cc=linux-scsi@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.