]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
io_uring/zcrx: don't leak pages on account failure
authorPavel Begunkov <asml.silence@gmail.com>
Mon, 21 Jul 2025 09:56:21 +0000 (10:56 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 20 Aug 2025 16:41:44 +0000 (18:41 +0200)
commit 6bbd3411ff87df1ca38ff32d36eb5dc673ca8021 upstream.

Someone needs to release pinned pages in io_import_umem() if accounting
fails. Assign them to the area but return an error, the following
io_zcrx_free_area() will clean them up.

Fixes: 262ab205180d2 ("io_uring/zcrx: account area memory")
Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
Link: https://lore.kernel.org/r/e19f283a912f200c0d427e376cb789fc3f3d69bc.1753091564.git.asml.silence@gmail.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
io_uring/zcrx.c

index 5204b5102c2c3bf0ad5702f8c7926f06bdec963e..56b490b27064cc6689ec32b6542035520a826f2c 100644 (file)
@@ -187,15 +187,13 @@ static int io_import_umem(struct io_zcrx_ifq *ifq,
 
        mem->account_pages = io_count_account_pages(pages, nr_pages);
        ret = io_account_mem(ifq->ctx, mem->account_pages);
-       if (ret < 0) {
+       if (ret < 0)
                mem->account_pages = 0;
-               return ret;
-       }
 
        mem->pages = pages;
        mem->nr_folios = nr_pages;
        mem->size = area_reg->len;
-       return 0;
+       return ret;
 }
 
 static void io_release_area_mem(struct io_zcrx_mem *mem)