This is a note to let you know that I've just added the patch titled block: do not leak memory in bio_copy_user_iov() to the 3.18-stable tree which can be found at: http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary The filename of the patch is: block-do-not-leak-memory-in-bio_copy_user_iov.patch and it can be found in the queue-3.18 subdirectory. If you, or anyone else, feels it should not be added to the stable tree, please let <stable@xxxxxxxxxxxxxxx> know about it. >From a3761c3c91209b58b6f33bf69dd8bb8ec0c9d925 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Glisse?= <jglisse@xxxxxxxxxx> Date: Wed, 10 Apr 2019 16:27:51 -0400 Subject: block: do not leak memory in bio_copy_user_iov() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From: Jérôme Glisse <jglisse@xxxxxxxxxx> commit a3761c3c91209b58b6f33bf69dd8bb8ec0c9d925 upstream. When bio_add_pc_page() fails in bio_copy_user_iov() we should free the page we just allocated otherwise we are leaking it. Cc: linux-block@xxxxxxxxxxxxxxx Cc: Linus Torvalds <torvalds@xxxxxxxxxxxxxxxxxxxx> Cc: stable@xxxxxxxxxxxxxxx Reviewed-by: Chaitanya Kulkarni <chaitanya.kulkarni@xxxxxxx> Signed-off-by: Jérôme Glisse <jglisse@xxxxxxxxxx> Signed-off-by: Jens Axboe <axboe@xxxxxxxxx> Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx> --- block/bio.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) --- a/block/bio.c +++ b/block/bio.c @@ -1217,8 +1217,11 @@ struct bio *bio_copy_user_iov(struct req } } - if (bio_add_pc_page(q, bio, page, bytes, offset) < bytes) + if (bio_add_pc_page(q, bio, page, bytes, offset) < bytes) { + if (!map_data) + __free_page(page); break; + } len -= bytes; offset = 0; Patches currently in stable-queue which might be from jglisse@xxxxxxxxxx are queue-3.18/block-do-not-leak-memory-in-bio_copy_user_iov.patch