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=-3.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=no 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 2DB73C49EA2 for ; Mon, 21 Jun 2021 18:59:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1A01B60FF2 for ; Mon, 21 Jun 2021 18:59:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231284AbhFUTBa (ORCPT ); Mon, 21 Jun 2021 15:01:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35706 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230189AbhFUTB3 (ORCPT ); Mon, 21 Jun 2021 15:01:29 -0400 Received: from zeniv-ca.linux.org.uk (zeniv-ca.linux.org.uk [IPv6:2607:5300:60:148a::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BB6D2C061574; Mon, 21 Jun 2021 11:59:14 -0700 (PDT) Received: from viro by zeniv-ca.linux.org.uk with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1lvP8P-00AvlT-GG; Mon, 21 Jun 2021 18:59:01 +0000 Date: Mon, 21 Jun 2021 18:59:01 +0000 From: Al Viro To: Linus Torvalds Cc: "Eric W. Biederman" , Michael Schmitz , linux-arch , Jens Axboe , Oleg Nesterov , Linux Kernel Mailing List , Richard Henderson , Ivan Kokshaysky , Matt Turner , alpha , Geert Uytterhoeven , linux-m68k , Arnd Bergmann , Ley Foon Tan , Tejun Heo , Kees Cook Subject: Re: Kernel stack read with PTRACE_EVENT_EXIT and io_uring threads Message-ID: References: <87sg1lwhvm.fsf@disp2133> <6e47eff8-d0a4-8390-1222-e975bfbf3a65@gmail.com> <924ec53c-2fd9-2e1c-bbb1-3fda49809be4@gmail.com> <87eed4v2dc.fsf@disp2133> <5929e116-fa61-b211-342a-c706dcb834ca@gmail.com> <87fsxjorgs.fsf@disp2133> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Sender: Al Viro Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jun 21, 2021 at 01:54:56PM +0000, Al Viro wrote: > On Tue, Jun 15, 2021 at 02:58:12PM -0700, Linus Torvalds wrote: > > > And I think our horrible "kernel threads return to user space when > > done" is absolutely horrifically nasty. Maybe of the clever sort, but > > mostly of the historical horror sort. > > How would you prefer to handle that, then? Separate magical path from > kernel_execve() to switch to userland? We used to have something of > that sort, and that had been a real horror... > > As it is, it's "kernel thread is spawned at the point similar to > ret_from_fork(), runs the payload (which almost never returns) and > then proceeds out to userland, same way fork(2) would've done." > That way kernel_execve() doesn't have to do anything magical. > > Al, digging through the old notes and current call graph... There's a large mess around do_exit() - we have a bunch of callers all over arch/*; if nothing else, I very much doubt that really want to let tracer play with a thread in the middle of die_if_kernel() or similar. We sure as hell do not want to arrange for anything on the kernel stack in such situations, no matter what's done in exit(2)...