diff options
author | Dave Hansen <dave.hansen@linux.intel.com> | 2021-06-04 02:08:10 +0300 |
---|---|---|
committer | Borislav Petkov <bp@suse.de> | 2021-06-04 18:01:03 +0300 |
commit | 314a1e1eabea5b86532e90e0d4e217fa88471e3b (patch) | |
tree | bf631cce69652b52c9b4716c6b33c2a0fdcf541e /arch/x86/mm/pkeys.c | |
parent | 8124c8a6b35386f73523d27eacb71b5364a68c4c (diff) | |
download | linux-314a1e1eabea5b86532e90e0d4e217fa88471e3b.tar.xz |
x86/pkeys: Skip 'init_pkru' debugfs file creation when pkeys not supported
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@linux.intel.com>
Signed-off-by: Borislav Petkov <bp@suse.de>
Link: https://lkml.kernel.org/r/20210603230810.113FF3F2@viggo.jf.intel.com
Diffstat (limited to 'arch/x86/mm/pkeys.c')
-rw-r--r-- | arch/x86/mm/pkeys.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/arch/x86/mm/pkeys.c b/arch/x86/mm/pkeys.c index a2332eef66e9..4a67b922bce1 100644 --- a/arch/x86/mm/pkeys.c +++ b/arch/x86/mm/pkeys.c @@ -192,6 +192,10 @@ static const struct file_operations fops_init_pkru = { 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; |