SELinux Security Module development
 help / color / mirror / Atom feed
* [PATCH] libsepol: Fix potential NULL dereference in policydb_read()
@ 2026-01-22 16:45 James Carter
  2026-01-26  1:49 ` Jason Zaman
  0 siblings, 1 reply; 2+ messages in thread
From: James Carter @ 2026-01-22 16:45 UTC (permalink / raw)
  To: selinux; +Cc: James Carter

Since there can be gaps in the type_val_to_struct array for very
old policies (version < POLICYDB_VERSION_BOUNDARY), need to
that it is not NULL for a particular index before using.

Reported-by: oss-fuzz (issue 474424148)
Signed-off-by: James Carter <jwcart2@gmail.com>
---
 libsepol/src/policydb.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libsepol/src/policydb.c b/libsepol/src/policydb.c
index 6aaa18f2..9760b164 100644
--- a/libsepol/src/policydb.c
+++ b/libsepol/src/policydb.c
@@ -4513,7 +4513,7 @@ int policydb_read(policydb_t * p, struct policy_file *fp, unsigned verbose)
 					if (j >= p->p_types.nprim)
 						goto bad;
 
-					if (p->type_val_to_struct[i]->flavor == TYPE_ATTRIB) {
+					if (p->type_val_to_struct[i] && p->type_val_to_struct[i]->flavor == TYPE_ATTRIB) {
 						ERR(fp->handle, "Invalid to have type attributes associated with an attribute for a kernel policy");
 						goto bad;
 					}
-- 
2.52.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] libsepol: Fix potential NULL dereference in policydb_read()
  2026-01-22 16:45 [PATCH] libsepol: Fix potential NULL dereference in policydb_read() James Carter
@ 2026-01-26  1:49 ` Jason Zaman
  0 siblings, 0 replies; 2+ messages in thread
From: Jason Zaman @ 2026-01-26  1:49 UTC (permalink / raw)
  To: James Carter; +Cc: selinux

On Thu, Jan 22, 2026 at 11:45:45AM -0500, James Carter wrote:
> Since there can be gaps in the type_val_to_struct array for very
> old policies (version < POLICYDB_VERSION_BOUNDARY), need to
> that it is not NULL for a particular index before using.
> 
> Reported-by: oss-fuzz (issue 474424148)
> Signed-off-by: James Carter <jwcart2@gmail.com>
Signed-off-by: Jason Zaman <jason@perfinion.com>

Thanks, applied.
> ---
>  libsepol/src/policydb.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/libsepol/src/policydb.c b/libsepol/src/policydb.c
> index 6aaa18f2..9760b164 100644
> --- a/libsepol/src/policydb.c
> +++ b/libsepol/src/policydb.c
> @@ -4513,7 +4513,7 @@ int policydb_read(policydb_t * p, struct policy_file *fp, unsigned verbose)
>  					if (j >= p->p_types.nprim)
>  						goto bad;
>  
> -					if (p->type_val_to_struct[i]->flavor == TYPE_ATTRIB) {
> +					if (p->type_val_to_struct[i] && p->type_val_to_struct[i]->flavor == TYPE_ATTRIB) {
>  						ERR(fp->handle, "Invalid to have type attributes associated with an attribute for a kernel policy");
>  						goto bad;
>  					}
> -- 
> 2.52.0
> 
> 

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-01-26  1:49 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-01-22 16:45 [PATCH] libsepol: Fix potential NULL dereference in policydb_read() James Carter
2026-01-26  1:49 ` Jason Zaman

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox