Skip to contentSkip to conversation

selinux: keep context struct members in sync

PATCH Applied Christian Göttsche 2 participants 2 messages May 11, 2023 – May 18, 2023 SELinux security module

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 selinux: keep context struct members in sync

Commit 53f3517ae087 ("selinux: do not leave dangling pointer behind") reset the str field of the context struct in an OOM error branch. In this struct the fields str and len are coupled and should be kept in sync. Set the length to zero according to the string be set to NULL.

Fixes 53f3517ae087 ("selinux: do not leave dangling pointer behind")
---
 security/selinux/ss/context.h | 1 +
 1 file changed, 1 insertion(+)
security/selinux/ss/context.h +1 -0
index 44179977f434..aed704b8c642 100644
@@ -168,6 +168,7 @@ static inline int context_cpy(struct context *dst, const struct context *src)
 	if (rc) {
 		kfree(dst->str);
 		dst->str = NULL;
+		dst->len = 0;
 		return rc;
 	}
 	return 0;
Signature · 1 line
2.40.1
maintainer Applied
#1 lore raw
Quoted 11 lines · On May 11, 2023 =?UTF-8?q?Christian=20G=C3=B6ttsche?= <[email protected]>…

Commit 53f3517ae087 ("selinux: do not leave dangling pointer behind") reset the str field of the context struct in an OOM error branch. In this struct the fields str and len are coupled and should be kept in sync. Set the length to zero according to the string be set to NULL.

Fixes 53f3517ae087 ("selinux: do not leave dangling pointer behind")
---
 security/selinux/ss/context.h | 1 +
 1 file changed, 1 insertion(+)

Merged into selinux/next, thanks.

--
paul-moore.com