[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20210527235116.E5A35872@viggo.jf.intel.com>
Date: Thu, 27 May 2021 16:51:16 -0700
From: Dave Hansen <dave.hansen@...ux.intel.com>
To: linux-mm@...ck.org
Cc: linux-kernel@...r.kernel.org,
Dave Hansen <dave.hansen@...ux.intel.com>, tglx@...utronix.de,
mingo@...hat.com, bp@...en8.de, x86@...nel.org, luto@...nel.org,
shuah@...nel.org, babu.moger@....com, dave.kleikamp@...cle.com,
linuxram@...ibm.com, bauerman@...ux.ibm.com, bigeasy@...utronix.de
Subject: [PATCH 3/5] x86/pkeys: skip 'init_pkru' debugfs file creation when pkeys not supported
From: Dave Hansen <dave.hansen@...ux.intel.com>
The PKRU hardware is permissive by default: all reads and writes are
allowed. The in-kernel policy is restrictive by default: deny all
unnecessary access until explicitly requested.
That policy can be modified with a debugfs file: "x86/init_pkru".
This file is created unconditionally, regardless of PKRU support in
the hardware, which is a little silly.
Avoid creating the file when pkeys are not available. This also
removes the need to check for pkey support at runtime, which would be
required once the new pkey modification infrastructure is put in place
later in this series.
Signed-off-by: Dave Hansen <dave.hansen@...ux.intel.com>
Cc: Thomas Gleixner <tglx@...utronix.de>
Cc: Ingo Molnar <mingo@...hat.com>
Cc: Borislav Petkov <bp@...en8.de>
Cc: x86@...nel.org
Cc: Andy Lutomirski <luto@...nel.org>
Cc: Shuah Khan <shuah@...nel.org>
Cc: Babu Moger <babu.moger@....com>
Cc: Dave Kleikamp <dave.kleikamp@...cle.com>
Cc: Ram Pai <linuxram@...ibm.com>
Cc: Thiago Jung Bauermann <bauerman@...ux.ibm.com>
Cc: Sebastian Andrzej Siewior <bigeasy@...utronix.de>
---
b/arch/x86/mm/pkeys.c | 4 ++++
1 file changed, 4 insertions(+)
diff -puN arch/x86/mm/pkeys.c~x86-pkeys-skip-debugfs-file arch/x86/mm/pkeys.c
--- a/arch/x86/mm/pkeys.c~x86-pkeys-skip-debugfs-file 2021-05-27 16:40:25.847705465 -0700
+++ b/arch/x86/mm/pkeys.c 2021-05-27 16:40:25.852705465 -0700
@@ -193,6 +193,10 @@ static const struct file_operations fops
static int __init create_init_pkru_value(void)
{
+ /* Do not expose the file if pkeys are not supported. */
+ if (!cpu_feature_enabled(X86_FEATURE_OSPKE))
+ return 0;
+
debugfs_create_file("init_pkru", S_IRUSR | S_IWUSR,
arch_debugfs_dir, NULL, &fops_init_pkru);
return 0;
_
Powered by blists - more mailing lists