Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp59434pxj; Wed, 16 Jun 2021 20:15:47 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyoP8LUjrvlPAqk/Pt890yca7ScBROXcEC5TQhqBYahS/Htwvjo0LbFhDx9JLWBHXOHOKCz X-Received: by 2002:a02:956a:: with SMTP id y97mr2402105jah.58.1623899747396; Wed, 16 Jun 2021 20:15:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623899747; cv=none; d=google.com; s=arc-20160816; b=bvqx5rFm6Q+m8jjSwLzMfL71ebwdubprMu4HsStjovS52dNeli3URqLWbOQcRx/asR J5oKu9h9SBVzWTM+izf1WXWx15sN8qQC/840GifSVjR61eHZ8m5RKrWxW0+S96vq5rsu 4VcyJe/UT497rhZyVx6JMuO8hd3FJpcWLseABZH/M9PK0JHm8uQt8TrLlju1QBmthHaI 0n7whEqAj7M+5oVMy8A3Yu+3fpyIrd6m0dOn2jMMr3VUe/AAZCf1AyyVKf4os77Q3XEg 7vZOnmBotb/lBgCKpDHxkrWGpfjpgt9tUPYgT2hmzNrgrMaY6e0o5wfyXED/SSUh3buT 5+FQ== 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:organization:references:in-reply-to:date:cc:to:from :subject:message-id; bh=mXGng22TY64HlRlA5E+lBW/bqIrgQqRrtZsjekxCjP0=; b=uAf+QbKleDgI8nlZVmcgEI9tQKR4T8NJPStGPFEduRiuMUFzlWlK/kzisxGC3awwKh PNKPZvSzejqZUtzknF2aNSbDdTAJCludN3QJBuiaddZZHgpqwvbg6Ew827DRUL6A/WS3 lk2JPxxI//dfrD9fSxRO9hbQLC0g2Hw+QuPmpYxRruuuDtp0hpTMSY2mNXRd4JSL4SCK 9w774OXEIUYNPHvTA2Ym1HCd1VKlibqCRiUFXfmMh2RICNqyvcxiQpg+CPhYbZC3uCEr 7ADkS1G7hMu+Uz8lqGOYCAzhH/MlAt7iCfupvbe5Sw2gy6caqwqywb8fh2mp2483DAGa NUWw== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id q4si5008898jaj.46.2021.06.16.20.15.35; Wed, 16 Jun 2021 20:15:47 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232725AbhFPTZY (ORCPT + 99 others); Wed, 16 Jun 2021 15:25:24 -0400 Received: from cloud48395.mywhc.ca ([173.209.37.211]:58004 "EHLO cloud48395.mywhc.ca" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232670AbhFPTZX (ORCPT ); Wed, 16 Jun 2021 15:25:23 -0400 Received: from modemcable064.203-130-66.mc.videotron.ca ([66.130.203.64]:32882 helo=[192.168.1.179]) by cloud48395.mywhc.ca with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1ltb88-0000z6-2x; Wed, 16 Jun 2021 15:23:16 -0400 Message-ID: <4163ed48afbcb1c288b366fe2745205cd66bea3d.camel@trillion01.com> Subject: Re: [PATCH] coredump: Limit what can interrupt coredumps From: Olivier Langlois To: "Eric W. Biederman" , Oleg Nesterov Cc: Linus Torvalds , Linux Kernel Mailing List , linux-fsdevel , io-uring , Alexander Viro , Jens Axboe , "Pavel Begunkov>" Date: Wed, 16 Jun 2021 15:23:14 -0400 In-Reply-To: <87pmwmn5m0.fsf@disp2133> References: <198e912402486f66214146d4eabad8cb3f010a8e.camel@trillion01.com> <87eeda7nqe.fsf@disp2133> <87pmwt6biw.fsf@disp2133> <87czst5yxh.fsf_-_@disp2133> <87y2bh4jg5.fsf@disp2133> <87sg1p4h0g.fsf_-_@disp2133> <20210614141032.GA13677@redhat.com> <87pmwmn5m0.fsf@disp2133> Organization: Trillion01 Inc Content-Type: text/plain; charset="ISO-8859-1" User-Agent: Evolution 3.40.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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-kernel@vger.kernel.org On Tue, 2021-06-15 at 17:08 -0500, Eric W. Biederman wrote: > Oleg Nesterov writes: > > > > --- 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... > > > > 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? > > > > Or perhaps we should change __dump_emit() to clear signal_pending() > > and > > restart __kernel_write() if it fails or returns a short write. > > > > Otherwise the change above doesn't look like a full fix to me. > > Agreed.? The coredump to a pipe will still be short.? That needs > something additional. > > The problem Olivier Langlois reported was > core dumps coming up short because TIF_NOTIFY_SIGNAL was being > set during a core dump. > > We can see this with pipe_write returning -ERESTARTSYS > on a full pipe if signal_pending which includes TIF_NOTIFY_SIGNAL > is true. > Eric, I redid my test but this time instead of dumping directly into a file, I did let the coredump be piped to the systemd coredump module and the coredump generation isn't working as expected when piping. So your code review conclusions are correct.