Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp935372pxb; Wed, 29 Sep 2021 12:56:11 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzGb3++HBVXtvcClsHs5r5J8ICJ4Nt8ozLIk5NqsN6ssMugikBDFtdMNctPDzZ/Y4LE5xLQ X-Received: by 2002:aa7:8f01:0:b0:447:8167:46c1 with SMTP id x1-20020aa78f01000000b00447816746c1mr504857pfr.30.1632945371265; Wed, 29 Sep 2021 12:56:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632945371; cv=none; d=google.com; s=arc-20160816; b=0L/t4EQOeSXjXlCuTYEVobrgfCZjvxaQ0Smfg48znAVeYK9aqESfykzyCmfBCkBlPO yXwFAGezJ2+pDAyN3rY5FNpTcjy91hceTzDOen6ts/adofD+4/fsRmnVkodjKybzbh1P +FSW1o/yE0GxcCjWXX3FlHQchNxKxqvkI8gJ/gnM+k9rWA/qcGOomZYt9B8iEx5/0DlG rXiI9oQs3s4fzW06u8tcxVYrs6sUN/U37rmS/2b51ifOjs7VMaRfqTMR28l8P8PGSR1u MJG3mcWmDl2sTm4bSFmqJqUfqxHBuODAd+NqJjTokMcB4ZfoNrYgoXoLFGjxk510az75 Ok+Q== 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:dkim-signature; bh=XUQjPlxUzyJJLOjoxDLHnmXHdd8MXOO/ojHcClak0TY=; b=vLEX1f2uy4/T2dkrNa7RTHDCiGQPVx+yv9wth5OP78qncHM63G8ljCUlUO8m8Z1dM8 7UwORFNb0bRuUxl+HkOayrfI6JeOHYTw7NM5tod/gVjCP8z8QmHup8CtBqOr1Y98xNh4 +cDHhdKOYwk3/FgqZAPViUWjD8Dqct0znnFTt28VsJAWGGhpuYfJDcPDLJs6EhobLrEH 81zEpzAVX12PWdcj//pI08V/H7mDnXj7pW7cIiHtw258KmCJZt9fZvpUKzEoxR3G8BtH FsE59YfvHk/T3jRqYlvEakfUeLlL4trrFILFDDH8wBTSP3UDDmVchcRERmHn59AoneKF ljYA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=iKBOQNL+; 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 a7si1007418pgw.504.2021.09.29.12.55.40; Wed, 29 Sep 2021 12:56:11 -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=@infradead.org header.s=casper.20170209 header.b=iKBOQNL+; 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 S1344575AbhI2Trp (ORCPT + 99 others); Wed, 29 Sep 2021 15:47:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60798 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345040AbhI2Trm (ORCPT ); Wed, 29 Sep 2021 15:47:42 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 366B1C06161C; Wed, 29 Sep 2021 12:46:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=XUQjPlxUzyJJLOjoxDLHnmXHdd8MXOO/ojHcClak0TY=; b=iKBOQNL+2JpkvGVN0VgW2BBHLU BEfPRu4lE5rZV2fufxs3AYjjUyXhUaJMEEUUojipC9C2ZNEPpdTh8MyEo8rzPy+pcYvLeEukNtxId fWTwyQhGTNiLkT+y+sS2gl0AjjObLiRwAm85TW9JzcBE9cVXvWSkq9MXhDEoFCI+XnTwdIXt5Sw5e 3wi4LuUpf2FFwgwPldghyfurXx1137/L2Z41DCEdHsXySFkF3REWo/iJVLK6uMYO76jusiAXr5kOY d1BvePeYCPk82dOKPqeZto265102twzRjbL/iFZmiErYkOVMSy8g0l3OvddOEYoCqYzN3F+1MKUvr 8wR/RjiQ==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=worktop.programming.kicks-ass.net) by casper.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1mVfRL-00CAit-HA; Wed, 29 Sep 2021 19:40:50 +0000 Received: by worktop.programming.kicks-ass.net (Postfix, from userid 1000) id C5137981431; Wed, 29 Sep 2021 21:40:26 +0200 (CEST) Date: Wed, 29 Sep 2021 21:40:26 +0200 From: Peter Zijlstra To: Kees Cook Cc: Josh Poimboeuf , Mark Rutland , Vito Caputo , Jann Horn , Thomas Gleixner , Ingo Molnar , Borislav Petkov , "H. Peter Anvin" , Jens Axboe , Stefan Metzmacher , Andy Lutomirski , Lai Jiangshan , Christian Brauner , Andrew Morton , "Kenta.Tada@sony.com" , Daniel Bristot de Oliveira , Michael =?iso-8859-1?Q?Wei=DF?= , Anand K Mistry , Alexey Gladkov , Michal Hocko , Helge Deller , Dave Hansen , Andrea Righi , Ohhoon Kwon , Kalesh Singh , YiFei Zhu , "Eric W. Biederman" , Qi Zheng , 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: <20210929194026.GA4323@worktop.programming.kicks-ass.net> References: <20210923234917.pqrxwoq7yqnvfpwu@shells.gnugeneration.com> <20210924002230.sijoedia65hf5bj7@shells.gnugeneration.com> <202109231814.FD09DBAD3@keescook> <20210924135424.GA33573@C02TD0UTHF1T.local> <202109240716.A0792BE46@keescook> <20210927090337.GB1131@C02TD0UTHF1T.local> <202109271103.4E15FC0@keescook> <20210927205056.jjdlkof5w6fs5wzw@treble> <202109291152.681444A135@keescook> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <202109291152.681444A135@keescook> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Sep 29, 2021 at 11:54:55AM -0700, Kees Cook wrote: > > > > > > It's supposed to show where a blocked task is blocked; the "wait > > > > > > channel". > Since I think we're considering get_wchan() to be slow-path, can we just > lock the runqueue and use arch_stack_walk_reliable()? Funny thing, when a task is blocked it isn't on the runqueue :-) So if all we want to do is capture a blocked task and fail otherwise we don't need the rq->lock at all. Something like: unsigned long ip = 0; raw_spin_lock_irq(&p->pi_lock); state = READ_ONCE(p->__state); smp_rmb(); /* see try_to_wake_up() */ if (state == TASK_RUNNING || state == TASK_WAKING || p->on_rq) goto unlock; ip = /* do actual stack walk on a blocked task */ unlock: raw_spin_unlock_irq(&p->pi_lock); return ip; Should get us there.