From mboxrd@z Thu Jan 1 00:00:00 1970 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=-14.2 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=ham 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 03D46C4338F for ; Tue, 17 Aug 2021 21:39:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id CFD8860F11 for ; Tue, 17 Aug 2021 21:39:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234361AbhHQVj5 (ORCPT ); Tue, 17 Aug 2021 17:39:57 -0400 Received: from mail.cybernetics.com ([173.71.130.66]:32900 "EHLO mail.cybernetics.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231630AbhHQVj5 (ORCPT ); Tue, 17 Aug 2021 17:39:57 -0400 X-ASG-Debug-ID: 1629236359-0fb3b00bc411c20001-k4Lu3k Received: from cybernetics.com ([10.10.4.126]) by mail.cybernetics.com with ESMTP id Ay0aCx67Gi3c4LJt; Tue, 17 Aug 2021 17:39:19 -0400 (EDT) X-Barracuda-Envelope-From: tonyb@cybernetics.com X-Barracuda-RBL-Trusted-Forwarder: 10.10.4.126 X-ASG-Whitelist: Client DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=cybernetics.com; s=mail; bh=CwgGQbJnAx7e81R8CCBmcM3i0wXVlb0O/n3+HhzHIIo=; h=Content-Language:Content-Transfer-Encoding:Content-Type:In-Reply-To: MIME-Version:Date:Message-ID:From:References:Cc:To:Subject; b=lXI5kzRsraQZKx5 m/5NRRxeRPuYy/PZPjofZM7qHDKZ7dCnjSFZhsLx/MuHjoYvaunKTJdKvpBI5IpYkn8YOnWRUr8aW h7pNB2NcRElMIEyeseUBXZH26eVkucNPIb8oBYnAYpBqeyH72CnMQO6V/rM49zvfZTLSNcJTOl+K5 Qk= Received: from [10.157.2.224] (HELO [192.168.200.1]) by cybernetics.com (CommuniGate Pro SMTP 6.2.14) with ESMTPS id 11075885; Tue, 17 Aug 2021 17:39:19 -0400 Subject: Re: [PATCH] coredump: Limit what can interrupt coredumps X-Barracuda-RBL-Trusted-Forwarder: 10.157.2.224 To: Jens Axboe , Olivier Langlois , "Eric W. Biederman" , Oleg Nesterov X-ASG-Orig-Subj: Re: [PATCH] coredump: Limit what can interrupt coredumps Cc: Linus Torvalds , Linux Kernel Mailing List , linux-fsdevel , io-uring , Alexander Viro , "Pavel Begunkov>" References: <87eeda7nqe.fsf@disp2133> <87pmwt6biw.fsf@disp2133> <87czst5yxh.fsf_-_@disp2133> <87y2bh4jg5.fsf@disp2133> <87sg1p4h0g.fsf_-_@disp2133> <20210614141032.GA13677@redhat.com> <87pmwmn5m0.fsf@disp2133> <4d93d0600e4a9590a48d320c5a7dd4c54d66f095.camel@trillion01.com> <8af373ec-9609-35a4-f185-f9bdc63d39b7@cybernetics.com> <9d194813-ecb1-2fe4-70aa-75faf4e144ad@kernel.dk> <0bc38b13-5a7e-8620-6dce-18731f15467e@kernel.dk> <24c795c6-4ec4-518e-bf9b-860207eee8c7@kernel.dk> <05c0cadc-029e-78af-795d-e09cf3e80087@cybernetics.com> <84640f18-79ee-d8e4-5204-41a2c2330ed8@kernel.dk> From: Tony Battersby Message-ID: <3168284a-0b52-7845-07b1-a72bdfed915c@cybernetics.com> Date: Tue, 17 Aug 2021 17:39:18 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 MIME-Version: 1.0 In-Reply-To: <84640f18-79ee-d8e4-5204-41a2c2330ed8@kernel.dk> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Content-Language: en-US X-Barracuda-Connect: UNKNOWN[10.10.4.126] X-Barracuda-Start-Time: 1629236359 X-Barracuda-URL: https://10.10.4.122:443/cgi-mod/mark.cgi X-Barracuda-BRTS-Status: 1 X-Virus-Scanned: by bsmtpd at cybernetics.com X-Barracuda-Scan-Msg-Size: 1690 Precedence: bulk List-ID: X-Mailing-List: io-uring@vger.kernel.org On 8/17/21 5:28 PM, Jens Axboe wrote: > > Another approach - don't allow TWA_SIGNAL task_work to get queued if > PF_SIGNALED has been set on the task. This is similar to how we reject > task_work_add() on process exit, and the callers must be able to handle > that already. > > Can you test this one on top of your 5.10-stable? > > > diff --git a/fs/coredump.c b/fs/coredump.c > index 07afb5ddb1c4..ca7c1ee44ada 100644 > --- a/fs/coredump.c > +++ b/fs/coredump.c > @@ -602,6 +602,14 @@ void do_coredump(const kernel_siginfo_t *siginfo) > .mm_flags = mm->flags, > }; > > + /* > + * task_work_add() will refuse to add work after PF_SIGNALED has > + * been set, ensure that we flush any pending TIF_NOTIFY_SIGNAL work > + * if any was queued before that. > + */ > + if (test_thread_flag(TIF_NOTIFY_SIGNAL)) > + tracehook_notify_signal(); > + > audit_core_dumps(siginfo->si_signo); > > binfmt = mm->binfmt; > diff --git a/kernel/task_work.c b/kernel/task_work.c > index 1698fbe6f0e1..1ab28904adc4 100644 > --- a/kernel/task_work.c > +++ b/kernel/task_work.c > @@ -41,6 +41,12 @@ int task_work_add(struct task_struct *task, struct callback_head *work, > head = READ_ONCE(task->task_works); > if (unlikely(head == &work_exited)) > return -ESRCH; > + /* > + * TIF_NOTIFY_SIGNAL notifications will interfere with > + * a core dump in progress, reject them. > + */ > + if ((task->flags & PF_SIGNALED) && notify == TWA_SIGNAL) > + return -ESRCH; > work->next = head; > } while (cmpxchg(&task->task_works, head, work) != head); > > Doesn't compile.  5.10 doesn't have TIF_NOTIFY_SIGNAL. Tony Battersby