diff options
author | Jan Kara <jack@suse.com> | 2015-11-04 17:13:39 +0100 |
---|---|---|
committer | Jens Axboe <axboe@fb.com> | 2015-11-11 09:36:56 -0700 |
commit | 2dbe5495763612f7c1b68fc897cd28c9e22079b8 (patch) | |
tree | 7b53e4691b04a65e508c3dd4ea4e3cff1d53a301 | |
parent | c5a37883f42be712a989e54d5d6c0159b0e56599 (diff) | |
download | lwn-2dbe5495763612f7c1b68fc897cd28c9e22079b8.tar.gz lwn-2dbe5495763612f7c1b68fc897cd28c9e22079b8.zip |
brd: Refuse improperly aligned discard requests
Currently when improperly aligned discard request is submitted, we just
silently discard more / less data which results in filesystem corruption
in some cases. Refuse such misaligned requests.
Signed-off-by: Jan Kara <jack@suse.com>
Signed-off-by: Jens Axboe <axboe@fb.com>
-rw-r--r-- | drivers/block/brd.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/drivers/block/brd.c b/drivers/block/brd.c index c9f9c30d6467..a5880f4ab40e 100644 --- a/drivers/block/brd.c +++ b/drivers/block/brd.c @@ -337,6 +337,9 @@ static blk_qc_t brd_make_request(struct request_queue *q, struct bio *bio) goto io_error; if (unlikely(bio->bi_rw & REQ_DISCARD)) { + if (sector & ((PAGE_SIZE >> SECTOR_SHIFT) - 1) || + bio->bi_iter.bi_size & PAGE_MASK) + goto io_error; discard_from_brd(brd, sector, bio->bi_iter.bi_size); goto out; } |