Skip to content

Commit 1b4979c

Browse files
cgzonesjwcart2
authored andcommitted
libsepol: reject invalid filetrans source type
Avoid integer underflow on invalid filetrans source types. policydb.c:2658:47: runtime error: unsigned integer overflow: 0 - 1 cannot be represented in type 'unsigned int' #0 0x4cf4cb in policydb_filetrans_insert ./libsepol/src/policydb.c:2658:47 #1 0x4d221a in filename_trans_read_one_compat ./libsepol/src/policydb.c:2691:7 #2 0x4d221a in filename_trans_read ./libsepol/src/policydb.c:2842:9 #3 0x4d1370 in policydb_read ./libsepol/src/policydb.c:4447:7 #4 0x4b1ee3 in LLVMFuzzerTestOneInput ./libsepol/fuzz/binpolicy-fuzzer.c:35:6 #5 0x43f2f3 in fuzzer::Fuzzer::ExecuteCallback(unsigned char const*, unsigned long) fuzzer.o #6 0x42ae32 in fuzzer::RunOneTest(fuzzer::Fuzzer*, char const*, unsigned long) fuzzer.o #7 0x430d5b in fuzzer::FuzzerDriver(int*, char***, int (*)(unsigned char const*, unsigned long)) fuzzer.o #8 0x45a1f2 in main (./out/binpolicy-fuzzer+0x45a1f2) #9 0x7f8b8923a7ec in __libc_start_main csu/../csu/libc-start.c:332:16 #10 0x407aa9 in _start (./out/binpolicy-fuzzer+0x407aa9) Signed-off-by: Christian Göttsche <[email protected]>
1 parent 8750fb6 commit 1b4979c

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

libsepol/src/policydb.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2683,7 +2683,10 @@ static int filename_trans_read_one_compat(policydb_t *p, struct policy_file *fp)
26832683
if (rc < 0)
26842684
goto err;
26852685

2686-
stype = le32_to_cpu(buf[0]);
2686+
stype = le32_to_cpu(buf[0]);
2687+
if (stype == 0)
2688+
goto err;
2689+
26872690
ttype = le32_to_cpu(buf[1]);
26882691
tclass = le32_to_cpu(buf[2]);
26892692
otype = le32_to_cpu(buf[3]);

0 commit comments

Comments
 (0)