selftests/x86/fsgsbase: Check mmap return value
PATCH 1/1 selftests/x86/fsgsbase: Check mmap return value
mmap() in main() returns MAP_FAILED on error, but the return value is not checked. Subsequent dereferences of shared_scratch (e.g. in test_ptrace_write_gsbase) would segfault. Add a MAP_FAILED check using err(), consistent with the rest of the file.
--- tools/testing/selftests/x86/fsgsbase.c | 2 ++ 1 file changed, 2 insertions(+)
tools/testing/selftests/x86/fsgsbase.c +2 -0
@@ -572,6 +572,8 @@ int main() shared_scratch =mmap (NULL ,4096 ,PROT_READ |PROT_WRITE ,MAP_ANONYMOUS |MAP_SHARED ,-1 ,0 ); +if (shared_scratch ==MAP_FAILED ) +err (1 ,"mmap" );/* Do these tests before we have an LDT. */ test_ptrace_write_gs_read_base ();
Signature · 1 line
2.43.0
Hi, longlong
Quoted 7 lines
mmap()inmain()returnsMAP_FAILEDon error, but the return value is not checked. Subsequent dereferences ofshared_scratch(e.g. intest_ptrace_write_gsbase) would segfault. Add aMAP_FAILEDcheck usingerr(), consistent with the rest of the file.Fixes 697096b14444 ("selftests/x86/fsgsbase: Fix some test case bugs")Signed-off-by longlong yan <[email protected]>
Thank you for your patch.
I notice that the fix for this issue has already been addressed by my previous patch [1]. Could you please take a look?
[1] https://lore.kernel.org/all/[email protected]/
Best regards,
Hongfu