* [PATCH] selinux: keep context struct members in sync
@ 2023-05-11 12:31 Christian Göttsche
2023-05-18 17:39 ` Paul Moore
0 siblings, 1 reply; 2+ messages in thread
From: Christian Göttsche @ 2023-05-11 12:31 UTC (permalink / raw)
To: selinux; +Cc: Paul Moore, Stephen Smalley, Eric Paris, linux-kernel
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")
Signed-off-by: Christian Göttsche <cgzones@googlemail.com>
---
security/selinux/ss/context.h | 1 +
1 file changed, 1 insertion(+)
diff --git a/security/selinux/ss/context.h b/security/selinux/ss/context.h
index 44179977f434..aed704b8c642 100644
--- a/security/selinux/ss/context.h
+++ b/security/selinux/ss/context.h
@@ -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;
--
2.40.1
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2023-05-18 17:39 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-05-11 12:31 [PATCH] selinux: keep context struct members in sync Christian Göttsche
2023-05-18 17:39 ` Paul Moore
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®