Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp1057097pxb; Thu, 23 Sep 2021 17:11:27 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz4aIq3BFSyYV8ZDXxK70FlsOti7+1kpX9O3u4yjeJ5++gc5qr84hs5NSbLGJo3aBZpjCOR X-Received: by 2002:a17:906:4482:: with SMTP id y2mr8033234ejo.484.1632442287238; Thu, 23 Sep 2021 17:11:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632442287; cv=none; d=google.com; s=arc-20160816; b=gEz/76k1mxxnGThvmNUWSPERjgpIh2E9lxMjltseiAX0X7U3StYz5CJgBEwFPceIpB ugvxz3I3/+220UffB011crvOnF9WiVMvE951TqaWDozBcDfeVQLiyqJlH8TJvPC0INiY GfF/G3Q5kJBI6QCyL/LUZn/Ao5HNvx218FmZkHjtJaCpgC3rAV0zI7p6yMYzCCRa/Lq9 ns1hcNAgn4fgImMay3Lss+2szoLBTFfGPty8DsffAX39xKy6EHSl6J6U3CB1ONKkU4Ou eIHbp/Lbkmp4+s1v0c0lcu1dn9g8PTG/W2Y/JS7hcZ8PRJNQUP8/lcVarL4i1Q3J8zcC d0Pw== 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=lKLY+5bNGiRz/82Uo56vZTCvhpy0d8iLAjs0wXOjirI=; b=FGLfbXzw7BN4gsd9hh5Fmqqhc0zF32g58zgIQ43qiREFedtq6DYEKbaOsOr+cGQGDl zu4EtqCBCuMrWkXQCP8GmJ3mg2V4PeUQIbrOOEG3rdDCDTP+7RKEX9NNUI0zgCf99yfQ IPYSiK7/mNfBldmoqHj8Bd2kAglBQ+a4nVC7x3pMJdJxvEhH2vOCGGCVsmeOjosi4sF3 SCv2yfmb3byp4MSN6BTPvJNrvyDEbjQjKJzcany9cR0fGRmvzZmbr/R7SkO4QACSszE7 yo2FMxkYPmIp0ceKB4R3TduefV0o+Q4Mk41rGPdc0/wEuF0b8gmREdzIGOjwIrCtwdZR dRZQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=mUy622lh; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y20si7383342edi.311.2021.09.23.17.11.03; Thu, 23 Sep 2021 17:11: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=@google.com header.s=20210112 header.b=mUy622lh; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232143AbhIXALH (ORCPT + 99 others); Thu, 23 Sep 2021 20:11:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40508 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243629AbhIXAKp (ORCPT ); Thu, 23 Sep 2021 20:10:45 -0400 Received: from mail-lf1-x12c.google.com (mail-lf1-x12c.google.com [IPv6:2a00:1450:4864:20::12c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 572D2C06175F for ; Thu, 23 Sep 2021 17:09:13 -0700 (PDT) Received: by mail-lf1-x12c.google.com with SMTP id u8so32239346lff.9 for ; Thu, 23 Sep 2021 17:09:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=lKLY+5bNGiRz/82Uo56vZTCvhpy0d8iLAjs0wXOjirI=; b=mUy622lhBZq+g0q8n8qp89eDCX0F3ZmAh9k8+h1cvy9OOaSFtSqZx5Pm0HpvXRBus3 giGmm+7B/oMrd5DwIEKod0yQEp6P/PGQQ1SGrWukFVzEYM0Me61+vtpSs6i5AgBHTgTD A0KyE4hPKZG9xLoJlL6pZ514TiFsvc5HFis8pBgS7feNiuu68UG/ol+od1N5Rxseeqcb iC6WG5ktgT7N1Me/OfNZJVOo/ECgo9cpknLc1JDYQdXmvU3gCnUd56slp2gr+FihxTtK DsAT+G6pMjgb8ZRPoOkIwR3AnP9SoQOPHffnYHBffhrLGfNhZsKcgpJEsfqcpkU+xH2Q eIfA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=lKLY+5bNGiRz/82Uo56vZTCvhpy0d8iLAjs0wXOjirI=; b=F9F+s1sYURN6Nx+gXSxWQthhz5uMFyqp5QeTzEkj9vIzXwcDCvqraWN9dbpCJX9yvx Re8nQxZjisWXwSIfo1WUuP3Jyo+iKF2Ch+Gv+iXfLt0cgiVe/FtCscIXWV4wASnrDz6c R5+B9goK3PS11flH9BUFzpadPZ9iQB9O2RBDyoWLS8/TX1GskB+Bjk74lFwQ7g1xmOpw DIb66+Maov0LW2eUeInQ8V7gr3o+PP9/YvcfaQdacefX0Sy4r0efxZ75nUxhF8CpO3We zk0VrObvRhrNvfQyOmt5CWKr1mjfbHoZ5zxl5cqqTHdsi7Nvc4aN2plvIqppsK9sYiEi ndjg== X-Gm-Message-State: AOAM532dCt2FgSbVkhsFnT6J/oNdkUiwdP9rE3TTmT2IyVQzRaAiq3Dz SOK2G0QkIstaU3PVQD932/U7NJLkXQls8lMPT4FWpw== X-Received: by 2002:a05:651c:101:: with SMTP id a1mr8322528ljb.459.1632442151367; Thu, 23 Sep 2021 17:09:11 -0700 (PDT) MIME-Version: 1.0 References: <20210923233105.4045080-1-keescook@chromium.org> <20210923234917.pqrxwoq7yqnvfpwu@shells.gnugeneration.com> In-Reply-To: <20210923234917.pqrxwoq7yqnvfpwu@shells.gnugeneration.com> From: Jann Horn Date: Fri, 24 Sep 2021 02:08:45 +0200 Message-ID: Subject: Re: [PATCH] proc: Disable /proc/$pid/wchan To: Vito Caputo Cc: Kees Cook , Thomas Gleixner , Josh Poimboeuf , Ingo Molnar , Borislav Petkov , "H. Peter Anvin" , Jens Axboe , Mark Rutland , Peter Zijlstra , Stefan Metzmacher , Andy Lutomirski , Lai Jiangshan , Christian Brauner , Andrew Morton , "Kenta.Tada@sony.com" , Daniel Bristot de Oliveira , =?UTF-8?Q?Michael_Wei=C3=9F?= , 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 Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Sep 24, 2021 at 1:59 AM Vito Caputo wrote: > On Thu, Sep 23, 2021 at 04:31:05PM -0700, Kees Cook wrote: > > The /proc/$pid/wchan file has been broken by default on x86_64 for 4 > > years now[1]. As this remains a potential leak of either kernel > > addresses (when symbolization fails) or limited observation of kernel > > function progress, just remove the contents for good. > > > > Unconditionally set the contents to "0" and also mark the wchan > > field in /proc/$pid/stat with 0. > > > > This leaves kernel/sched/fair.c as the only user of get_wchan(). But > > again, since this was broken for 4 years, was this profiling logic > > actually doing anything useful? > > > > [1] https://lore.kernel.org/lkml/20210922001537.4ktg3r2ky3b3r6yp@treble/ > > > > Cc: Josh Poimboeuf > > Cc: Vito Caputo > > Signed-off-by: Kees Cook > > > > Please don't deliberately break WCHANs wholesale. This is a very > useful tool for sysadmins to get a vague sense of where processes are > spending time in the kernel on production systems without affecting > performance or having to restart things under instrumentation. Wouldn't /proc/$pid/stack be more useful for that anyway? As long as you have root privileges, you can read that to get the entire stack, not just a single method name. (By the way, I guess that might be an alternative to ripping wchan out completely - require CAP_SYS_ADMIN like for /proc/$pid/stack?)