Open muyu888 opened 1 year ago
This might be related to a problem found by oss-fuzz earlier in the year. I sent a patch to the list on April 20th, but that patch has not been reviewed or merged yet. If you are able, please try that patch and see if it fixes the problem. If it doesn't, it would be very helpful if you could attach the CIL policy that oss-fuzz created to find this problem. Thanks!
Thanks for the answer, but I didn't find the patch you mentioned for the 20th of April, could you please provide it again? And then I didn't find the cil strategy file over here either, maybe it has another name, painstakingly you say more details!
Just to be clear, the patch was posted on the SELinux mailing list here: https://lore.kernel.org/selinux/20230420125801.999381-1-jwcart2@gmail.com/
oss-fuzz is generating CIL policies and then trying to compile them, so there should be a policy file somewhere. I know when I receive reports from oss-fuzz it includes a link to the CIL policy file that caused the problem.
I've found the cause, the memory leak is due to the following merge-in:https://github.com/SELinuxProject/selinux/commit/c49a8ea09501ad66e799ea41b8154b6770fec2c8; but later on this merge-in will fix the leak:https://github.com/SELinuxProject/selinux/commit/2d2c76fc613ba338476a3a1741c2a3af5e04d154; As for the segment error, it's only known to be caused by this merge-in code:https://github.com/SELinuxProject/selinux/commit/67a8dc8117e0c3887c39f7add8932e4ad23c1d9c; it's not clear which merge-in or multiple merges fixed it, but as of version 3.3, this version is working fine!
libsepol version 3.1.10 Operating system Linux
Description I found memory leaks and segment errors while performing OSS-fuzz testing with the following steps,Maybe you can tell me whether it's reasonable or not. Steps to Reproduce Issue one: 1、 Compilation python3 infra/helper.py build_fuzzers --sanitizer address selinux 2、Check the output file python3 infra/helper.py reproduce selinux secilc-fuzzer build/out/selinux/leak-0790666db6912b2950c819fa190a5aa32aa23c36 3、 Report the contents of the error INFO: Seed: 1882425977 INFO: Loaded 1 modules (14356 inline 8-bit counters): 14356 [0xa757a0, 0xa78fb4), INFO: Loaded 1 PC tables (14356 PCs): 14356 [0xa78fb8,0xab10f8), /out/secilc-fuzzer: Running 1 inputs 100 time(s) each. Running: /testcase
================================================================= ==6==ERROR: LeakSanitizer: detected memory leaks
Direct leak of 48 byte(s) in 2 object(s) allocated from:
0 0x51dd5d in malloc /src/llvm-project/compiler-rt/lib/asan/asan_malloc_linux.cpp:145:3
SUMMARY: AddressSanitizer: 96 byte(s) leaked in 4 allocation(s). INFO: a leak has been found in the initial corpus. INFO: to ignore leaks on libFuzzer side use -detect_leaks=0.
4.My analysis: In the file /cil/src/cil_resolve_ast.c, there are two branches in the static int __cil_resolve_perms(), one of which applies for memory that has not been visibly found to be used externally, and whether it can be released! else { cil_list_append(*perm_datums, curr->flavor, curr->data); } } return SEPOL_OK;
exit: cil_list_destroy(perm_datums, CIL_FALSE); return rc; } Issue two: 1、 Compilation python3 infra/helper.py build_fuzzers --sanitizer undefined selinux 2、 Check the output file python3 infra/helper.py reproduce selinux secilc-fuzzer build/out/selinux/crash-cb5d181cd5ac1886a7b128f6c58b5638edc7f26d 3、 Report the contents of the error INFO: Seed: 820964843 INFO: Loaded 1 modules (51925 inline 8-bit counters): 51925 [0xb9ff68, 0xbaca3d), INFO: Loaded 1 PC tables (51925 PCs): 51925 [0xbaca40,0xc77790), /out/secilc-fuzzer: Running 1 inputs 100 time(s) each. Running: /testcase UndefinedBehaviorSanitizer:DEADLYSIGNAL ==6==ERROR: UndefinedBehaviorSanitizer: SEGV on unknown address 0x000000000000 (pc 0x7fcf403a1746 bp 0x7fff63ca2990 sp 0x7fff63ca28f8 T6) ==6==The signal is caused by a READ memory access. ==6==Hint: address points to the zero page.
0 0x7fcf403a1746 in strlen (/lib/x86_64-linux-gnu/libc.so.6+0x8b746)
UndefinedBehaviorSanitizer can not provide additional info. SUMMARY: UndefinedBehaviorSanitizer: SEGV (/lib/x86_64-linux-gnu/libc.so.6+0x8b746) in strlen ==6==ABORTING
Hope can give conclusion can pass this OSS-fuzz fuzz test, thanks~!