Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp2240753pxb; Thu, 11 Feb 2021 07:44:18 -0800 (PST) X-Google-Smtp-Source: ABdhPJzV4WUIGFj9bJkIlaGgTJ0CD4wGVfu7s54Qc+v0jpj+OLoD3UD50SmthgUKOWJvx3O7JcEl X-Received: by 2002:a50:d302:: with SMTP id g2mr8979212edh.75.1613058258566; Thu, 11 Feb 2021 07:44:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1613058258; cv=none; d=google.com; s=arc-20160816; b=MyZRyELS9l2URjQ4FdoP8iN0lRVQZ+PbVAwgQmA3T69M+svh+535LK+5C7XV9+rab6 viGi1DdszQoKSRkkoj5Gm+ImH3iFEriDM2+xYKlKqLEeP05OEZU6EOgPYybBnjkJfnmt MuVrnOumgGi+nNjHxx3x7Y2Vf+p7IFo40+KgbzmMx449dNdDMIGwG5YYAp2HRZYRP6cx kA/4PXwTIEkVU1iIRvVKeWlg5Oc0tndsGOgd7ex26RjOx/C3utCUEI+LyWr87r/R1tWw N3GalJt+ene07Cdyv90XrJX7z7A7Xi8Dr/k3F0Kg/+m+ZhCorLKG+SyR6lcdT7jXhWIf e9Tw== 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=uJ1Z33hUfL+fC0wxnfcLHPvncT76OCoz6WIjXD2tCJk=; b=kAHwvoejv2jbAOGoufA+Jc7CULrlaeT7RsRn1ikiq+zZqecHz+WlYHqI2UiVyPlJWw LTxbApGg+6iJSzMy7Em1WrLxcBhxjUID3s927LPEDnIa8ETco/xcM4RINp4Gscy5Nxgo Bnnb8ld86MrLNjjR3ZKf1N5LsEZ8+vBJs5mdR+1h4awOTWmGqu/uRm1NQ66KankRRbDU AneUvdk/xV6sZldu6IP08GYw6osilAKXhzMutV9x/OOpRzfeoQmrOJGg2A8ATQegOM6B eQqpjihKXdyLwXb9wjSA6R3LvyPL9cuQw/VFy+Xb7XCukWAG4Fa7EftweQ2dJTqqHZ2U +cZw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=fkzAvMxZ; 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 b5si3879361eju.170.2021.02.11.07.43.53; Thu, 11 Feb 2021 07:44:18 -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=fkzAvMxZ; 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 S231537AbhBKPnM (ORCPT + 99 others); Thu, 11 Feb 2021 10:43:12 -0500 Received: from mail.kernel.org ([198.145.29.99]:52052 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230003AbhBKPNT (ORCPT ); Thu, 11 Feb 2021 10:13:19 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 2186664EE8; Thu, 11 Feb 2021 15:04:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1613055859; bh=wUK9OGL1h0Qhog08GnNk0WylrDiiA+cqNwg3rfsdqCk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fkzAvMxZB/NQiMLpAHVRoiWb1zucLzvMINyFnLfQcVxhNjNdq3qAE2I1lqAdGfR0A SZEqMA/W3mN0zWKRGfkeg7QYUY+BG3fCtx3BcVVVUNK/9mUotViARgsSYiFk+dMt5s C05JBEXCogMso/KEPLyvIPyc8FiVf0XaGlqCb7aM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Greg Kroah-Hartman , Josef Grieb , Jens Axboe , Pavel Begunkov Subject: [PATCH 5.10 08/54] io_uring: if we see flush on exit, cancel related tasks Date: Thu, 11 Feb 2021 16:01:52 +0100 Message-Id: <20210211150153.241428769@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: Jens Axboe [ Upstream commit 84965ff8a84f0368b154c9b367b62e59c1193f30 ] Ensure we match tasks that belong to a dead or dying task as well, as we need to reap those in addition to those belonging to the exiting task. Cc: stable@vger.kernel.org # 5.9+ Reported-by: Josef Grieb Signed-off-by: Jens Axboe Signed-off-by: Pavel Begunkov 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 @@ -1014,8 +1014,12 @@ static bool io_match_task(struct io_kioc { struct io_kiocb *link; - if (task && head->task != task) + if (task && head->task != task) { + /* in terms of cancelation, always match if req task is dead */ + if (head->task->flags & PF_EXITING) + return true; return false; + } if (!files) return true; if (__io_match_files(head, files)) @@ -8844,6 +8848,9 @@ static int io_uring_flush(struct file *f struct io_uring_task *tctx = current->io_uring; struct io_ring_ctx *ctx = file->private_data; + if (fatal_signal_pending(current) || (current->flags & PF_EXITING)) + io_uring_cancel_task_requests(ctx, NULL); + if (!tctx) return 0;