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 45D76C48BE8 for ; Tue, 15 Jun 2021 19:32:00 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 212DB60E0C for ; Tue, 15 Jun 2021 19:32:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230267AbhFOTeD (ORCPT ); Tue, 15 Jun 2021 15:34:03 -0400 Received: from out03.mta.xmission.com ([166.70.13.233]:53420 "EHLO out03.mta.xmission.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229749AbhFOTeC (ORCPT ); Tue, 15 Jun 2021 15:34:02 -0400 Received: from in02.mta.xmission.com ([166.70.13.52]) by out03.mta.xmission.com with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.93) (envelope-from ) id 1ltEmu-007YGd-82; Tue, 15 Jun 2021 13:31:52 -0600 Received: from ip68-227-160-95.om.om.cox.net ([68.227.160.95] helo=email.xmission.com) by in02.mta.xmission.com with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.93) (envelope-from ) id 1ltEmt-00FC9o-1T; Tue, 15 Jun 2021 13:31:51 -0600 From: ebiederm@xmission.com (Eric W. Biederman) To: Michael Schmitz Cc: Linus Torvalds , linux-arch , Jens Axboe , Oleg Nesterov , Al Viro , Linux Kernel Mailing List , Richard Henderson , Ivan Kokshaysky , Matt Turner , alpha , Geert Uytterhoeven , linux-m68k , Arnd Bergmann , Ley Foon Tan , Tejun Heo , Kees Cook In-Reply-To: <5929e116-fa61-b211-342a-c706dcb834ca@gmail.com> (Michael Schmitz's message of "Tue, 15 Jun 2021 10:26:33 +1200") References: <87sg1p30a1.fsf@disp2133> <87pmwsytb3.fsf@disp2133> <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> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux) Date: Tue, 15 Jun 2021 14:30:59 -0500 Message-ID: <87fsxjorgs.fsf@disp2133> MIME-Version: 1.0 Content-Type: text/plain X-XM-SPF: eid=1ltEmt-00FC9o-1T;;;mid=<87fsxjorgs.fsf@disp2133>;;;hst=in02.mta.xmission.com;;;ip=68.227.160.95;;;frm=ebiederm@xmission.com;;;spf=neutral X-XM-AID: U2FsdGVkX18kd161ANp8gAbkjGsKS094xb9QyLKgQ0I= X-SA-Exim-Connect-IP: 68.227.160.95 X-SA-Exim-Mail-From: ebiederm@xmission.com Subject: Re: Kernel stack read with PTRACE_EVENT_EXIT and io_uring threads X-SA-Exim-Version: 4.2.1 (built Sat, 08 Feb 2020 21:53:50 +0000) X-SA-Exim-Scanned: Yes (on in02.mta.xmission.com) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Michael Schmitz writes: > Hi Eric, > > On 15/06/21 4:26 am, Eric W. Biederman wrote: >> Michael Schmitz writes: >> >>> On second thought, I'm not certain what adding another empty stack frame would >>> achieve here. >>> >>> On m68k, 'frame' already is a new stack frame, for running the new thread >>> in. This new frame does not have any user context at all, and it's explicitly >>> wiped anyway. >>> >>> Unless we save all user context on the stack, then push that context to a new >>> save frame, and somehow point get_signal to look there for IO threads >>> (essentially what Eric suggested), I don't see how this could work? >>> >>> I must be missing something. >> It is only designed to work well enough so that ptrace will access >> something well defined when ptrace accesses io_uring tasks. >> >> The io_uring tasks are special in that they are user process >> threads that never run in userspace. So as long as everything >> ptrace can read is accessible on that process all is well. > OK, I'm testing a patch that would save extra context in sys_io_uring_setup, > which ought to ensure that for m68k. I had to update ret_from_kernel_thread to pop that state to get Linus's change to boot. Apparently kernel_threads exiting needs to be handled. >> Having stared a bit longer at the code I think the short term >> fix for both of PTRACE_EVENT_EXIT and io_uring is to guard >> them both with CONFIG_HAVE_ARCH_TRACEHOOK. Which does not work because nios2 which looks susceptible sets CONFIG_HAVE_ARCH_TRACEHOOK. A further look shows that there is also PTRACE_EVENT_EXEC that needs to be handled so execve and execveat need to be wrapped as well. Do you happen to know if there is userspace that will run in qemu-system-m68k that can be used for testing? Eric