From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D48FC3A3E75 for ; Tue, 17 Mar 2026 12:55:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773752114; cv=none; b=dq9QNU+ZRq0qqWDY5MnXdT9kGZJcxPrqoCtR1LvjSDLU3NW99DyFDh7P3uQtH5IXjvVHiAE3m75QXGFM0poXyDnUuiBpIzjZGi+gGhHoRkMkS5cLIury416AMa87uCJM7zZ/SjRVzgxu8MoxGAWohLuyHsJPJcE2Jo23KpyFPCg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773752114; c=relaxed/simple; bh=aJtwhJs/sY6YxZa5CiGXhk0vYbbCRKP3vzYO9AiQddw=; h=Subject:To:Cc:From:Date:Message-ID:MIME-Version:Content-Type; b=VlMq+1sRzBX0EdnBeICma9/ISu7GJ6QnjFhR+1lvAiBcjMd3b8sYVYMmlZYPsOD9GppUdAHJRvsFLXcayNuxO8LLZ+MOMGOLqZscA2Cnh9OuRZyO+dRHbGnJvsfsddOEQAq09cbX7lvar8tuqagrM6RGoK7qYpBPlC3kwrIhs7U= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=fgIcX8f1; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="fgIcX8f1" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 00A6DC4CEF7; Tue, 17 Mar 2026 12:55:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1773752114; bh=aJtwhJs/sY6YxZa5CiGXhk0vYbbCRKP3vzYO9AiQddw=; h=Subject:To:Cc:From:Date:From; b=fgIcX8f1FOpOp/Wc5oA2XBQqQNTnuzPmVlY8Zoh5Dh/oIKjlgqbIacQ/TyktA/JBT dBk6Ae+LB4Bf73tKdrY+5TygrQ21hwRCmmNh8GZ68rT+8YCsnqj3S59yxts9suD9eU bRSa07EGvDz9pNfJSkjNLO39nQFko4D81HPWQEnU= Subject: FAILED: patch "[PATCH] io_uring/kbuf: check if target buffer list is still legacy on" failed to apply to 6.6-stable tree To: axboe@kernel.dk,keenanat2000@gmail.com Cc: From: Date: Tue, 17 Mar 2026 13:55:01 +0100 Message-ID: <2026031701-humid-ultimate-853d@gregkh> Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=ANSI_X3.4-1968 Content-Transfer-Encoding: 8bit The patch below does not apply to the 6.6-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 . To reproduce the conflict and resubmit, you may use the following commands: git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-6.6.y git checkout FETCH_HEAD git cherry-pick -x c2c185be5c85d37215397c8e8781abf0a69bec1f # git commit -s git send-email --to '' --in-reply-to '2026031701-humid-ultimate-853d@gregkh' --subject-prefix 'PATCH 6.6.y' HEAD^.. Possible dependencies: thanks, greg k-h ------------------ original commit in Linus's tree ------------------ >From c2c185be5c85d37215397c8e8781abf0a69bec1f Mon Sep 17 00:00:00 2001 From: Jens Axboe Date: Thu, 12 Mar 2026 08:59:25 -0600 Subject: [PATCH] io_uring/kbuf: check if target buffer list is still legacy on recycle There's a gap between when the buffer was grabbed and when it potentially gets recycled, where if the list is empty, someone could've upgraded it to a ring provided type. This can happen if the request is forced via io-wq. The legacy recycling is missing checking if the buffer_list still exists, and if it's of the correct type. Add those checks. Cc: stable@vger.kernel.org Fixes: c7fb19428d67 ("io_uring: add support for ring mapped supplied buffers") Reported-by: Keenan Dong Signed-off-by: Jens Axboe diff --git a/io_uring/kbuf.c b/io_uring/kbuf.c index dae5b4ab3819..e7f444953dfb 100644 --- a/io_uring/kbuf.c +++ b/io_uring/kbuf.c @@ -111,9 +111,18 @@ bool io_kbuf_recycle_legacy(struct io_kiocb *req, unsigned issue_flags) buf = req->kbuf; bl = io_buffer_get_list(ctx, buf->bgid); - list_add(&buf->list, &bl->buf_list); - bl->nbufs++; + /* + * If the buffer list was upgraded to a ring-based one, or removed, + * while the request was in-flight in io-wq, drop it. + */ + if (bl && !(bl->flags & IOBL_BUF_RING)) { + list_add(&buf->list, &bl->buf_list); + bl->nbufs++; + } else { + kfree(buf); + } req->flags &= ~REQ_F_BUFFER_SELECTED; + req->kbuf = NULL; io_ring_submit_unlock(ctx, issue_flags); return true;