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=-15.3 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_SANE_1 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 06576C48BCF for ; Sat, 12 Jun 2021 16:27:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id CA87461376 for ; Sat, 12 Jun 2021 16:27:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231341AbhFLQ2n (ORCPT ); Sat, 12 Jun 2021 12:28:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54052 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230200AbhFLQ2m (ORCPT ); Sat, 12 Jun 2021 12:28:42 -0400 Received: from mail-pg1-x52a.google.com (mail-pg1-x52a.google.com [IPv6:2607:f8b0:4864:20::52a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 551AFC061574 for ; Sat, 12 Jun 2021 09:26:42 -0700 (PDT) Received: by mail-pg1-x52a.google.com with SMTP id o9so5082290pgd.2 for ; Sat, 12 Jun 2021 09:26:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel-dk.20150623.gappssmtp.com; s=20150623; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=MQ1mPpuRuVxBspdvy6UzAnzpaI1Bxq3sd+5iifYVq6M=; b=X1c1dzhdcdE+0uP5L4BSVnCnYq5Podggz2EG34RYS8+w2Ggp6ZGGj4wzWuoyVVzZnP z69HttbHn0Bx/ntjUOHEwgY1REmy/VrDtHTD0s/N6hu4w3yV3AJ05eAoVZfW7soX10dX asFe552tpzR1D74iZpoxDbDf/x//1LJZkpNQaoAOrDrM2i8hIExDOBXCqxhrjchmXHDC BQS1bqsoLyGLwmukVEilDkksMmP3CCdlMrwo8rIzc1NKJ2tRBw9tnQmFq0qW9z57JcXw 2iWjOcdz6e+nVFdSAfl6oecl9h36QWbVak5hYYnZBXCJvNRUTW4YyFQN3/EvQzpJr2CG vLzw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=MQ1mPpuRuVxBspdvy6UzAnzpaI1Bxq3sd+5iifYVq6M=; b=kTNg/TJNMhdpLZ6whxTMbzk6PFwC6kcUVeF+1I4t3WpVrEvojzr4DfQEsztT7obBlW J8e32btJy23Q3dg/0HeFSoEjmXpcb7IDbPnjbDvxlSO+1eKzNIjbg2UlhaMWRcQZAOqD ZYvwZ0iZSW78vHppsaZc48yTv0BORSVBy4oBb2e23jAep57ywiMFYozX9su6KUCRr3OU 2AA4sIly5cjAwaGsZ/1iJkSjz/j7iwXZAZmyKzf/jvPEKn9kNlq43YcaGGoybpUJ15si proqITqmx0I2RJK1ZE6C5AsH1Y418Lg0TIqH1F2MWVAOdkzW+F+p7b3uAr3fpcHdBWu/ Pw1A== X-Gm-Message-State: AOAM533q05FOCRnZHE7YMOGEipKScf3whY00K/MYOGjcJPZCO7xyrGdA FnXrpYEh/TXmE3Mi28f5KT2eHQ== X-Google-Smtp-Source: ABdhPJyy1n778pYdAk3+Hs5II6u5ygH2NnqoKQwbqwRgPrpopuaXT7omTPwdMCEDxqfglx6JblgSRQ== X-Received: by 2002:aa7:9706:0:b029:2f2:4481:1e17 with SMTP id a6-20020aa797060000b02902f244811e17mr13862002pfg.53.1623515197779; Sat, 12 Jun 2021 09:26:37 -0700 (PDT) Received: from [192.168.4.41] (cpe-72-132-29-68.dc.res.rr.com. [72.132.29.68]) by smtp.gmail.com with ESMTPSA id w79sm8603030pff.21.2021.06.12.09.26.35 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 12 Jun 2021 09:26:37 -0700 (PDT) Subject: Re: [PATCH] coredump: Limit what can interrupt coredumps To: Olivier Langlois , "Eric W. Biederman" , Linus Torvalds Cc: Linux Kernel Mailing List , linux-fsdevel , io-uring , Alexander Viro , "Pavel Begunkov>" , Oleg Nesterov References: <192c9697e379bf084636a8213108be6c3b948d0b.camel@trillion01.com> <9692dbb420eef43a9775f425cb8f6f33c9ba2db9.camel@trillion01.com> <87h7i694ij.fsf_-_@disp2133> <198e912402486f66214146d4eabad8cb3f010a8e.camel@trillion01.com> <87eeda7nqe.fsf@disp2133> <87pmwt6biw.fsf@disp2133> <87czst5yxh.fsf_-_@disp2133> <87y2bh4jg5.fsf@disp2133> <87sg1p4h0g.fsf_-_@disp2133> <9628ac27c07db760415d382e26b5a0ced41f5851.camel@trillion01.com> From: Jens Axboe Message-ID: <0fce1bd7-172c-84c6-915f-9cc2a45543a9@kernel.dk> Date: Sat, 12 Jun 2021 10:26:35 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: <9628ac27c07db760415d382e26b5a0ced41f5851.camel@trillion01.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 6/12/21 8:36 AM, Olivier Langlois wrote: > On Thu, 2021-06-10 at 15:11 -0500, Eric W. Biederman wrote: >> >> Olivier Langlois has been struggling with coredumps being incompletely >> written in >> processes using io_uring. >> >> Olivier Langlois writes: >>> io_uring is a big user of task_work and any event that io_uring made >>> a >>> task waiting for that occurs during the core dump generation will >>> generate a TIF_NOTIFY_SIGNAL. >>> >>> Here are the detailed steps of the problem: >>> 1. io_uring calls vfs_poll() to install a task to a file wait queue >>>    with io_async_wake() as the wakeup function cb from >>> io_arm_poll_handler() >>> 2. wakeup function ends up calling task_work_add() with TWA_SIGNAL >>> 3. task_work_add() sets the TIF_NOTIFY_SIGNAL bit by calling >>>    set_notify_signal() >> >> The coredump code deliberately supports being interrupted by SIGKILL, >> and depends upon prepare_signal to filter out all other signals.   Now >> that signal_pending includes wake ups for TIF_NOTIFY_SIGNAL this hack >> in dump_emitted by the coredump code no longer works. >> >> Make the coredump code more robust by explicitly testing for all of >> the wakeup conditions the coredump code supports.  This prevents >> new wakeup conditions from breaking the coredump code, as well >> as fixing the current issue. >> >> The filesystem code that the coredump code uses already limits >> itself to only aborting on fatal_signal_pending.  So it should >> not develop surprising wake-up reasons either. >> >> v2: Don't remove the now unnecessary code in prepare_signal. >> >> Cc: stable@vger.kernel.org >> Fixes: 12db8b690010 ("entry: Add support for TIF_NOTIFY_SIGNAL") >> Reported-by: Olivier Langlois >> Signed-off-by: "Eric W. Biederman" >> --- >>  fs/coredump.c | 2 +- >>  1 file changed, 1 insertion(+), 1 deletion(-) >> >> diff --git a/fs/coredump.c b/fs/coredump.c >> index 2868e3e171ae..c3d8fc14b993 100644 >> --- 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); >>  } >>   >>  static void wait_for_dump_helpers(struct file *file) > > Tested-by: Olivier Langlois Thanks Olivier and Eric for taking care of this. I've been mostly offline for more than a week, back at it next week. -- Jens Axboe