Re: [PATCH v3 8/8] selftests/lsm: add lockdown securityfs test
From: Guicai Ma
Date: Thu Nov 26 2026 - 21:10:48 EST
On Thu, Nov 26, 2026 at 09:13:15PM +0800, Cai Xinchen wrote:
> +run_lockdown_test: all
> + $(call RUN_TESTS, lockdown_test)
As Sashiko noted, out-of-tree builds fail here because the binary lives
under $(OUTPUT). Running with OUTPUT= set produces:
# Warning: file lockdown_test is missing!
not ok 1 selftests: lsm: lockdown_test
Using $(OUTPUT)/lockdown_test here works both in-tree and out-of-tree.
> + if (geteuid() != 0)
> + SKIP(return, "requires root");
> + if (status_writable())
> + SKIP(return, "cannot open %s for writing: %s",
> + LOCKDOWN_PATH, strerror(errno));
Having both checks in FIXTURE_SETUP() makes non-root runs skip
read_format as well, leaving the 0644 / open(O_WRONLY) EACCES behavior
documented in 7/8 uncovered. Moving the write/root gate out of
read_format (or adding an unprivileged open() check) would cover that
part of the ABI too.
I also ran the lockdown_test binary under QEMU/KVM on arm64 (mainline
9437ee8b6cf6 with this series applied, KASAN + lockdep,
CONFIG_SECURITY_LOCKDOWN_LSM=y). Under lsm=lockdown, uid 65534 skipped
all 5 cases, while root runs passed none -> integrity (5/5),
integrity -> confidentiality (5/5), and confidentiality (4 pass, 1 skip
on upgrade). Booting with lsm=yama skipped all 5 cases on ENOENT, with
no KASAN or lockdep warnings.
Thanks,
Guicai Ma