[PATCH v3 8/8] selftests/lsm: add lockdown securityfs test

Cai Xinchen caixinchen1 at huawei.com
Mon Nov 30 07:19:36 UTC 2026


Thanks for your review.

I will change $(call RUN_TESTS, lockdown_test) to $(call RUN_TESTS, 
$(OUTPUT)/lockdown_test) in v4. And I will add CAP_DAC_OVERRIDE check 
for non-root user and allow non-root user check read-format in v4.

Thanks for your tests.

On 11/27/2026 10:10 AM, Guicai Ma wrote:
> 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



More information about the Linux-security-module-archive mailing list