From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 32A55C4332F for ; Wed, 10 Nov 2021 18:55:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1A8FD61205 for ; Wed, 10 Nov 2021 18:55:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233728AbhKJS54 (ORCPT ); Wed, 10 Nov 2021 13:57:56 -0500 Received: from mail.kernel.org ([198.145.29.99]:53674 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232949AbhKJSzn (ORCPT ); Wed, 10 Nov 2021 13:55:43 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id A75F4619F7; Wed, 10 Nov 2021 18:49:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1636570182; bh=0oH85cjq7vTw6si60/MnAKRM5WZ4EBlcJF4dA31QY9c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZLBm3omHtw8CXgZxxKP1eo2vYMUWBTCVjelMQR6G2MndmLfpUiJyS85Kq7eFD31AX 5W1EteGdAERAU53YYMWQtpXfbErtRHfmjXu1mpiBFuwqEmIfdxO6t/oCUJcvIexNYc kECM1jdu8Sl8/yJy16N3Tl1UIAYOsfdS5HwIJVf4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, kernel test robot , Vito Caputo , Jann Horn , Kees Cook , "Peter Zijlstra (Intel)" Subject: [PATCH 5.14 09/24] Revert "proc/wchan: use printk format instead of lookup_symbol_name()" Date: Wed, 10 Nov 2021 19:44:01 +0100 Message-Id: <20211110182003.631273586@linuxfoundation.org> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211110182003.342919058@linuxfoundation.org> References: <20211110182003.342919058@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Kees Cook commit 54354c6a9f7fd5572d2b9ec108117c4f376d4d23 upstream. This reverts commit 152c432b128cb043fc107e8f211195fe94b2159c. When a kernel address couldn't be symbolized for /proc/$pid/wchan, it would leak the raw value, a potential information exposure. This is a regression compared to the safer pre-v5.12 behavior. Reported-by: kernel test robot Reported-by: Vito Caputo Reported-by: Jann Horn Signed-off-by: Kees Cook Signed-off-by: Peter Zijlstra (Intel) Cc: stable@vger.kernel.org Link: https://lkml.kernel.org/r/20211008111626.090829198@infradead.org Signed-off-by: Greg Kroah-Hartman --- fs/proc/base.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) --- a/fs/proc/base.c +++ b/fs/proc/base.c @@ -67,6 +67,7 @@ #include #include #include +#include #include #include #include @@ -385,17 +386,19 @@ static int proc_pid_wchan(struct seq_fil struct pid *pid, struct task_struct *task) { unsigned long wchan; + char symname[KSYM_NAME_LEN]; - if (ptrace_may_access(task, PTRACE_MODE_READ_FSCREDS)) - wchan = get_wchan(task); - else - wchan = 0; - - if (wchan) - seq_printf(m, "%ps", (void *) wchan); - else - seq_putc(m, '0'); + if (!ptrace_may_access(task, PTRACE_MODE_READ_FSCREDS)) + goto print0; + wchan = get_wchan(task); + if (wchan && !lookup_symbol_name(wchan, symname)) { + seq_puts(m, symname); + return 0; + } + +print0: + seq_putc(m, '0'); return 0; } #endif /* CONFIG_KALLSYMS */