Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp9106942pxu; Mon, 28 Dec 2020 06:49:12 -0800 (PST) X-Google-Smtp-Source: ABdhPJzXAOGv8IFBz2KlRU7MlxNJR+sDu9s1BMOCCFPXWgP/J8N91wV315vE83L2biDXHl4osO1u X-Received: by 2002:aa7:c919:: with SMTP id b25mr41381682edt.108.1609166952548; Mon, 28 Dec 2020 06:49:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609166952; cv=none; d=google.com; s=arc-20160816; b=oBx+zrPdK4N11zbm6x0nBAjjyI0ORf6PHEuSYljPnH9EMQk4DcM2nssRxETo4eQrFW ddZCnhpWwc3jJcib0ku0a6pGhDf5A8vJDbvYY2TfqRjSHIJbWOzb8kcwJlMVAM3UGhmi F1FUaQW5JXCMrOi6X7n6m72HNPH07SsuyvVsfkNEnUmvddMpdh6GtFdDd2ZC3JW1PqEt 6dmktivMknP0Ea6oFrzxxxNZFrdsy1q9tobXTJx+5YlVYud5gU8MtbWsQXLPEBQdLWDh InL2pR5ac0dQ47wQHn+AAHdy9Mo3Iyqdq17xlx4OGjh5TiGpRcbNV0acnyuiZSiEog3v jE8g== 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=nW77tgYiyZ2fx3NCweRxZJCraP1sewTf+Imu1RqDgjQ=; b=k42ZN2BmObZDXtUBG3Pz43WZ2mSUFRLqkZQG8a+I2LpkcA8N6uV6p0UtaYS/++7m76 D3WxSKWWhxgWDqd3N/h3dBGNy7AV0v+Hu/YgJe6eT5x0HR9iM8+aroWwNHX6wq8mk89q Tj4GJRQE3uOjmhpOgGfUUjRLLhxHX8SoFB5w8ieElhJ5gK4hsLXNQlOMUByBR+aNLuO/ 8xugc6LNL+7ofxE1hsFUK2NAqpJAp53iA7ifvwF27JWc2VOw7U9K374msOgYWsmXQdDk BHZPYqYokZAZZjy0SjdVJyMDKubDwhSme3//I7r5wCK6CCj4b49s/cpbeNxT0TK89DZ7 oShg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=zjvt9PnD; 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 hs10si9211688ejc.57.2020.12.28.06.48.48; Mon, 28 Dec 2020 06:49:12 -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=zjvt9PnD; 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 S2506613AbgL1OqU (ORCPT + 99 others); Mon, 28 Dec 2020 09:46:20 -0500 Received: from mail.kernel.org ([198.145.29.99]:60210 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2502999AbgL1OYH (ORCPT ); Mon, 28 Dec 2020 09:24:07 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 47BDA22AEC; Mon, 28 Dec 2020 14:23:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1609165407; bh=kogepKgP2qSS/eTnmVk/QoKuTHbO64aWOs1Lu8EteTM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=zjvt9PnDk7jY+vGZ52/7mMspnYV00vYnXotv91y8wn2mqbsL6wjdBod/z588qdkKB UVNPhxRBE/QWzx82KrHRfx3B+1osyQHDpISwL5KhQikymi7dLs12pvW15mNzRX2A8z CJ8xWC0oPSlgpL39ZqWKRIxTmY/TJmmdtOYwMLH8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jens Axboe Subject: [PATCH 5.10 521/717] io_uring: make ctx cancel on exit targeted to actual ctx Date: Mon, 28 Dec 2020 13:48:39 +0100 Message-Id: <20201228125045.924030517@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201228125020.963311703@linuxfoundation.org> References: <20201228125020.963311703@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: Jens Axboe commit 00c18640c2430c4bafaaeede1f9dd6f7ec0e4b25 upstream. Before IORING_SETUP_ATTACH_WQ, we could just cancel everything on the io-wq when exiting. But that's not the case if they are shared, so cancel for the specific ctx instead. Cc: stable@vger.kernel.org Fixes: 24369c2e3bb0 ("io_uring: add io-wq workqueue sharing") Signed-off-by: Jens Axboe Signed-off-by: Greg Kroah-Hartman --- fs/io_uring.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) --- a/fs/io_uring.c +++ b/fs/io_uring.c @@ -8401,6 +8401,13 @@ static void io_ring_exit_work(struct wor io_ring_ctx_free(ctx); } +static bool io_cancel_ctx_cb(struct io_wq_work *work, void *data) +{ + struct io_kiocb *req = container_of(work, struct io_kiocb, work); + + return req->ctx == data; +} + static void io_ring_ctx_wait_and_kill(struct io_ring_ctx *ctx) { mutex_lock(&ctx->uring_lock); @@ -8415,7 +8422,7 @@ static void io_ring_ctx_wait_and_kill(st io_poll_remove_all(ctx, NULL); if (ctx->io_wq) - io_wq_cancel_all(ctx->io_wq); + io_wq_cancel_cb(ctx->io_wq, io_cancel_ctx_cb, ctx, true); /* if we failed setting up the ctx, we might not have any rings */ io_iopoll_try_reap_events(ctx);