linux-hardening.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Kees Cook <keescook@chromium.org>
To: Peter Zijlstra <peterz@infradead.org>
Cc: "Kees Cook" <keescook@chromium.org>,
	"Andrew Morton" <akpm@linux-foundation.org>,
	"Christian Brauner" <christian.brauner@ubuntu.com>,
	"Jann Horn" <jannh@google.com>, "Michal Hocko" <mhocko@suse.com>,
	"Helge Deller" <deller@gmx.de>,
	linux-fsdevel@vger.kernel.org,
	"kernel test robot" <oliver.sang@intel.com>,
	"Vito Caputo" <vcaputo@pengaru.com>,
	"Ingo Molnar" <mingo@redhat.com>,
	"Juri Lelli" <juri.lelli@redhat.com>,
	"Vincent Guittot" <vincent.guittot@linaro.org>,
	"Dietmar Eggemann" <dietmar.eggemann@arm.com>,
	"Steven Rostedt" <rostedt@goodmis.org>,
	"Ben Segall" <bsegall@google.com>, "Mel Gorman" <mgorman@suse.de>,
	"Daniel Bristot de Oliveira" <bristot@redhat.com>,
	"Anand K Mistry" <amistry@google.com>,
	"Kenta.Tada@sony.com" <Kenta.Tada@sony.com>,
	"Alexey Gladkov" <legion@kernel.org>,
	"Michael Weiß" <michael.weiss@aisec.fraunhofer.de>,
	"Qi Zheng" <zhengqi.arch@bytedance.com>,
	"Tobin C. Harding" <me@tobin.cc>,
	"Tycho Andersen" <tycho@tycho.pizza>,
	"Thomas Gleixner" <tglx@linutronix.de>,
	"Borislav Petkov" <bp@alien8.de>,
	"H. Peter Anvin" <hpa@zytor.com>,
	"Mark Rutland" <mark.rutland@arm.com>,
	"Jens Axboe" <axboe@kernel.dk>,
	"Stefan Metzmacher" <metze@samba.org>,
	"Lai Jiangshan" <laijs@linux.alibaba.com>,
	"Andy Lutomirski" <luto@kernel.org>,
	"Dave Hansen" <dave.hansen@linux.intel.com>,
	"Eric W. Biederman" <ebiederm@xmission.com>,
	"Ohhoon Kwon" <ohoono.kwon@samsung.com>,
	"Kalesh Singh" <kaleshsingh@google.com>,
	"YiFei Zhu" <yifeifz2@illinois.edu>,
	"Josh Poimboeuf" <jpoimboe@redhat.com>,
	linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org,
	x86@kernel.org
Subject: [PATCH v2 4/6] proc: Only report /proc/$pid/wchan when process is blocked
Date: Wed, 29 Sep 2021 15:02:16 -0700	[thread overview]
Message-ID: <20210929220218.691419-5-keescook@chromium.org> (raw)
In-Reply-To: <20210929220218.691419-1-keescook@chromium.org>

The current get_wchan() implementations do their best to avoid problems
when walking a stack given a process in an unknown state, but this is
fragile and unnecessary. It's only useful to report wchan if a process
is actually blocked, so use the new sched_task_get_wchan() instead.

Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Christian Brauner <christian.brauner@ubuntu.com>
Cc: Jann Horn <jannh@google.com>
Cc: Michal Hocko <mhocko@suse.com>
Cc: Helge Deller <deller@gmx.de>
Cc: linux-fsdevel@vger.kernel.org
Signed-off-by: Kees Cook <keescook@chromium.org>
---
 fs/proc/base.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/fs/proc/base.c b/fs/proc/base.c
index 1f394095eb88..7853592778b2 100644
--- a/fs/proc/base.c
+++ b/fs/proc/base.c
@@ -392,7 +392,8 @@ static int proc_pid_wchan(struct seq_file *m, struct pid_namespace *ns,
 	if (!ptrace_may_access(task, PTRACE_MODE_READ_FSCREDS))
 		goto print0;
 
-	wchan = get_wchan(task);
+	wchan = sched_task_get_wchan(task);
+	/* Must only report symbolized addresses and never raw pointers. */
 	if (wchan && !lookup_symbol_name(wchan, symname)) {
 		seq_puts(m, symname);
 		return 0;
-- 
2.30.2


  parent reply	other threads:[~2021-09-29 22:04 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-29 22:02 [PATCH v2 0/6] wchan: Fix ORC support and leaky fallback Kees Cook
2021-09-29 22:02 ` [PATCH v2 1/6] Revert "proc/wchan: use printk format instead of lookup_symbol_name()" Kees Cook
2021-09-29 22:02 ` [PATCH v2 2/6] sched: Add wrapper for get_wchan() to keep task blocked Kees Cook
2021-09-30  8:27   ` Peter Zijlstra
2021-09-30  8:28     ` Peter Zijlstra
2021-09-30  8:29       ` Peter Zijlstra
2021-09-29 22:02 ` [PATCH v2 3/6] proc: Use task_is_running() for wchan in /proc/$pid/stat Kees Cook
2021-09-29 22:02 ` Kees Cook [this message]
2021-09-29 22:02 ` [PATCH v2 5/6] x86: Fix get_wchan() to support the ORC unwinder Kees Cook
2021-09-29 22:02 ` [PATCH v2 6/6] leaking_addresses: Always print a trailing newline Kees Cook
2021-09-30 14:37   ` Tycho Andersen
2021-09-30  1:01 ` [PATCH v2 0/6] wchan: Fix ORC support and leaky fallback Josh Poimboeuf
2021-09-30  8:40   ` Peter Zijlstra
2021-09-30 15:18     ` Kees Cook
2021-09-30 18:39       ` Peter Zijlstra

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210929220218.691419-5-keescook@chromium.org \
    --to=keescook@chromium.org \
    --cc=Kenta.Tada@sony.com \
    --cc=akpm@linux-foundation.org \
    --cc=amistry@google.com \
    --cc=axboe@kernel.dk \
    --cc=bp@alien8.de \
    --cc=bristot@redhat.com \
    --cc=bsegall@google.com \
    --cc=christian.brauner@ubuntu.com \
    --cc=dave.hansen@linux.intel.com \
    --cc=deller@gmx.de \
    --cc=dietmar.eggemann@arm.com \
    --cc=ebiederm@xmission.com \
    --cc=hpa@zytor.com \
    --cc=jannh@google.com \
    --cc=jpoimboe@redhat.com \
    --cc=juri.lelli@redhat.com \
    --cc=kaleshsingh@google.com \
    --cc=laijs@linux.alibaba.com \
    --cc=legion@kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-hardening@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=luto@kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=me@tobin.cc \
    --cc=metze@samba.org \
    --cc=mgorman@suse.de \
    --cc=mhocko@suse.com \
    --cc=michael.weiss@aisec.fraunhofer.de \
    --cc=mingo@redhat.com \
    --cc=ohoono.kwon@samsung.com \
    --cc=oliver.sang@intel.com \
    --cc=peterz@infradead.org \
    --cc=rostedt@goodmis.org \
    --cc=tglx@linutronix.de \
    --cc=tycho@tycho.pizza \
    --cc=vcaputo@pengaru.com \
    --cc=vincent.guittot@linaro.org \
    --cc=x86@kernel.org \
    --cc=yifeifz2@illinois.edu \
    --cc=zhengqi.arch@bytedance.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).