Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp3771693pxb; Mon, 27 Sep 2021 02:06:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy0gK2jk6vYBe4baOimdc09r0eTc9K0XJQPbssUvMtvqGKp1qBn+t0mC79E4EXzBQ35Ua8N X-Received: by 2002:a17:90a:fc1:: with SMTP id 59mr1266334pjz.233.1632733598092; Mon, 27 Sep 2021 02:06:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632733598; cv=none; d=google.com; s=arc-20160816; b=YSfZBtydbDNjJlC9GggrS0zQLNEe0/ObgveSGsjXBtvzQorfAZ+GMzMv1M4JEWksX7 OdYQLbTGHg7oisC5twLNVmfP4WlDRbaAQciW/wSbaBmQlYu7e2qNjUwWqwJQCsq6/Chi 8Ycumw1y5fplPbto9X63mFcBPZOfJoAv0MRejVCf8/82GBm7gBvXlVc9t+g8H7oGKq78 ZTWUhHw9LXy81mgO9fDxKVTV8bv89RWOZPmfONaRkc6QSdRdYhyUS5IbLkajaZiWIqJN JI929S2In30Y0CWaZXEMi18vXanp2wDXXrrcOAZI2KMO6dVcFGZhQZKQ0VS7v/CFrwdM ODvA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=ksZ3VzBkJ2R1Vexas+OW1lBDS6fRycXx0Yzx8Ul+rIo=; b=nm/6Tbv0YasDK8qd0TJml5WSRKB84lipaN9NifH98dlxhn56PCLlVXBMm68IwZOvm5 OPWdKdQqKjPL8BUXm2qriLFXTiCudTNJdm/bs9Rv7/lrF4lDDVRRlqFX/dh5ZGNLRT0k DYdmrtdjjijbcPa031sauwypB86cwRmj31kUjQH4HZQ8k4/Y6wpUDuKxyLzZU4gb5ZoS VRujyVscYSpptSaIscqxBEf/B/OLusfd+1mVxwMnghLFfaogaHFYV4QnnSxAnfLf3mgh JjAea3sFfXQV0SUZ8SU/H+cwLyBl3X9UfvyNsPaK72990b4DCktVKQQNQ23el7o8zWC4 A96A== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y20si11201587pgh.337.2021.09.27.02.06.24; Mon, 27 Sep 2021 02:06:38 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233613AbhI0JFs (ORCPT + 99 others); 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-kernel@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.