diff --git a/block/blk-map.c b/block/blk-map.c index b5fd1d8574615e..8e0b67875a0c85 100644 --- a/block/blk-map.c +++ b/block/blk-map.c @@ -460,6 +460,17 @@ static void bio_copy_kern_endio_read(struct bio *bio) bio_copy_kern_endio(bio); } +static bool blk_kern_needs_copy(void *kbuf, unsigned int len) +{ +#ifdef CONFIG_LKL + char *buf = kbuf; + + return !virt_addr_valid(buf) || !virt_addr_valid(buf + len - 1); +#else + return false; +#endif +} + /** * bio_copy_kern - copy kernel address into bio * @q: the struct request_queue for the bio @@ -772,7 +783,7 @@ int blk_rq_map_kern(struct request_queue *q, struct request *rq, void *kbuf, return -EINVAL; if (!blk_rq_aligned(q, addr, len) || object_is_on_stack(kbuf) || - blk_queue_may_bounce(q)) + blk_kern_needs_copy(kbuf, len) || blk_queue_may_bounce(q)) bio = bio_copy_kern(q, kbuf, len, gfp_mask, reading); else bio = bio_map_kern(q, kbuf, len, gfp_mask);