]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
selinux: keep context struct members in sync
authorChristian Göttsche <cgzones@googlemail.com>
Thu, 11 May 2023 12:31:47 +0000 (14:31 +0200)
committerPaul Moore <paul@paul-moore.com>
Thu, 18 May 2023 17:38:39 +0000 (13:38 -0400)
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>
Signed-off-by: Paul Moore <paul@paul-moore.com>
security/selinux/ss/context.h

index 44179977f434ccd8ac8016ca7cbf834d86b5286d..aed704b8c6426f780aa44b6cee7b29ecc16177bb 100644 (file)
@@ -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;