]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
selinux: fix selinux_xfrm_alloc_user() to set correct ctx_len
authorStephen Smalley <stephen.smalley.work@gmail.com>
Fri, 13 Jun 2025 19:37:05 +0000 (15:37 -0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 27 Jun 2025 10:05:34 +0000 (11:05 +0100)
commit6500f360a435256e77a5ee8792db81c86438bc97
tree3ee6947aeb78f963abb6603698870d297a8b17be
parent06780dbaa92921a82f9257b8f173c19304375195
selinux: fix selinux_xfrm_alloc_user() to set correct ctx_len

commit 86c8db86af43f52f682e53a0f2f0828683be1e52 upstream.

We should count the terminating NUL byte as part of the ctx_len.
Otherwise, UBSAN logs a warning:
  UBSAN: array-index-out-of-bounds in security/selinux/xfrm.c:99:14
  index 60 is out of range for type 'char [*]'

The allocation itself is correct so there is no actual out of bounds
indexing, just a warning.

Cc: stable@vger.kernel.org
Suggested-by: Christian Göttsche <cgzones@googlemail.com>
Link: https://lore.kernel.org/selinux/CAEjxPJ6tA5+LxsGfOJokzdPeRomBHjKLBVR6zbrg+_w3ZZbM3A@mail.gmail.com/
Signed-off-by: Stephen Smalley <stephen.smalley.work@gmail.com>
Signed-off-by: Paul Moore <paul@paul-moore.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
security/selinux/xfrm.c