Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp4054757pxj; Mon, 21 Jun 2021 12:25:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzO0FI5U+aNNjUY1sPGVDMTqRnBf6+8F6U1wwFqMmeT9fnMaHpB2aMY3RYNgkeegoBVuBLr X-Received: by 2002:aa7:d34f:: with SMTP id m15mr3015035edr.311.1624303546316; Mon, 21 Jun 2021 12:25:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624303546; cv=none; d=google.com; s=arc-20160816; b=ck+UZ7MD8OPcI3n7s2roVfr6Fy/yMnDIVbH/JrxebSeMJZ955LSbqsz1DoIe3319Mw WlK0ods30SagtAUEKsCrplTM/rYbUDaMiYeriW77sBn8sBS8vhG9KtlOvvv3IKlTr7fy eU0P1U7/JP+jXlz5nzg6QLVI2GubXDc7/8S6WROSuh+SCsc9h87n9NGmgtdjyL7tFFfp l1nW4NgJS3t4FAsk4pXSGr3imyBrFX9T8KZFqO8zKp6mWy9/UwOGrFPrm3ATlGxU9Fkw PoNFQpIJVrwXfZs7HjabxSkq25naRgWdKxexaZkDB5FXu8tM+96jSkZZeYfW++KQsQiz 43wQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=9EgTWT+k19GO01aTDHUiLhzy964hCzl+TMGFBgMJHcA=; b=DqFVmsUKC+WqelvhjjGFjR2Eco/dL+Dw1S6ZAsaZWw2SvqwyFSO6Z6w/hdmTpgT469 8B83QgukHHftZGX2ECTAszopRWyzgMAMBDl3oVNXXgu0QHJQrTZweA1uckesUyZQ7arw fYnlB7P8hIUSzn8fEg6cujpUPJTUn9Rtot7AVVKgEqCFZS98sFoAYRCkx9OJR1DZWWe6 7TQDLXYVvSmIaUjwF9JLDCEWRqpKhNlcHz2rzGn/cWhYNH/8nOT1Anc2hGe2a5KP/T2p zY1qbuTMW7M0HZs6cy53/EtLiBwuiEKy89HyKBVYqFQIH4MqaqgjrGhC169ozxtTlKcp uLpw== 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 rn4si256318ejb.426.2021.06.21.12.25.24; Mon, 21 Jun 2021 12:25:46 -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 S230343AbhFUT0o (ORCPT + 99 others); Mon, 21 Jun 2021 15:26:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41316 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230052AbhFUT0n (ORCPT ); Mon, 21 Jun 2021 15:26:43 -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 44AD6C061574; Mon, 21 Jun 2021 12:24:29 -0700 (PDT) Received: from viro by zeniv-ca.linux.org.uk with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1lvPWt-00Aw2Y-H5; Mon, 21 Jun 2021 19:24:19 +0000 Date: Mon, 21 Jun 2021 19:24:19 +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 06:59:01PM +0000, Al Viro wrote: > 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)... FWIW, on alpha it's die_if_kernel(), do_entUna() and do_page_fault(), all in not-from-userland cases. On m68k - die_if_kernel(), do_page_fault() (both for non-from-userland cases) and something really odd - fpsp040_die(). Exception handling for floating point stuff on 68040? Looks like it has an open-coded copy_to_user()/copy_from_user(), with faults doing hard do_exit(SIGSEGV) instead of raising a signal and trying to do something sane... I really don't want to try and figure out how painful would it be to teach that code how to deal with faults - _testing_ anything in that area sure as hell will be. IIRC, details of recovery from FPU exceptions on 68040 in the manual left impression of a minefield...