From: Christian Göttsche Date: Thu, 11 May 2023 12:31:47 +0000 (+0200) Subject: selinux: keep context struct members in sync X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=ed99135f7621459ef873991115372ba1afe88a04;p=linux.git 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") Signed-off-by: Christian Göttsche Signed-off-by: Paul Moore --- diff --git a/security/selinux/ss/context.h b/security/selinux/ss/context.h index 44179977f434c..aed704b8c6426 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;