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 2CD7751C5A; Tue, 22 Jul 2025 14:00:26 +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=1753192826; cv=none; b=Za4zhFJwd4m3UVaDo+1jsY7PvU2fsYxAXwzpoSWw1P58wOCKjT7K/U4XfJfzhqsZkRfWLXxLV0v7bAt5gksDGLpP1QomHHyB3okRA1wKxTxkfNvfpUaNPMejvxaHF7IuGjuRyoxZh84w3fIJ8umODPHevhSEF/nVClJZLWymCzk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753192826; c=relaxed/simple; bh=fnl36tM/auWeg0ov0IeslQGdgUS1j8wI/5FteCJIIsA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ipaGAD3GSwE+IEHbO/eaBLXtCpHmo6ORO2ZIn+RNPaRbEGVbH5M61RiCo/mosS04delnlSAega2YlCjTVGdAo+bUIDuQXxvejVTlHTx3mObqeNodch8hFsCy0BJaE+Vlx/L7VqWb8bGROhGMOnbiYbjNHLC3KzTGOidiwR4/D1w= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=PHSz5Bxm; 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="PHSz5Bxm" Received: by smtp.kernel.org (Postfix) with ESMTPSA id A7F9BC4CEF5; Tue, 22 Jul 2025 14:00:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1753192826; bh=fnl36tM/auWeg0ov0IeslQGdgUS1j8wI/5FteCJIIsA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PHSz5BxmVOr62fTIa4QsRO8NzDWoUKs0MwVChTFlY2xEaT0L2XBEqXtUPHd0NxZeG avd9jhQ4YN0cLJtaDP1kTKBEbAYDGeGOlqeL8UTNLEtYEeWeYqCDrC14DFokey9T2y 4gqtruajMYhY6/yanTxgrjM34ve+ot8E1UDQYCT8= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Pavel Begunkov , Jens Axboe Subject: [PATCH 6.12 035/158] io_uring/poll: fix POLLERR handling Date: Tue, 22 Jul 2025 15:43:39 +0200 Message-ID: <20250722134342.057726841@linuxfoundation.org> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20250722134340.596340262@linuxfoundation.org> References: <20250722134340.596340262@linuxfoundation.org> User-Agent: quilt/0.68 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.12-stable review patch. If anyone has any objections, please let me know. ------------------ From: Pavel Begunkov commit c7cafd5b81cc07fb402e3068d134c21e60ea688c upstream. 8c8492ca64e7 ("io_uring/net: don't retry connect operation on EPOLLERR") is a little dirty hack that 1) wrongfully assumes that POLLERR equals to a failed request, which breaks all POLLERR users, e.g. all error queue recv interfaces. 2) deviates the connection request behaviour from connect(2), and 3) racy and solved at a wrong level. Nothing can be done with 2) now, and 3) is beyond the scope of the patch. At least solve 1) by moving the hack out of generic poll handling into io_connect(). Cc: stable@vger.kernel.org Fixes: 8c8492ca64e79 ("io_uring/net: don't retry connect operation on EPOLLERR") Signed-off-by: Pavel Begunkov Link: https://lore.kernel.org/r/3dc89036388d602ebd84c28e5042e457bdfc952b.1752682444.git.asml.silence@gmail.com Signed-off-by: Jens Axboe Signed-off-by: Greg Kroah-Hartman --- io_uring/net.c | 12 ++++++++---- io_uring/poll.c | 2 -- 2 files changed, 8 insertions(+), 6 deletions(-) --- a/io_uring/net.c +++ b/io_uring/net.c @@ -1735,9 +1735,11 @@ int io_connect(struct io_kiocb *req, uns int ret; bool force_nonblock = issue_flags & IO_URING_F_NONBLOCK; - if (unlikely(req->flags & REQ_F_FAIL)) { - ret = -ECONNRESET; - goto out; + if (connect->in_progress) { + struct poll_table_struct pt = { ._key = EPOLLERR }; + + if (vfs_poll(req->file, &pt) & EPOLLERR) + goto get_sock_err; } file_flags = force_nonblock ? O_NONBLOCK : 0; @@ -1762,8 +1764,10 @@ int io_connect(struct io_kiocb *req, uns * which means the previous result is good. For both of these, * grab the sock_error() and use that for the completion. */ - if (ret == -EBADFD || ret == -EISCONN) + if (ret == -EBADFD || ret == -EISCONN) { +get_sock_err: ret = sock_error(sock_from_file(req->file)->sk); + } } if (ret == -ERESTARTSYS) ret = -EINTR; --- a/io_uring/poll.c +++ b/io_uring/poll.c @@ -315,8 +315,6 @@ static int io_poll_check_events(struct i return IOU_POLL_REISSUE; } } - if (unlikely(req->cqe.res & EPOLLERR)) - req_set_fail(req); if (req->apoll_events & EPOLLONESHOT) return IOU_POLL_DONE;