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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id DB865C433EF for ; Sun, 5 Jun 2022 20:44:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347265AbiFEUn7 (ORCPT ); Sun, 5 Jun 2022 16:43:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54110 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229678AbiFEUn4 (ORCPT ); Sun, 5 Jun 2022 16:43:56 -0400 Received: from mx4.wp.pl (mx4.wp.pl [212.77.101.11]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0FA92266F for ; Sun, 5 Jun 2022 13:43:53 -0700 (PDT) Received: (wp-smtpd smtp.wp.pl 12142 invoked from network); 5 Jun 2022 22:43:49 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=wp.pl; s=1024a; t=1654461829; bh=MCYrEjgzieJDKLfSTVWSDFa0xMQ9SUb7yWBOIBy4GZw=; h=From:To:Cc:Subject; b=eMjPXfP77QOc2vnNXkCxF/w2ISUbuXJ0uppmHnajDp8T4rRCQktqHX1WDSrQlpqiV J705YI+LC15YX6NKC/5Gv5qkNdpRodJ2CsuXzzgg4LIWmk8Gv9kJTV/xp8GtABSTeZ qSP71wjemrXWa0VwRyzJzd+MCvflyZbPSqIpFKk4= Received: from public-gprs207966.centertel.pl (HELO mocarz) (deweloper@wp.pl@[46.134.151.159]) (envelope-sender ) by smtp.wp.pl (WP-SMTPD) with ECDHE-RSA-AES256-GCM-SHA384 encrypted SMTP for ; 5 Jun 2022 22:43:49 +0200 Date: Sun, 5 Jun 2022 22:43:47 +0200 From: Aleksander Mazur To: Arnd Bergmann , Sergey Senozhatsky Cc: Aleksander Mazur , linux-kernel@vger.kernel.org, Jiri Olsa Subject: [PATCH] /proc/modules: honor kptr_restrict even without CONFIG_KALLSYMS Message-ID: <20220605224347.481e2fb4@mocarz> X-Mailer: Claws Mail 4.1.0 (GTK 3.24.34; x86_64-redhat-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-WP-MailID: 28a283f460c12e9444f57583fc01d6b6 X-WP-AV: skaner antywirusowy Poczty Wirtualnej Polski X-WP-SPAM: NO 000000A [8YNk] Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit e4a8ca3baa55 fixed building without CONFIG_KALLSYMS by providing dummy kallsyms_show_value(). Unfortunately -- due to hard-coded "false" being returned -- access to addresses in /proc/modules became permanently disabled. My proposal is to change this unconditional "false" to !kptr_restrict. This re-enables addresses in /proc/modules even without CONFIG_KALLSYSMS unless restricted by means of sysctl (kernel.kptr_restrict). Fixes: e4a8ca3baa55 ("/proc/module: fix building without kallsyms") Signed-off-by: Aleksander Mazur --- include/linux/kallsyms.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/linux/kallsyms.h b/include/linux/kallsyms.h index ad39636e0c3f..cf64f9709f46 100644 --- a/include/linux/kallsyms.h +++ b/include/linux/kallsyms.h @@ -160,7 +160,7 @@ static inline int lookup_symbol_attrs(unsigned long addr, unsigned long *size, u static inline bool kallsyms_show_value(const struct cred *cred) { - return false; + return !kptr_restrict; } static inline int kallsyms_on_each_symbol(int (*fn)(void *, const char *, struct module *, -- 2.36.1