This is a note to let you know that I've just added the patch titled io_uring: Clean up a false-positive warning from GCC 9.3.0 to the 5.15-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-clean-up-a-false-positive-warning-from-gcc-9.3.0.patch and it can be found in the queue-5.15 subdirectory. If you, or anyone else, feels it should not be added to the stable tree, please let <stable@xxxxxxxxxxxxxxx> know about it. >From f79aabb5fcef594b03b9c7d790640833d95b0604 Mon Sep 17 00:00:00 2001 From: Alviro Iskandar Setiawan <alviro.iskandar@xxxxxxxxx> Date: Mon, 7 Feb 2022 21:05:33 +0700 Subject: io_uring: Clean up a false-positive warning from GCC 9.3.0 From: Alviro Iskandar Setiawan <alviro.iskandar@xxxxxxxxx> commit 0d7c1153d9291197c1dc473cfaade77acb874b4b upstream. In io_recv(), if import_single_range() fails, the @flags variable is uninitialized, then it will goto out_free. After the goto, the compiler doesn't know that (ret < min_ret) is always true, so it thinks the "if ((flags & MSG_WAITALL) ..." path could be taken. The complaint comes from gcc-9 (Debian 9.3.0-22) 9.3.0: ``` fs/io_uring.c:5238 io_recvfrom() error: uninitialized symbol 'flags' ``` Fix this by bypassing the @ret and @flags check when import_single_range() fails. Reasons: 1. import_single_range() only returns -EFAULT when it fails. 2. At that point, @flags is uninitialized and shouldn't be read. Reported-by: kernel test robot <lkp@xxxxxxxxx> Reported-by: Dan Carpenter <dan.carpenter@xxxxxxxxxx> Reported-by: "Chen, Rong A" <rong.a.chen@xxxxxxxxx> Link: https://lore.gnuweeb.org/timl/d33bb5a9-8173-f65b-f653-51fc0681c6d6@xxxxxxxxx/ Cc: Pavel Begunkov <asml.silence@xxxxxxxxx> Suggested-by: Ammar Faizi <ammarfaizi2@xxxxxxxxxxx> Fixes: 7297ce3d59449de49d3c9e1f64ae25488750a1fc ("io_uring: improve send/recv error handling") Signed-off-by: Alviro Iskandar Setiawan <alviro.iskandar@xxxxxxxxx> Signed-off-by: Ammar Faizi <ammarfaizi2@xxxxxxxxxxx> Link: https://lore.kernel.org/r/20220207140533.565411-1-ammarfaizi2@xxxxxxxxxxx Signed-off-by: Jens Axboe <axboe@xxxxxxxxx> Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx> --- io_uring/io_uring.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/io_uring/io_uring.c +++ b/io_uring/io_uring.c @@ -5240,7 +5240,6 @@ static int io_recv(struct io_kiocb *req, min_ret = iov_iter_count(&msg.msg_iter); ret = sock_recvmsg(sock, &msg, flags); -out_free: if (ret < min_ret) { if (ret == -EAGAIN && force_nonblock) return -EAGAIN; @@ -5255,6 +5254,7 @@ out_free: } req_set_fail(req); } else if ((flags & MSG_WAITALL) && (msg.msg_flags & (MSG_TRUNC | MSG_CTRUNC))) { +out_free: req_set_fail(req); } if (req->flags & REQ_F_BUFFER_SELECTED) Patches currently in stable-queue which might be from alviro.iskandar@xxxxxxxxx are queue-5.15/io_uring-clean-up-a-false-positive-warning-from-gcc-9.3.0.patch