Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp1921569pxj; Fri, 18 Jun 2021 20:43:26 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzsahvfxFj2UKENohqKXdD9XC35qFsfeD4Lg5eSH83v77uZnbrnKFrQrgAkg9JOU+ixDVVk X-Received: by 2002:a5d:8b03:: with SMTP id k3mr10422069ion.203.1624074206262; Fri, 18 Jun 2021 20:43:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624074206; cv=none; d=google.com; s=arc-20160816; b=y/dJSwHYbFvvDWqX3wCQv9a38WxH5mEp04DDtcawOCKAMCKNHAPfDp38XXJi8morE6 65UXlfBYW0/czPF+ng1xpJex4vki3DCSy1akWrTWUzPMC1u+z1pjSsTZDK25znQhXGaZ 5VNGQqiHlhPnNOp8ZtWI7QrwLDZH/FfIJeqxucVTSXRcMwDQFBkk52MeElaRZlMaYGAQ tyQEDJsuEYdta+LHCKxlqABy1oYYeyL/ItKxFdTTW2RL8pmEGSYov6nZGU/rW4Gz3tFU qR8aSga3fictvvcM9Lz25NOIX6Q+xtQ43aZE0ZkLF31LEH7HGGKVUiaBsLlgrUwAUULR OSvA== 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=heMx0R9Qo+oDrcWk3xae0K5szD8+IbBfsvO0hlupk9k=; b=x1tYp8UzMEFtMIAeXp8e/L+oz7vr+OheUldRzHW8ZZQoytRKlStzrQYqlNiQiebkvK tkLcsqVvZ6RBcfx/E2Po1JDBNttBVeyP+bhiEula8j23Cp/B0KRuL4+jJJG08//CWoDf fQ1uTZjM/Dxq+BkJgcU+SilmeAU4VLWHsJWrCZqaFPj+h6SjgiapemIqsCKgc90gXE86 Yz0teqce1IJZpIB8lK7uDpkiWpD3Kc9s+UQuJu6fdZE855XFu+WZxHTf6rZzp45mNuIt ASuI+iIroATMaHv6shxzCUn7bm05IwP25UV+OszJLF4aosIInn8Jv8yOhje6aneYE+iE PEPQ== 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 q5si4421990jat.33.2021.06.18.20.43.14; Fri, 18 Jun 2021 20:43:26 -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 S232090AbhFRUHv (ORCPT + 99 others); Fri, 18 Jun 2021 16:07:51 -0400 Received: from cloud48395.mywhc.ca ([173.209.37.211]:55278 "EHLO cloud48395.mywhc.ca" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229768AbhFRUHu (ORCPT ); Fri, 18 Jun 2021 16:07:50 -0400 Received: from modemcable064.203-130-66.mc.videotron.ca ([66.130.203.64]:33072 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 1luKkD-0008K1-VF; Fri, 18 Jun 2021 16:05:38 -0400 Message-ID: Subject: Re: [PATCH] coredump: Limit what can interrupt coredumps From: Olivier Langlois To: "Eric W. Biederman" Cc: Oleg Nesterov , Linus Torvalds , Linux Kernel Mailing List , linux-fsdevel , io-uring , Alexander Viro , Jens Axboe , "Pavel Begunkov>" Date: Fri, 18 Jun 2021 16:05:36 -0400 In-Reply-To: <87v96dd1gz.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> <4163ed48afbcb1c288b366fe2745205cd66bea3d.camel@trillion01.com> <87v96dd1gz.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 Wed, 2021-06-16 at 15:00 -0500, Eric W. Biederman wrote: > Olivier Langlois writes: > > > 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. > > Thank you for confirming that. > > Do you know how your test program is using io_uring? > > I have been trying to put the pieces together on what io_uring is > doing > that stops the coredump.? The fact that it takes a little while > before > it kills the coredump is a little puzzling.? The code looks like all > of > the io_uring operations should have been canceled before the coredump > starts. > > With a very simple setup, I guess that this could easily be reproducible. Make a TCP connection with a server that is streaming non-stop data and enter a loop where you keep initiating async OP_IOURING_READ operations on your TCP fd. Once you have that, manually sending a SIG_SEGV is a sure fire way to stumble into the problem. This is how I am testing the patches. IRL, it is possible to call io_uring_enter() to submit operations and return from the syscall without waiting on all events to have completed. Once the process is back in userspace, if it stumble into a bug that triggers a coredump, any remaining pending I/O operations can set TIF_SIGNAL_NOTIFY while the coredump is generated. I have read the part of your previous email where you share the result of your ongoing investigation. I didn't comment as the definitive references in io_uring matters are Jens and Pavel but I am going to share my opinion on the matter. I think that you did put the finger on the code cleaning up the io_uring instance in regards to pending operations. It seems to be io_uring_release() which is probably called from exit_files() which happens to be after the call to exit_mm(). At first, I did entertain the idea of considering if it could be possible to duplicate some of the operations performed by io_uring_release() related to the infamous TIF_SIGNAL_NOTIFY setting into io_uring_files_cancel() which is called before exit_mm(). but the idea is useless as it is not the other threads of the group that are causing the TIF_SIGNAL_NOTIFY problem. It is the thread calling do_coredump() which is done by the signal handing code even before that thread enters do_exit() and start to be cleaned up. That thread when it enters do_coredump() is still fully loaded and operational in terms of io_uring functionality. I guess that this io_uring cancel all pending operations hook would have to be called from do_coredump or from get_signal() but if it is the way to go, I feel that this is a change major enough that wouldn't dare going there without the blessing of the maintainers in cause....