Skip to contentSkip to conversation

selinux: set next pointer before attaching to list

PATCH In review Christian Göttsche 2 participants 2 messages Aug 18, 2023 SELinux security module

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 selinux: set next pointer before attaching to list

Set the next pointer in filename_trans_read_helper() before attaching the new node under construction to the list, otherwise garbage would be dereferenced on subsequent failure during cleanup in the out goto label.

Fixes 430059024389 ("selinux: implement new format of filename transitions")
---
 security/selinux/ss/policydb.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
security/selinux/ss/policydb.c +1 -1
index 28bd75dc6f71..2d528f699a22 100644
@@ -2009,6 +2009,7 @@ static int filename_trans_read_helper(struct policydb *p, void *fp)
 		if (!datum)
 			goto out;
 
+		datum->next = NULL;
 		*dst = datum;
 
 		/* ebitmap_read() will at least init the bitmap */
@@ -2021,7 +2022,6 @@ static int filename_trans_read_helper(struct policydb *p, void *fp)
 			goto out;
 
 		datum->otype = le32_to_cpu(buf[0]);
-		datum->next = NULL;
 
 		dst = &datum->next;
 	}
Signature · 1 line
2.40.1
maintainer
#1 lore raw
Quoted 10 lines · On Aug 18, 2023 =?UTF-8?q?Christian=20G=C3=B6ttsche?= <[email protected]>…

Set the next pointer in filename_trans_read_helper() before attaching the new node under construction to the list, otherwise garbage would be dereferenced on subsequent failure during cleanup in the out goto label.

Fixes 430059024389 ("selinux: implement new format of filename transitions")
---
 security/selinux/ss/policydb.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Thanks Christian, nice catch!

I'm going to merge this into selinux/stable-6.5 with a stable tag, and assuming all goes well with the automated testing I'll send this up to Linus early next week.

--
paul-moore.com