Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp1045156pxb; Thu, 23 Sep 2021 16:54:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz3KVtKqlq3ipisCEL4qJgr3BfgjoUKq40wyIEvWrKLR7HYuKgFpVkS+Vt+7jwKUyZIdHed X-Received: by 2002:a05:6e02:1088:: with SMTP id r8mr5769633ilj.46.1632441259500; Thu, 23 Sep 2021 16:54:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632441259; cv=none; d=google.com; s=arc-20160816; b=WWHi8lb7whbX1NNxPBZyaXnz+2sHliHej6l8MADCpYwdwgNYxi8zOhDiKp40vFGtaH apevrOpnuM8qFF78Wn7hdSU8iEZnfP1bZOg5l7DxoO1Bnag6yIdtuHPwBscZfsW6hGUF WSPQkdYgeFA06hv6k6oXZH3d/8rtg5fq6AQ6Eb41V/IDX1N3Q6FwqTZjqyf8TFPjL3a9 KlcqYME4hYByUf/rQJMREe5UduKdVKKaqRnGQQCok7H91f/SVVsx+GQ7oXstsBXCunie 7fIxb84XC4zmT5lXXUcDuDCtYqlNaYpw4/dlUkSkdR1FvaX0+97OUAsxdQIxEuMuANNS 7oxg== 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=n1roZZCWVqt47r5ixpWi+lAb3czWoGR/Dz03apt/Wpo=; b=iheQzL8uLLZTbi+4aUkzQjwXN1kfX9Gnk/FZmyNTWYfcsrnWx0+biXAGJlFPtkkmD2 rnZH1r+llpCI/xK+KJey655ZDFgXqSidFhGecbsuJHIQTb8sJU9mpwVd6gvQxUTd4wnU Ib3rPD0FnSxV353wtxU2gYoCVRZMD1SA9DYDwUSPaeE1MDxc/YyKLWVACii5fgWY4tyJ Oro6Q6FYkxoMrolr0+Sc/LBLjRHn9xhZrztfIGyx7yY0yIsl5twqi42/wECHeTkKZVIn T2GFC/fQhQkozoZkywYWxeVtbYZuh8xozjc35WxYqtOuLrtHgHoCY6HKe1f/iKuL04ER LoBw== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c6si7829645ioq.87.2021.09.23.16.54.08; Thu, 23 Sep 2021 16:54:19 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243599AbhIWXuv (ORCPT + 99 others); Thu, 23 Sep 2021 19:50:51 -0400 Received: from shells.gnugeneration.com ([66.240.222.126]:36990 "EHLO shells.gnugeneration.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243598AbhIWXuv (ORCPT ); Thu, 23 Sep 2021 19:50:51 -0400 Received: by shells.gnugeneration.com (Postfix, from userid 1000) id E8CF81A56019; Thu, 23 Sep 2021 16:49:17 -0700 (PDT) Date: Thu, 23 Sep 2021 16:49:17 -0700 From: Vito Caputo To: Kees Cook Cc: Thomas Gleixner , Josh Poimboeuf , Vito Caputo , 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 , 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: <20210923234917.pqrxwoq7yqnvfpwu@shells.gnugeneration.com> References: <20210923233105.4045080-1-keescook@chromium.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210923233105.4045080-1-keescook@chromium.org> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. I don't see how providing the symbol name of a given task's kernel function, especially if shallow near the user->kernel entrypoint, is a worrisome information leak. Just make sure it's not failing open with addresses like my original report documented seems to happen spuriously as-is w/kallsyms. When I worked full-time as a sysadmin WCHAN's were regularly the first thing to look at in `ps -o stat,wchan | grep D` when things were falling over. e.g.: ``` root@shells:/root# ps -o stat,wchan | grep D D io_schedule ``` Furthermore this is a well documented on dead trees and understood *nix/posix system observation technique. Even the POSIX ps(1) man page documents it: https://pubs.opengroup.org/onlinepubs/9699919799/utilities/ps.html Frankly I'm a bit mortified that I have to write this email. Today I'm hoping to test Josh's patch @ https://lore.kernel.org/all/20210831083625.59554-1-zhengqi.arch@bytedance.com/ Thanks, Vito Caputo