Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp2240736pxb; Thu, 11 Feb 2021 07:44:18 -0800 (PST) X-Google-Smtp-Source: ABdhPJz+0pI4UbAEPGfZJNqxDF96CbL7sea4kOIrwTws9kZ5P3uqx/XsoEqlMX/IYkC8qOHBDjUo X-Received: by 2002:a17:907:20e8:: with SMTP id rh8mr4363409ejb.119.1613058257918; Thu, 11 Feb 2021 07:44:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1613058257; cv=none; d=google.com; s=arc-20160816; b=DWk73CtAYooeweye21OpxlDqp8Ig8+LiIYL5bvM/3UW/zs5+heaLwKlVDLupLCKVB3 1A2eYa2LsrMqg7fJiYd04VI3e/jksAZKfE0we7xWeJQc4CWiDO1rsOwa9xdC1Jy475CV RLlcyqL4QIR1gmSlMdlzOZ4eQlAX25V53r8231+PRujPG0AoHp7soE9wkNMSUlB8DwFV lWvMDpCjUg5VzzcWwLmgX2WrKehvx8nkCB0GTdYAbKhc7vGpv7a7sbSK7pQhqYm99yE6 +jk6jXFIdgqdVJ4r/4BwOIsiEN89E4wEN42Kg8PNK7rerkFcnc8M4yJ5/MSdwjS4gDXa jlTA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=8uVUedOp1heQxpyl25Cex9yKYfg4kYoa9PNx0iOcO3o=; b=ts7KM5/p1Al+3yIKmg6S0lUt2YJA/YPLoq9BrsFZc78Inzuh0OWuOFn9N79APEda6W 9vknBBHi/akX0q+HUsrYNeeTTIyI3duP7gGo93vQCEuWHQKZtFeys3PQDjcpViFHYrUz hJ52IwzyLYQOuIRxUa2rKz64xZfifRBl9yhnXtH5Q8C19bEW1ipttYAc7AxWfxClBG+x XgW4cKCZOIqKrtnEWSJHL7AnLSt4giApKXFRjiSEDUaNsSM7bSExdyj9RkvDQeiG5nRh x1NQobpEZywsB7U6Lb+WaLm2hKTk5mDzdatR8HHqPOA/1b26fzn/pJPDIaUWplIib9qz 1fxA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=yFPmmFzb; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id w17si4001254ejy.52.2021.02.11.07.43.53; Thu, 11 Feb 2021 07:44:17 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=yFPmmFzb; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231474AbhBKPmp (ORCPT + 99 others); Thu, 11 Feb 2021 10:42:45 -0500 Received: from mail.kernel.org ([198.145.29.99]:51442 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229940AbhBKPNT (ORCPT ); Thu, 11 Feb 2021 10:13:19 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 8990864EE9; Thu, 11 Feb 2021 15:04:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1613055862; bh=bOF1+ygeVJ0Xvrdhb7APeT6uiLTctc3tlWBM7fCpBYg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=yFPmmFzbXggwWXbPkmGSMotiJ99LGOnO/KwJPULHIEzCdTryEvxDzRgkiGCcYY+1w vpMoHTcpRv7OSKSqIdfsW7QNbSXyZqv117HzBylYOxWv+jFu/Pa3c9jPJh5cq8lmBA MRWEwDe8Cphbo/qXB4BHwWK6b/eKlBLMvBBA6V7Y= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Greg Kroah-Hartman , Jens Axboe , Pavel Begunkov Subject: [PATCH 5.10 09/54] io_uring: fix __io_uring_files_cancel() with TASK_UNINTERRUPTIBLE Date: Thu, 11 Feb 2021 16:01:53 +0100 Message-Id: <20210211150153.284941450@linuxfoundation.org> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20210211150152.885701259@linuxfoundation.org> References: <20210211150152.885701259@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Pavel Begunkov [ Upstream commit a1bb3cd58913338e1b627ea6b8c03c2ae82d293f ] If the tctx inflight number haven't changed because of cancellation, __io_uring_task_cancel() will continue leaving the task in TASK_UNINTERRUPTIBLE state, that's not expected by __io_uring_files_cancel(). Ensure we always call finish_wait() before retrying. Cc: stable@vger.kernel.org # 5.9+ Signed-off-by: Pavel Begunkov Signed-off-by: Jens Axboe Signed-off-by: Greg Kroah-Hartman --- fs/io_uring.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) --- a/fs/io_uring.c +++ b/fs/io_uring.c @@ -8829,15 +8829,15 @@ void __io_uring_task_cancel(void) prepare_to_wait(&tctx->wait, &wait, TASK_UNINTERRUPTIBLE); /* - * If we've seen completions, retry. This avoids a race where - * a completion comes in before we did prepare_to_wait(). + * If we've seen completions, retry without waiting. This + * avoids a race where a completion comes in before we did + * prepare_to_wait(). */ - if (inflight != tctx_inflight(tctx)) - continue; - schedule(); + if (inflight == tctx_inflight(tctx)) + schedule(); + finish_wait(&tctx->wait, &wait); } while (1); - finish_wait(&tctx->wait, &wait); atomic_dec(&tctx->in_idle); io_uring_remove_task_files(tctx);