Skip to content

Commit 91e463c

Browse files
fujitaJens Axboe
authored andcommitted
block: fix SG_IO to return a proper error value
blk_rq_unmap_user() returns -EFAULT if a program passes an invalid address to kernel. SG_IO path needs to pass the returned value to user space instead of ignoring it. Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
1 parent d6ceb25 commit 91e463c

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

‎block/scsi_ioctl.c‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ static int blk_fill_sghdr_rq(struct request_queue *q, struct request *rq,
217217
static int blk_complete_sghdr_rq(struct request *rq, struct sg_io_hdr *hdr,
218218
struct bio *bio)
219219
{
220-
int ret = 0;
220+
int r, ret = 0;
221221

222222
/*
223223
* fill in all the output members
@@ -242,7 +242,9 @@ static int blk_complete_sghdr_rq(struct request *rq, struct sg_io_hdr *hdr,
242242
ret = -EFAULT;
243243
}
244244

245-
blk_rq_unmap_user(bio);
245+
r = blk_rq_unmap_user(bio);
246+
if (!ret)
247+
ret = r;
246248
blk_put_request(rq);
247249

248250
return ret;

0 commit comments

Comments
 (0)