From patchwork Sun Aug 22 21:06:06 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Olivier Langlois X-Patchwork-Id: 12451697 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.7 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B2530C4320E for ; Sun, 22 Aug 2021 21:06:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9B7CE61051 for ; Sun, 22 Aug 2021 21:06:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233333AbhHVVGu (ORCPT ); Sun, 22 Aug 2021 17:06:50 -0400 Received: from cloud48395.mywhc.ca ([173.209.37.211]:36814 "EHLO cloud48395.mywhc.ca" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232539AbhHVVGt (ORCPT ); Sun, 22 Aug 2021 17:06:49 -0400 Received: from modemcable064.203-130-66.mc.videotron.ca ([66.130.203.64]:52712 helo=localhost) by cloud48395.mywhc.ca with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1mHufP-0001tb-7O; Sun, 22 Aug 2021 17:06:07 -0400 Date: Sun, 22 Aug 2021 17:06:06 -0400 Message-Id: <1625bc89782bf83d9d8c7c63e8ffcb651ccb15fa.1629655338.git.olivier@trillion01.com> In-Reply-To: References: From: Olivier Langlois To: Jens Axboe , Pavel Begunkov , Oleg Nesterov , Steven Rostedt , Ingo Molnar , "Eric W. Biederman" , io-uring@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 3/3] coredump: cancel io_uring requests before dumping core X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - cloud48395.mywhc.ca X-AntiAbuse: Original Domain - vger.kernel.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - trillion01.com X-Get-Message-Sender-Via: cloud48395.mywhc.ca: authenticated_id: olivier@trillion01.com X-Authenticated-Sender: cloud48395.mywhc.ca: olivier@trillion01.com X-Source: X-Source-Args: X-Source-Dir: Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org The previous solution of ignoring the TIF_NOTIFY_SIGNAL bit while dumping core is only working when the core dump is sent in a file. When a pipe is used, pipe_write returns -ERESTARTSYS if signal_pending which includes TIF_NOTIFY_SIGNAL is true. A more robust solution is to make sure that io_uring will not set TIF_NOTIFY_SIGNAL while the core dump is generated by cancelling all the io_uring requests made by the current task before starting. Fixes: 06af8679449d ("coredump: Limit what can interrupt coredumps") Signed-off-by: Olivier Langlois --- fs/coredump.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/fs/coredump.c b/fs/coredump.c index 07afb5ddb1c4..9aceb4b3b40d 100644 --- a/fs/coredump.c +++ b/fs/coredump.c @@ -41,6 +41,7 @@ #include #include #include +#include #include #include @@ -625,6 +626,8 @@ void do_coredump(const kernel_siginfo_t *siginfo) need_suid_safe = true; } + io_uring_task_cancel(); + retval = coredump_wait(siginfo->si_signo, &core_state); if (retval < 0) goto fail_creds;