From patchwork Fri Nov 18 15:41:41 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pavel Begunkov X-Patchwork-Id: 13048426 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3AD09C433FE for ; Fri, 18 Nov 2022 15:43:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235357AbiKRPnI (ORCPT ); Fri, 18 Nov 2022 10:43:08 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55578 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242238AbiKRPnH (ORCPT ); Fri, 18 Nov 2022 10:43:07 -0500 Received: from mail-ed1-x52c.google.com (mail-ed1-x52c.google.com [IPv6:2a00:1450:4864:20::52c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 25AE159175 for ; Fri, 18 Nov 2022 07:43:07 -0800 (PST) Received: by mail-ed1-x52c.google.com with SMTP id x2so7707591edd.2 for ; Fri, 18 Nov 2022 07:43:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=YKuubekYFmhQpvPasuTk8ymDDJ8LyjeEFp1F3U1uKtM=; b=OIyoq7bZ9LO5jAjstuB3tj86qWj0L3JGD7lEaxU+1jqtn2GZd1pEWLiAQe+cK3ki0+ eCbp/3qsaTAVXsAOFdZWMjJfj95vYClqf4Kj3OEsfyaIqBe5hWe/i5864nXM2oWwaY8e z38p8pr5vei8lA2OGHpLEEk/3MxrxhFnGTtD8flE6HLj7DXAMePQYtoriNwcX5JwGfhR ZxM2o2NrSFG3q+HTNFQJLsIbtQeg0YYTIVh8ELoXhSzLpWlB1sxCJtRaE3rUisXA3kW0 8mth/VN48IZdhPRr2gxfJiJCRQ3fqHD0d1ZYjF/W1OwZjlKciUX4UrppHudqvjDsYWRT s6sQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=YKuubekYFmhQpvPasuTk8ymDDJ8LyjeEFp1F3U1uKtM=; b=DICky0O82HUxNbmEhCY00n+ZiZ2Sv1QrVlM9m096ITvo6295lWpFHUQuGGCmM4c9G4 fqNSjh6FShqE8gK1tPCHncYIX/PX3SqHHK2natPnaqighTqwagiTpp4WMYVewKzFZkui eF8RfS+YAkJy+jeHsA6zBuh1uYWdITzRUggETWvyN9HWUoe0UoxCmTszh/l8kucik2aO SbUd6M2nzBBVtiPM4D/8SaBcHhB9xUE1XxLQfKC+7jFH/4R8HSQ9uX9Ykxnu40AqO5RX ICGLtlrxgvIZdYoqUiyQiPvgzA5ieRD5rb4ZMJ5G68GzWbOkMrIIW7sFMCIQZ3id3XaD EMMw== X-Gm-Message-State: ANoB5pnybdUa4Y4jAFzeAmEttGgejuklgBe29T0VwGoocEi3XSxBCimr KoHR/UBgQDSpPlQa2sy0La8u17yJsn8= X-Google-Smtp-Source: AA0mqf6s+fOLRXnf67mJFkBIAEyatgmr1UaGQFyKgYatKvAgP0pg1hNzApnY2xr68KaBUy1uwRI8Ww== X-Received: by 2002:aa7:c508:0:b0:461:84de:7ac4 with SMTP id o8-20020aa7c508000000b0046184de7ac4mr6690541edq.206.1668786185192; Fri, 18 Nov 2022 07:43:05 -0800 (PST) Received: from 127.0.0.1localhost.com ([2620:10d:c092:600::2:c0b4]) by smtp.gmail.com with ESMTPSA id kx21-20020a170907775500b0078128c89439sm1827595ejc.6.2022.11.18.07.43.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Nov 2022 07:43:04 -0800 (PST) From: Pavel Begunkov To: io-uring@vger.kernel.org Cc: Jens Axboe , asml.silence@gmail.com Subject: [PATCH for-6.1] io_uring: disallow self-propelled ring polling Date: Fri, 18 Nov 2022 15:41:41 +0000 Message-Id: <3124038c0e7474d427538c2d915335ec28c92d21.1668785722.git.asml.silence@gmail.com> X-Mailer: git-send-email 2.38.1 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: io-uring@vger.kernel.org When we post a CQE we wake all ring pollers as it normally should be. However, if a CQE was generated by a multishot poll request targeting its own ring, it'll wake that request up, which will make it to post a new CQE, which will wake the request and so on until it exhausts all CQ entries. Don't allow multishot polling io_uring files but downgrade them to oneshots, which was always stated as a correct behaviour that the userspace should check for. Cc: stable@vger.kernel.org Fixes: aa43477b04025 ("io_uring: poll rework") Signed-off-by: Pavel Begunkov --- io_uring/poll.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/io_uring/poll.c b/io_uring/poll.c index f500506984ec..9fe31c1ebb7b 100644 --- a/io_uring/poll.c +++ b/io_uring/poll.c @@ -239,6 +239,8 @@ static int io_poll_check_events(struct io_kiocb *req, bool *locked) continue; if (req->apoll_events & EPOLLONESHOT) return IOU_POLL_DONE; + if (io_is_uring_fops(req->file)) + return IOU_POLL_DONE; /* multishot, just fill a CQE and proceed */ if (!(req->flags & REQ_F_APOLL_MULTISHOT)) {