Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp1000659pxb; Wed, 29 Sep 2021 14:34:28 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw60dpiB7CvrA5INybuZMjKFOYW1aZwnevBx2dMEFlOII2PcBO9lGZjCZfS3gAk5zK84+SN X-Received: by 2002:a50:da8d:: with SMTP id q13mr2780164edj.198.1632951267875; Wed, 29 Sep 2021 14:34:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632951267; cv=none; d=google.com; s=arc-20160816; b=zpfV3Exqy7kzqJ9D6ThFC/2O78j4TfEoKe+f8XrP9RvkqX/e1KANTG6KyHk8TIbnLL iV3OioXFJlwGp5ujygot9M3A77yY5Nj1r0b2vW4CPlwf3Suz7pXsSo5ZpSFQBCz6IaDM q02MU8H6ODOF5cpp9ka0Z3QBUi74jz7VWeVrz8m2LndKtBLeLyLIDVVaKOVeMGyWTZPK V2JoTMB7+JbsBep1/6+MUQerQj7uXh5Q6lcmgpJ36B+wCZUfst/GT2ykv8Is8+uGFivl ozpJ78dpYrrcOEkdy9Ar2ZMF+wo++SmsHN3PBN0KKceFXpZxscFmbuL45HRbFrxHzpCe gFIw== 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=wIkb/A/ZJJji8jbTcCnkjRo12VXeXRq0QRKfxt1FsB0=; b=moF3ecR5dc4pIOLiT0lSDCcTTId4pHGmnF8gqqvRs8rSXRx3SjaH1nsMSm0H4AbgcO vmB9N3sUBZHmmoeFafnt8nHpagejQu2i0OdlqvFqZkfUHLIRdQ07/BIar8Zop9Rr5S7o nY62N30/R8p3CWgRG45FrHjiiYKlklszvLdIxh7PBexjUHFmmq3KwMwZ4RL3LOOoZ5jh Th7JASYjgL/MOqqm2FjEXHxf4H9KRFy8M1RnNwcxlrNyXY9PAc7FjydI9RuMFBClfB6Z uIYH7gCjLBXgVkmmGdT3yqd4m3P6fmqqKkJK1p44uSGaEZKNcibqAiCl+OpgtI0MSbhB 14Sg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=HapCW9ua; 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=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g8si1432700eds.481.2021.09.29.14.34.04; Wed, 29 Sep 2021 14:34:27 -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=@redhat.com header.s=mimecast20190719 header.b=HapCW9ua; 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=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346340AbhI2VMP (ORCPT + 99 others); Wed, 29 Sep 2021 17:12:15 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:30628 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346355AbhI2VMN (ORCPT ); Wed, 29 Sep 2021 17:12:13 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1632949830; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=wIkb/A/ZJJji8jbTcCnkjRo12VXeXRq0QRKfxt1FsB0=; b=HapCW9uaayQK6EL1OhRm8lKbwfmH7r8URVkAHHd7z6zLYuQtI/C9siyeSXIhSiWnVM6Blw p+GHuoeiXsHwInbqX3UKgXAfuePd5FG8ti5PkycGltOvcOAo8MU/Y8uNnLb3UtQVJdUg0i eeazlJwiX6N+eEbBmTdyqcbXB2/+IYI= Received: from mail-qk1-f200.google.com (mail-qk1-f200.google.com [209.85.222.200]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-100-DL5MsEY0NY2-yFdCZiDoJg-1; Wed, 29 Sep 2021 17:10:29 -0400 X-MC-Unique: DL5MsEY0NY2-yFdCZiDoJg-1 Received: by mail-qk1-f200.google.com with SMTP id r5-20020a05620a298500b0045dac5fb940so11087808qkp.17 for ; Wed, 29 Sep 2021 14:10:29 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=wIkb/A/ZJJji8jbTcCnkjRo12VXeXRq0QRKfxt1FsB0=; b=xEZzKHHnWFyUjlA83l1seaNoSL6ucGkFio9Fb4HVxRej7vk3nMUdr0U4z0JQNYM5Df O+0FBmzIHQyS9d+ou1hE9sWA9c0Sx5FFaph4dKX3KvRCDK+M/LeOd5WB+FeC2l1pkiqF NCzJSZp5uPnmRMbE8l+FMhIxfH8uBqCx/YBJkZ3D6SO86WLBHfqQ84v0F1kW7cwS/Mmg v6/dhZc222JmfNim1uaitaPK2jq1sLIbpv0+Q8gqQVSTbtbHihRqbIcgpzeT0abH24et 3hFoG4ya60+kZW/B4uHrObrpkOB6UZsw7idPH1LEdWaJKsFCMmiIhtOgLkLetkUicp6t wkEQ== X-Gm-Message-State: AOAM530SqzJ3nVWzYkLMXEPeDmMpb8N2dKXcZsJUASSnYPDsHndoJ8CY xEv0zcScbTIifirKkL+2yDOfMp+cvTA2gcPFLTkGM9ZOBsGYCfmW4oFXfEHiWGhO/WGnMJw5rmM nQ5jbS4W8qmPYDHyR2jiqCn+m X-Received: by 2002:a05:620a:22e:: with SMTP id u14mr1806749qkm.101.1632949829289; Wed, 29 Sep 2021 14:10:29 -0700 (PDT) X-Received: by 2002:a05:620a:22e:: with SMTP id u14mr1806721qkm.101.1632949829055; Wed, 29 Sep 2021 14:10:29 -0700 (PDT) Received: from treble ([2600:1700:6e32:6c00::15]) by smtp.gmail.com with ESMTPSA id x10sm569784qtq.45.2021.09.29.14.10.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 Sep 2021 14:10:28 -0700 (PDT) Date: Wed, 29 Sep 2021 14:10:23 -0700 From: Josh Poimboeuf To: Peter Zijlstra Cc: Kees Cook , 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 =?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" , 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: <20210929211023.runlsoqfto7hrl36@treble> References: <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> <20210929194026.GA4323@worktop.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20210929194026.GA4323@worktop.programming.kicks-ass.net> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Sep 29, 2021 at 09:40:26PM +0200, Peter Zijlstra wrote: > 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; Ah, cool :-) I'd also add that I don't see any reason to use the "reliable" unwinding variant. AFAIK, just basic stack_trace_save_tsk() should be sufficient. -- Josh