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 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 76CE6C433F5 for ; Mon, 27 Sep 2021 09:04:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5FEDB60F24 for ; Mon, 27 Sep 2021 09:04:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233597AbhI0JFs (ORCPT ); Mon, 27 Sep 2021 05:05:48 -0400 Received: from foss.arm.com ([217.140.110.172]:34674 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233519AbhI0JFr (ORCPT ); Mon, 27 Sep 2021 05:05:47 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id CF478D6E; Mon, 27 Sep 2021 02:04:09 -0700 (PDT) Received: from C02TD0UTHF1T.local (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id EA6D03F70D; Mon, 27 Sep 2021 02:04:04 -0700 (PDT) Date: Mon, 27 Sep 2021 10:03:51 +0100 From: Mark Rutland To: Kees Cook Cc: Vito Caputo , Jann Horn , Thomas Gleixner , Josh Poimboeuf , Ingo Molnar , Borislav Petkov , "H. Peter Anvin" , Jens Axboe , Peter Zijlstra , Stefan Metzmacher , Andy Lutomirski , Lai Jiangshan , Christian Brauner , Andrew Morton , "Kenta.Tada@sony.com" , Daniel Bristot de Oliveira , Michael =?utf-8?B?V2Vpw58=?= , Anand K Mistry , Alexey Gladkov , Michal Hocko , Helge Deller , Dave Hansen , Andrea Righi , Ohhoon Kwon , Kalesh Singh , YiFei Zhu , "Eric W. Biederman" , linux-kernel@vger.kernel.org, x86@kernel.org, linux-fsdevel@vger.kernel.org, linux-hardening@vger.kernel.org Subject: Re: [PATCH] proc: Disable /proc/$pid/wchan Message-ID: <20210927090337.GB1131@C02TD0UTHF1T.local> References: <20210923233105.4045080-1-keescook@chromium.org> <20210923234917.pqrxwoq7yqnvfpwu@shells.gnugeneration.com> <20210924002230.sijoedia65hf5bj7@shells.gnugeneration.com> <202109231814.FD09DBAD3@keescook> <20210924135424.GA33573@C02TD0UTHF1T.local> <202109240716.A0792BE46@keescook> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <202109240716.A0792BE46@keescook> Precedence: bulk List-ID: X-Mailing-List: linux-hardening@vger.kernel.org On Fri, Sep 24, 2021 at 07:26:22AM -0700, Kees Cook wrote: > On Fri, Sep 24, 2021 at 02:54:24PM +0100, Mark Rutland wrote: > > On Thu, Sep 23, 2021 at 06:16:16PM -0700, Kees Cook wrote: > > > On Thu, Sep 23, 2021 at 05:22:30PM -0700, Vito Caputo wrote: > > > > Instead of unwinding stacks maybe the kernel should be sticking an > > > > entrypoint address in the current task struct for get_wchan() to > > > > access, whenever userspace enters the kernel? > > > > > > wchan is supposed to show where the kernel is at the instant the > > > get_wchan() happens. (i.e. recording it at syscall entry would just > > > always show syscall entry.) > > > > It's supposed to show where a blocked task is blocked; the "wait > > channel". > > > > I'd wanted to remove get_wchan since it requires cross-task stack > > walking, which is generally painful. > > Right -- this is the "fragile" part I'm worried about. > > > We could instead have the scheduler entrypoints snapshot their caller > > into a field in task_struct. If there are sufficiently few callers, that > > could be an inline wrapper that passes a __func__ string. Otherwise, we > > still need to symbolize. > > Hmm. Does PREEMPT break this? Within the core scheduler functions interrupts should be disabled, and as long as we only update task_struct there we shouldn't have a race. > Can we actually use __builtin_return_address(0) in __schedule? We'd need to do this in a few entry points above __schedule, since the currently get_wchan walks until !in_sched_functions(). It should be possible, though we might need to make sure those the nexus points aren't inlined. Thanks, Mark.