commit 7adee1139fa756f8e6c278bc5ec302e4ea4cc282
tree f21cebb9ae25735ad46cc6784d1e28bda119e292
parent efa8332f502f2a624fd32fd6cf9e542f2429c578
author Po-Hsu Lin via ltp <ltp@lists.linux.it> 2026-01-07 16:06:59 +0800
committer Andrea Cervesato <andrea.cervesato@suse.com> 2026-01-07 10:03:18 +0100

    tst_security.c: fix lsm parsing failure due to uninitialized buffer
    
    The tst_lsm_enabled() function reads /sys/kernel/security/lsm into an
    uninitialized local stack buffer. The dirty stack might cause incorrect
    parsing results for the last LSM and make string comparison to fail.
    
    This issue was found on Ubuntu Noble 6.8.0-93.95 ppc64el, where apparmor
    is the last LSM in the list:
    
      $ od -c /sys/kernel/security/lsm
      0000000   l   o   c   k   d   o   w   n   ,   c   a   p   a   b   i   l
      0000020   i   t   y   ,   l   a   n   d   l   o   c   k   ,   y   a   m
      0000040   a   ,   a   p   p   a   r   m   o   r
      0000052
    
    But this issue makes it fail to parse the apparmor string correctly, and
    leads to a lsm_get_self_attr02 test failure.
    
    This can be reproduced by poisioning the memory with a non-null character,
    along with the "selinux", "apparmor", or "smack" to be the last LSM in the
    list.
    
    Test will pass after zeroing out the buffer before reading.
    
    Reviewed-by: Andrea Cervesato <andrea.cervesato@suse.com>
    Signed-off-by: Po-Hsu Lin <po-hsu.lin@canonical.com>


:100644 100644 c515271351bbc3126e58feef28dc2a88f2d40509 00be4d72e2f3fe8fb6ab62561c00d4bb58540c16 M	lib/tst_security.c
