diff options
author | Dave Hansen <[email protected]> | 2022-01-04 09:15:27 -0800 |
---|---|---|
committer | Dave Hansen <[email protected]> | 2022-01-07 08:47:23 -0800 |
commit | 2056e2989bf47ad7274ecc5e9dda2add53c112f9 (patch) | |
tree | 9b9045047b72e1f423f41f1437b76274bf7d00c2 /scripts/bpf_doc.py | |
parent | 572a0a647b9b491729d24c083c8410c55bf16326 (diff) |
x86/sgx: Fix NULL pointer dereference on non-SGX systems
== Problem ==
Nathan Chancellor reported an oops when aceessing the
'sgx_total_bytes' sysfs file:
https://lore.kernel.org/all/YbzhBrimHGGpddDM@archlinux-ax161/
The sysfs output code accesses the sgx_numa_nodes[] array
unconditionally. However, this array is allocated during SGX
initialization, which only occurs on systems where SGX is
supported.
If the sysfs file is accessed on systems without SGX support,
sgx_numa_nodes[] is NULL and an oops occurs.
== Solution ==
To fix this, hide the entire nodeX/x86/ attribute group on
systems without SGX support using the ->is_visible attribute
group callback.
Unfortunately, SGX is initialized via a device_initcall() which
occurs _after_ the ->is_visible() callback. Instead of moving
SGX initialization earlier, call sysfs_update_group() during
SGX initialization to update the group visiblility.
This update requires moving the SGX sysfs code earlier in
sgx/main.c. There are no code changes other than the addition of
arch_update_sysfs_visibility() and a minor whitespace fixup to
arch_node_attr_is_visible() which checkpatch caught.
CC: Greg Kroah-Hartman <[email protected]>
Cc: [email protected]
Cc: [email protected]
Fixes: 50468e431335 ("x86/sgx: Add an attribute for the amount of SGX memory in a NUMA node")
Reported-by: Nathan Chancellor <[email protected]>
Signed-off-by: Dave Hansen <[email protected]>
Reviewed-by: Greg Kroah-Hartman <[email protected]>
Reviewed-by: Jarkko Sakkinen <[email protected]>
Tested-by: Nathan Chancellor <[email protected]>
Tested-by: Jarkko Sakkinen <[email protected]>
Link: https://lkml.kernel.org/r/[email protected]
Diffstat (limited to 'scripts/bpf_doc.py')
0 files changed, 0 insertions, 0 deletions