From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 C2FCB472798; Tue, 16 Jun 2026 18:59:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781636398; cv=none; b=ifIjP3Y/V9DWhhy/NMQDtNybumEp0pZJgi4Nn/r2ZfqSNblRPiQl2j4poSGRsdCrm4KWN2J76ifefF59S4qc5sJGTTokc3k2Qu4Fx4RPRnlh+Rg5EaRPkEoRS26Dv7rVzT/O8F7REcqOPsBB1xQvLxVeQtxDcP7n2yAAgPiDwq4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781636398; c=relaxed/simple; bh=UACtSUDjlrYbM2OsKpTx/C30KQ6X2W0ULdkBPOMfxTU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=odhAF37WU1ES5Uzu/B5ZEsQQJ6788Juelze5e/PldaOlT6G+jydNp9bvicWYeRwwlDi/vyWf1PkWZ2+dnHeLe5lPQFH2ar+nrFTSTamUPG7aqM6EBGC5O+eP7vU/rmft2eZ5WTcvrm9JFPXKhcxDGy2yMnUG3Fsd7MXBOROpG4E= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=kS1IVsva; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="kS1IVsva" Received: by smtp.kernel.org (Postfix) with ESMTPSA id D2D3B1F000E9; Tue, 16 Jun 2026 18:59:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1781636397; bh=PTQoYmxuADBnPi0ukGnrtDobUwlKsm8/DzoWH4FYV1o=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=kS1IVsvaUF1dMcKz7bm/V5rT9+yyOHBJnh9lo/77qLIF4BqX4h9dFtfCSujPVMJZw vOwtxmA0kwtVcQMl/vdToQf0OG+2k9wRRG7SWgFUtWCuePI8R7sKtElpEz2qpFNFbi sxlorxJsUeDYQYYZKMkDdmSXXwKHzBoiS/Rzq83M= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Yifan Wu , Juefei Pu , Yuan Tan , Xin Liu , Zhengchuan Liang , Longxuan Yu , Ren Wei , Pavel Begunkov , Jens Axboe Subject: [PATCH 5.10 214/342] io_uring/poll: fix signed comparison in io_poll_get_ownership() Date: Tue, 16 Jun 2026 20:28:30 +0530 Message-ID: <20260616145058.149589321@linuxfoundation.org> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260616145048.348037099@linuxfoundation.org> References: <20260616145048.348037099@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 5.10-stable review patch. If anyone has any objections, please let me know. ------------------ From: Longxuan Yu Commit 326941b22806cbf2df1fbfe902b7908b368cce42 usptream. io_poll_get_ownership() uses a signed comparison to check whether poll_refs has reached the threshold for the slowpath: if (unlikely(atomic_read(&req->poll_refs) >= IO_POLL_REF_BIAS)) atomic_read() returns int (signed). When IO_POLL_CANCEL_FLAG (BIT(31)) is set in poll_refs, the value becomes negative in signed arithmetic, so the >= 128 comparison always evaluates to false and the slowpath is never taken. Fix this by casting the atomic_read() result to unsigned int before the comparison, so that the cancel flag is treated as a large positive value and correctly triggers the slowpath. Fixes: a26a35e9019f ("io_uring: make poll refs more robust") Cc: stable@vger.kernel.org Reported-by: Yifan Wu Reported-by: Juefei Pu Co-developed-by: Yuan Tan Signed-off-by: Yuan Tan Suggested-by: Xin Liu Tested-by: Zhengchuan Liang Signed-off-by: Longxuan Yu Signed-off-by: Ren Wei Reviewed-by: Pavel Begunkov Link: https://patch.msgid.link/3a3508b08bcd7f1bc3beff848ae6e1d73d355043.1775965597.git.ylong030@ucr.edu Signed-off-by: Jens Axboe Signed-off-by: Greg Kroah-Hartman --- 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 @@ -5378,7 +5378,7 @@ static bool io_poll_get_ownership_slowpa */ static inline bool io_poll_get_ownership(struct io_kiocb *req) { - if (unlikely(atomic_read(&req->poll_refs) >= IO_POLL_REF_BIAS)) + if (unlikely((unsigned int)atomic_read(&req->poll_refs) >= IO_POLL_REF_BIAS)) return io_poll_get_ownership_slowpath(req); return !(atomic_fetch_inc(&req->poll_refs) & IO_POLL_REF_MASK); }