selinux/libsepol
Vit Mojzis 575d1cfaac libsepol/mls: Do not destroy context on memory error
In case of malloc error, ctx1, or ctx2 may be pointing to uninitialized
space and context_destroy should not be used on it.

Fixes:
Error: UNINIT (CWE-457):
libsepol-3.7/src/mls.c:673:2: alloc_fn: Calling "malloc" which returns uninitialized memory.
libsepol-3.7/src/mls.c:673:2: assign: Assigning: "ctx1" = "malloc(64UL)", which points to uninitialized data.
libsepol-3.7/src/mls.c:699:2: uninit_use_in_call: Using uninitialized value "ctx1->range.level[0].cat.node" when calling "context_destroy".
 \#  697|   	ERR(handle, "could not check if mls context %s contains %s",
 \#  698|   	    mls1, mls2);
 \#  699|-> 	context_destroy(ctx1);
 \#  700|   	context_destroy(ctx2);
 \#  701|   	free(ctx1);

Error: UNINIT (CWE-457):
libsepol-3.7/src/mls.c:674:2: alloc_fn: Calling "malloc" which returns uninitialized memory.
libsepol-3.7/src/mls.c:674:2: assign: Assigning: "ctx2" = "malloc(64UL)", which points to uninitialized data.
libsepol-3.7/src/mls.c:700:2: uninit_use_in_call: Using uninitialized value "ctx2->range.level[0].cat.node" when calling "context_destroy".
 \#  698|   	    mls1, mls2);
 \#  699|   	context_destroy(ctx1);
 \#  700|-> 	context_destroy(ctx2);
 \#  701|   	free(ctx1);
 \#  702|   	free(ctx2);

Signed-off-by: Vit Mojzis <vmojzis@redhat.com>
Acked-by: James Carter <jwcart2@gmail.com>
2024-10-30 08:06:57 -04:00
..
cil libsepol/cil: Initialize avtab_datum on declaration 2024-10-30 08:06:55 -04:00
fuzz libsepol/fuzz: handle empty and non kernel policies 2023-12-06 13:32:50 -05:00
include libsepol: Add policy capability netlink_xperm 2024-09-04 16:54:26 -04:00
man Do not automatically install Russian translations 2023-08-16 13:33:47 -04:00
src libsepol/mls: Do not destroy context on memory error 2024-10-30 08:06:57 -04:00
tests libsepol/tests: Update the order of neverallow test results 2023-11-21 08:55:45 -05:00
utils libsepol/utils: improve wording 2022-07-06 15:57:24 -04:00
.gitignore
LICENSE docs: provide a top level LICENSE file 2022-10-05 08:20:38 -04:00
Makefile
VERSION Release 3.7 2024-06-26 17:30:41 +02:00