Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2902237pxj; Mon, 14 Jun 2021 09:40:25 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxzZTgLRQDvph30h9W+BpPT+DFo5+HGtJ7S2VYrtZ60av9AY7huEEK94tReGpjCZQ7SGgyy X-Received: by 2002:a17:907:960e:: with SMTP id gb14mr16590482ejc.231.1623688825110; Mon, 14 Jun 2021 09:40:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623688825; cv=none; d=google.com; s=arc-20160816; b=ZFSileiKesDF5Gf9iTYz6MGkJd/mOIhwl5okps6av0jWIsi4N3ku5SjNJxp57QxUV7 gHkyibG35W9GhkKMiEDtosXbkejXm9B0w9ZEbz6rIynXHGv2v3WFB1b/hs2QNNSorjh9 omltP6WH5VYcwKNwUkwxahWP2zalRYVEw4XbJMhpxMHvI+AG25Dk0jq8xmL8rOWZ180z 1y5HKn4toSMVnAM3Xxxd4Ad8rDz5HYGA590JEx0Y7akm/E7xxuImXwJUkqP4+ZVoCwcy Iwq+Ao2sp8krTwkhe58LyX86oCAyLMe1tlnZONgJLXznrcBHAnHQcdjLKJOQjAjC8EZY tTGA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:subject:mime-version:user-agent:message-id :in-reply-to:date:references:cc:to:from; bh=uEqv89ybMlzDgfQrg4hhyl+UwjOiF99s/RZwxRo216E=; b=gTEnTxcWWRdvFo0dZAYVyMvfWQg2rwSURucSZgtwdy95FViG1HNKcTxEmcCdk0gGLS c+3V74+AP/FHP6vIWgwMbuULsmztDfHBN5VtXXbq+eRvZ+JonGl7+VhbUy58cWPUmmfY GUXicpUFwlTH6+9BIv6SWzoPp9UVOyySX99/tHZ2IWYTfYdDUOBnl7ZFHWw/AktETnyu 4jFD7YqShHldGA1TBC2z7n38+0av7EQhR/3lhqCKKMGnUu9OxltA2yM9yOnL+ijwoIFE pEKwe8FXXm6XWEh+h9pcFEGr4qBAW9vva/XaPzslZ5T3EOQNo2Kv/W87Zi5n6eUTyD+m CIuA== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=xmission.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id lh4si11415601ejb.152.2021.06.14.09.40.01; Mon, 14 Jun 2021 09:40:25 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=xmission.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234859AbhFNQkR (ORCPT + 99 others); Mon, 14 Jun 2021 12:40:17 -0400 Received: from out01.mta.xmission.com ([166.70.13.231]:55700 "EHLO out01.mta.xmission.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234785AbhFNQj5 (ORCPT ); Mon, 14 Jun 2021 12:39:57 -0400 Received: from in02.mta.xmission.com ([166.70.13.52]) by out01.mta.xmission.com with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.93) (envelope-from ) id 1lspb0-00E2ye-8I; Mon, 14 Jun 2021 10:37:54 -0600 Received: from ip68-227-160-95.om.om.cox.net ([68.227.160.95] helo=email.xmission.com) by in02.mta.xmission.com with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.93) (envelope-from ) id 1lspaz-00Bj3q-9Z; Mon, 14 Jun 2021 10:37:53 -0600 From: ebiederm@xmission.com (Eric W. Biederman) To: Oleg Nesterov Cc: Linus Torvalds , Olivier Langlois , Linux Kernel Mailing List , linux-fsdevel , io-uring , Alexander Viro , Jens Axboe , "Pavel Begunkov\>" References: <198e912402486f66214146d4eabad8cb3f010a8e.camel@trillion01.com> <87eeda7nqe.fsf@disp2133> <87pmwt6biw.fsf@disp2133> <87czst5yxh.fsf_-_@disp2133> <87y2bh4jg5.fsf@disp2133> <87sg1p4h0g.fsf_-_@disp2133> <20210614141032.GA13677@redhat.com> Date: Mon, 14 Jun 2021 11:37:45 -0500 In-Reply-To: <20210614141032.GA13677@redhat.com> (Oleg Nesterov's message of "Mon, 14 Jun 2021 16:10:33 +0200") Message-ID: <87o8c8tnae.fsf@disp2133> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-XM-SPF: eid=1lspaz-00Bj3q-9Z;;;mid=<87o8c8tnae.fsf@disp2133>;;;hst=in02.mta.xmission.com;;;ip=68.227.160.95;;;frm=ebiederm@xmission.com;;;spf=neutral X-XM-AID: U2FsdGVkX1/3JGSdnkn820cAjJpiknzinMIfCCMTwAM= X-SA-Exim-Connect-IP: 68.227.160.95 X-SA-Exim-Mail-From: ebiederm@xmission.com X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on sa03.xmission.com X-Spam-Level: X-Spam-Status: No, score=-0.2 required=8.0 tests=ALL_TRUSTED,BAYES_50, DCC_CHECK_NEGATIVE,T_TM2_M_HEADER_IN_MSG autolearn=disabled version=3.4.2 X-Spam-Virus: No X-Spam-Report: * -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP * 0.8 BAYES_50 BODY: Bayes spam probability is 40 to 60% * [score: 0.5000] * 0.0 T_TM2_M_HEADER_IN_MSG BODY: No description available. * -0.0 DCC_CHECK_NEGATIVE Not listed in DCC * [sa03 1397; Body=1 Fuz1=1 Fuz2=1] X-Spam-DCC: XMission; sa03 1397; Body=1 Fuz1=1 Fuz2=1 X-Spam-Combo: ;Oleg Nesterov X-Spam-Relay-Country: X-Spam-Timing: total 431 ms - load_scoreonly_sql: 0.04 (0.0%), signal_user_changed: 4.6 (1.1%), b_tie_ro: 3.1 (0.7%), parse: 1.13 (0.3%), extract_message_metadata: 4.2 (1.0%), get_uri_detail_list: 2.0 (0.5%), tests_pri_-1000: 3.1 (0.7%), tests_pri_-950: 1.13 (0.3%), tests_pri_-900: 0.90 (0.2%), tests_pri_-90: 148 (34.4%), check_bayes: 146 (34.0%), b_tokenize: 6 (1.3%), b_tok_get_all: 7 (1.7%), b_comp_prob: 1.85 (0.4%), b_tok_touch_all: 129 (29.9%), b_finish: 0.77 (0.2%), tests_pri_0: 250 (57.9%), check_dkim_signature: 0.38 (0.1%), check_dkim_adsp: 2.4 (0.6%), poll_dns_idle: 0.94 (0.2%), tests_pri_10: 2.9 (0.7%), tests_pri_500: 7 (1.7%), rewrite_mail: 0.00 (0.0%) Subject: Re: [PATCH] coredump: Limit what can interrupt coredumps X-SA-Exim-Version: 4.2.1 (built Sat, 08 Feb 2020 21:53:50 +0000) X-SA-Exim-Scanned: Yes (on in02.mta.xmission.com) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Oleg Nesterov writes: > Eric, et al, sorry for delay, I didn't read emails several days. > > On 06/10, Eric W. Biederman wrote: >> >> v2: Don't remove the now unnecessary code in prepare_signal. > > No, that code is still needed. Otherwise any fatal signal will be > turned into SIGKILL. > >> --- a/fs/coredump.c >> +++ b/fs/coredump.c >> @@ -519,7 +519,7 @@ static bool dump_interrupted(void) >> * but then we need to teach dump_write() to restart and clear >> * TIF_SIGPENDING. >> */ >> - return signal_pending(current); >> + return fatal_signal_pending(current) || freezing(current); >> } > > > Well yes, this is what the comment says. > > But note that there is another reason why dump_interrupted() returns true > if signal_pending(), it assumes thagt __dump_emit()->__kernel_write() may > fail anyway if signal_pending() is true. Say, pipe_write(), or iirc nfs, > perhaps something else... The pipe_write case is a good case to consider. In general filesystems are only allowed to stop if fatal_signal_pending. It is an ancient unix/posix thing. > That is why zap_threads() clears TIF_SIGPENDING. Perhaps it should clear > TIF_NOTIFY_SIGNAL as well and we should change io-uring to not abuse the > dumping threads? I would very much like some clarity on TIF_NOTIFY_SIGNAL. At the very least it would be nice if it could get renamed TIF_NOTIFY_TASK_WORK. I don't know what it has to do with signals. > Or perhaps we should change __dump_emit() to clear signal_pending() and > restart __kernel_write() if it fails or returns a short write. Given that the code needs to handle pipes that seems a reasonable thing to do. Note. All of the blocking of new signals in prepare_signal is still in place. So only a SIGKILL can come in set TIF_SIGPENDING. So I would say that the current fix is correct (and safe to backport). But still requires some magic in prepare_signal until we do more. I don't understand the logic with well enough of adding work to non-io_uring threads with task_work_add to understand why that happens in the first place. There are a lot of silly corners here. Yes please let's keep on digging. Eric