Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp4081657pxj; Tue, 15 Jun 2021 15:09:31 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyM3ogtQHX8v7BKpu1m8nfT2T8FuWmNa+8oFtBLItWPwdFvAmnHOAjx4DeIxeh/bayR7I5J X-Received: by 2002:a17:906:c293:: with SMTP id r19mr1799560ejz.252.1623794971168; Tue, 15 Jun 2021 15:09:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623794971; cv=none; d=google.com; s=arc-20160816; b=noSLoBOYF1VQCLuvMCgE88onoEVIAvhcqZb3vkJCGAf9loeyNnJfM3s4dPFcxZTyd4 IxOZPbz0cp5PE+SxCXhIGpBB22+M0dOoawzNh6DoZPdsqkH11ofkh+aD4HeV+q7GvIah 8Cg+6DlX9dPoUe8STSV6WZmLSwjA9bV5gHSvvphSi4VsT8Ushd9C9AVtW3asi5gGRYlN MTxPyXMidPY5B5P0zUTAxrMcXqHq/GFAQdw8Mfb3lRbDyb0GB8aIp56h4gRVGIJX/3Rj Mk7iCtx41mj9mpAjTRIdcfxPMqV4O7rfgqNZtlhtEUb2SK8cvjGrQd30Pj2VA3TYd2iE nFeg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=0l26BC8IhPfrvU9uGo+au3BoxNgDLxCiG8UoyUZG3Ik=; b=ZfYHtcjYp+nA2HjXgoV+lYPuNN9+w2b6PA74/Ht9cQCqWH/lke34sda8LyXmLOJTpi kUHE6YWm1QtJ2xFRA9PMLHe+5k772O/mOIwzFRnKS0sLAm1KaCD983ffNTzPlzpoqBT4 l/CJaa4tQ29X8JQBcOlwldDQfT+xMmJZNSjvjjdVGnCP7SSIBiVfgSqNfVgPU4D59HF/ 6xoX19Vsye5BO/jeeXFYWgCkyCwqhpB2Ro5fO/vFnXVGsXDBQUx2utUueoHI8oVhv4mb 2L4B/dclwk+49OGKbI9iJbzJWXgHMkLuzoH79R88Yx1+ozCGcYcnkzUipLCFQeEl3+3j ErgA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=google header.b=TFaqMa9t; 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 j6si189540ejo.589.2021.06.15.15.09.06; Tue, 15 Jun 2021 15:09:31 -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; dkim=pass header.i=@linux-foundation.org header.s=google header.b=TFaqMa9t; 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 S229918AbhFOWHV (ORCPT + 99 others); Tue, 15 Jun 2021 18:07:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58228 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229601AbhFOWHU (ORCPT ); Tue, 15 Jun 2021 18:07:20 -0400 Received: from mail-ej1-x629.google.com (mail-ej1-x629.google.com [IPv6:2a00:1450:4864:20::629]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8E1DEC061574 for ; Tue, 15 Jun 2021 15:05:15 -0700 (PDT) Received: by mail-ej1-x629.google.com with SMTP id og14so255253ejc.5 for ; Tue, 15 Jun 2021 15:05:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=0l26BC8IhPfrvU9uGo+au3BoxNgDLxCiG8UoyUZG3Ik=; b=TFaqMa9trH0+DcltUOWD9SDg1O0XP/L7I2lYUz0Glh+HYXXZcxcD6sfjwxWfuZY+Ok eLw6VyrExA7gBNmYpfm8IdtmzqFEznbO1gHxDtyivDlT8jzLszkwtH4h94NAyR3n3R/V cMVr5dZELWDG4zkytARwyq6x21dhxpBfi5ra4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=0l26BC8IhPfrvU9uGo+au3BoxNgDLxCiG8UoyUZG3Ik=; b=EFE0tQMeAEsYIVxyo6W1kqbXto6dHb9Ooz87Q+SxHTWqLtyV58bXht4SRTzDhytWzQ tESycsNwqpSXJUGWgU2wHD9Xp9xEBKaQ45JCiUlmR3hqOKonUCNw+sE1R5qxjvtN0+pw arg5oSWZKL17EyzIaUbjXFB9mPN6v4ZuaE91new8yNjrzhEe1KtWxFhv/N8yzF2eKrjv oL9d+zLtOKs81ZCt1JFIFGeiqOFwzIYQH2vKYT5gJSHQNnLyZNePzIgDZ1x6fU0wbFig XvxLHGEY3FwXkXdwB8vGNoSmFVQKvdTNV8V3T+FmZy7ngve95w9Dol7pq7xE/8ka5Irh A2DA== X-Gm-Message-State: AOAM530IeMaU2VwJmRQUutdR36HEdHglbV7VArWgEQvn0LTTsqdtfg6/ fxQ5lv9E70nwxB2lHmuB0AXbqJvmvRkU6hKyXBM= X-Received: by 2002:a17:906:f289:: with SMTP id gu9mr1697268ejb.157.1623794713924; Tue, 15 Jun 2021 15:05:13 -0700 (PDT) Received: from mail-ej1-f53.google.com (mail-ej1-f53.google.com. [209.85.218.53]) by smtp.gmail.com with ESMTPSA id e6sm199811edk.63.2021.06.15.15.05.13 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 15 Jun 2021 15:05:13 -0700 (PDT) Received: by mail-ej1-f53.google.com with SMTP id k25so220741eja.9 for ; Tue, 15 Jun 2021 15:05:13 -0700 (PDT) X-Received: by 2002:ac2:43b9:: with SMTP id t25mr1069877lfl.253.1623794308417; Tue, 15 Jun 2021 14:58:28 -0700 (PDT) MIME-Version: 1.0 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> <87fsxjorgs.fsf@disp2133> In-Reply-To: <87fsxjorgs.fsf@disp2133> From: Linus Torvalds Date: Tue, 15 Jun 2021 14:58:12 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: Kernel stack read with PTRACE_EVENT_EXIT and io_uring threads To: "Eric W. Biederman" Cc: Michael Schmitz , 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 Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jun 15, 2021 at 12:32 PM Eric W. Biederman wrote: > > 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. You are very right. That, btw, seems to be a horrible design mistake, but I think it's how "kernel_execve()" works - both for the initial "init", but also for user-mode helper processes. Both of those cases do "kernel_thread()" to create a new thread, and then that new kernel thread does kernel_execve() to create the user space image for that thread. And that act of "execve()" clears PF_KTHREAD from the thread, and then the final return from the kernel thread function returns to that new user space. Or something like that. It's been ages since I looked at that code, and your patch initially confused the heck out of me because I went "that can't _possibly_ be needed". But yes, I think your patch is right. 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. Or am I mis-rememberting how this ends up working? Did you look at exactly what it was that returned from kernel threads? This might be worth commenting on somewhere. But your patch for alpha looks correct to me. Did you have some test-case to verify ptrace() on io worker threads? Linus