This is a note to let you know that I've just added the patch titled io_uring: correct pinned_vm accounting to the 5.19-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: io_uring-correct-pinned_vm-accounting.patch and it can be found in the queue-5.19 subdirectory. If you, or anyone else, feels it should not be added to the stable tree, please let <stable@xxxxxxxxxxxxxxx> know about it. >From 42b6419d0aba47c5d8644cdc0b68502254671de5 Mon Sep 17 00:00:00 2001 From: Pavel Begunkov <asml.silence@xxxxxxxxx> Date: Tue, 4 Oct 2022 03:19:08 +0100 Subject: io_uring: correct pinned_vm accounting From: Pavel Begunkov <asml.silence@xxxxxxxxx> commit 42b6419d0aba47c5d8644cdc0b68502254671de5 upstream. ->mm_account should be released only after we free all registered buffers, otherwise __io_sqe_buffers_unregister() will see a NULL ->mm_account and skip locked_vm accounting. Cc: <Stable@xxxxxxxxxxxxxxx> Signed-off-by: Pavel Begunkov <asml.silence@xxxxxxxxx> Link: https://lore.kernel.org/r/6d798f65ed4ab8db3664c4d3397d4af16ca98846.1664849932.git.asml.silence@xxxxxxxxx Signed-off-by: Jens Axboe <axboe@xxxxxxxxx> Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx> --- io_uring/io_uring.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) --- a/io_uring/io_uring.c +++ b/io_uring/io_uring.c @@ -10727,12 +10727,6 @@ static void io_flush_apoll_cache(struct static __cold void io_ring_ctx_free(struct io_ring_ctx *ctx) { io_sq_thread_finish(ctx); - - if (ctx->mm_account) { - mmdrop(ctx->mm_account); - ctx->mm_account = NULL; - } - io_rsrc_refs_drop(ctx); /* __io_rsrc_put_work() may need uring_lock to progress, wait w/o it */ io_wait_rsrc_data(ctx->buf_data); @@ -10771,6 +10765,10 @@ static __cold void io_ring_ctx_free(stru #endif WARN_ON_ONCE(!list_empty(&ctx->ltimeout_list)); + if (ctx->mm_account) { + mmdrop(ctx->mm_account); + ctx->mm_account = NULL; + } io_mem_free(ctx->rings); io_mem_free(ctx->sq_sqes); Patches currently in stable-queue which might be from asml.silence@xxxxxxxxx are queue-5.19/io_uring-correct-pinned_vm-accounting.patch queue-5.19/io_uring-net-don-t-update-msg_name-if-not-provided.patch queue-5.19/io_uring-rw-fix-unexpected-link-breakage.patch queue-5.19/io_uring-net-fix-fast_iov-assignment-in-io_setup_async_msg.patch queue-5.19/io_uring-af_unix-defer-registered-files-gc-to-io_uring-release.patch