Received: by 2002:a25:683:0:0:0:0:0 with SMTP id 125csp108384ybg; Mon, 8 Jun 2020 17:49:57 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwOGniNYWOyGeFCzCKurYaGd/KwoPnIv74CHgI7jOAw5BS7xrl//U0MoK5BgFJ0RSs2I+qn X-Received: by 2002:a17:906:76c4:: with SMTP id q4mr24577558ejn.371.1591663796940; Mon, 08 Jun 2020 17:49:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591663796; cv=none; d=google.com; s=arc-20160816; b=M9HjrlhXnECfIiCz/ZcgCWn5kFFiPcejfTzi8lr34uirYhpCu0ONFe8ACSDRK1foii OXU7WmuTSRfEjMzmncDDFjQ6E1+vHTfg9bPhsM24S1soTlTA+VnV1H9hXnxraU0flfM/ LqZE8Mt0+oT9uX42TQd7t8nHc8lrksb0a6XTLgbgl0Er7qoHdIs99J1dCjM3vYNvMy2Y n5XHDev362so57YYa5oqpkTPjJc65pxhtdbF8jl475CeCS1iOGAd3tA7gmd9aPVaAucK aN1EYWSLdCYaOdyMAL65IMbwO4EF7icTYoREP81658dkIdr7eS63ZLhIwHlM4VAUWMMi 5DvQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=1uOXKKwn8RhZ22kxVtKyRSMTwvSIvcndf/ToOou9vh0=; b=nbZDt36Ko7ANJWg73Deds7OiNh4TRsRlPJ/FVe9svcP4MQN4XU3BFVIuCcHBq4Rt71 u7eoT0jNXFOzzidZPamiYJ7SzSYBSfcIV/9jZiEihWn/b/cXwKBn7z01aB16cnypD6ek s8DbydfkPn1MbaCNQN7g5945xQb9HEiNESD3b90XhEzW0cum8h8nRqFmImvz7+RUfSfB 3nWUJj1AETs5mubjY0W2MnUcTFkRvCNzJm8+tSM/sObq7Dg6EdAO/RUYomahJJn9I/U7 A+EdZBujPwctbeokAn9UHLOmlqGz6CRwRG+c4Hx5hKwauOuRJ53jByHa9dpfcBL/2olm RRaQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=KADOENpz; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id cx18si8133004edb.323.2020.06.08.17.49.33; Mon, 08 Jun 2020 17:49:56 -0700 (PDT) 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=@kernel.org header.s=default header.b=KADOENpz; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1733288AbgFIApr (ORCPT + 99 others); Mon, 8 Jun 2020 20:45:47 -0400 Received: from mail.kernel.org ([198.145.29.99]:58782 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728975AbgFHXLq (ORCPT ); Mon, 8 Jun 2020 19:11:46 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 661652151B; Mon, 8 Jun 2020 23:11:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1591657906; bh=WoBvXvBT7w5MB1Ci7HGCPSvkE9k4I+qGx8ouhuGbpBE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KADOENpzi4cxP4t4Fq7cuHlZ+5+7c1TbQP4G88ziw1qCEC+1L9sJp2GKhvxGgdMQ2 l4eA1wsaLnUV3WAsW4j5Cgcha+p0byqn6nqlFFaNd3Q6SH2HHJSuOmk5hNMC+a95ga jKtfn/peoNXyE3+wmbjOHOwWjB2T35S+OQRVoqO4= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Pavel Begunkov , Jens Axboe , Sasha Levin , linux-fsdevel@vger.kernel.org, io-uring@vger.kernel.org Subject: [PATCH AUTOSEL 5.7 258/274] io_uring: fix overflowed reqs cancellation Date: Mon, 8 Jun 2020 19:05:51 -0400 Message-Id: <20200608230607.3361041-258-sashal@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200608230607.3361041-1-sashal@kernel.org> References: <20200608230607.3361041-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Pavel Begunkov [ Upstream commit 7b53d59859bc932b37895d2d37388e7fa29af7a5 ] Overflowed requests in io_uring_cancel_files() should be shed only of inflight and overflowed refs. All other left references are owned by someone else. If refcount_sub_and_test() fails, it will go further and put put extra ref, don't do that. Also, don't need to do io_wq_cancel_work() for overflowed reqs, they will be let go shortly anyway. Signed-off-by: Pavel Begunkov Signed-off-by: Jens Axboe Signed-off-by: Sasha Levin --- fs/io_uring.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/fs/io_uring.c b/fs/io_uring.c index dd90c3fcd4f5..4038ed0a5c39 100644 --- a/fs/io_uring.c +++ b/fs/io_uring.c @@ -7467,10 +7467,11 @@ static void io_uring_cancel_files(struct io_ring_ctx *ctx, finish_wait(&ctx->inflight_wait, &wait); continue; } + } else { + io_wq_cancel_work(ctx->io_wq, &cancel_req->work); + io_put_req(cancel_req); } - io_wq_cancel_work(ctx->io_wq, &cancel_req->work); - io_put_req(cancel_req); schedule(); finish_wait(&ctx->inflight_wait, &wait); } -- 2.25.1