FAILED: patch "[PATCH] more bio_map_user_iov() leak fixes" failed to apply to 4.4-stable tree
Subsystems (2)
[email protected]
maintainerThe patch below does not apply to the 4.4-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
Quoted 1 line
From
2b04e8f6bbb196cab4b232af0f8d48ff2c7a8058Mon Sep 17 00:00:00 2001
From: Al Viro <[email protected]>
Date: Sat, 23 Sep 2017 15:51:23 -0400
Subject: [PATCH] more bio_map_user_iov() leak fixes
we need to take care of failure exit as well - pages already in bio should be dropped by analogue of bio_unmap_pages(), since their refcounts had been bumped only once per reference in bio.
Signed-off-by Al Viro <[email protected]>
block/bio.c +9 -5
@@ -1331,6 +1331,7 @@ struct bio *bio_map_user_iov(struct request_queue *q,int ret, offset;struct iov_iter i;struct iovec iov; +struct bio_vec *bvec;iov_for_each (iov, i, *iter) {unsigned long uaddr = (unsigned long ) iov.iov_base;
@@ -1375,7 +1376,12 @@ struct bio *bio_map_user_iov(struct request_queue *q, ret =get_user_pages_fast (uaddr, local_nr_pages, (iter->type &WRITE ) !=WRITE , &pages[cur_page]); -if (ret < local_nr_pages) { +if (unlikely (ret < local_nr_pages)) { +for (j = cur_page; j < page_limit; j++) { +if (!pages[j]) +break ; +put_page (pages[j]); + } ret = -EFAULT ; goto out_unmap; }
@@ -1431,10 +1437,8 @@ struct bio *bio_map_user_iov(struct request_queue *q,return bio; out_unmap: -for (j =0 ; j < nr_pages; j++) { -if (!pages[j]) -break ; -put_page (pages[j]); +bio_for_each_segment_all (bvec, bio, j) { +put_page (bvec->bv_page); } out:kfree (pages);