From: Cai Xinchen <caixinchen1@huawei.com>
To: <nicolas.bouchinet@oss.cyber.gouv.fr>, <xiujianfeng@huawei.com>,
<paul@paul-moore.com>, <jmorris@namei.org>, <serge@hallyn.com>,
<shuah@kernel.org>, <kalevi@kolttonen.fi>,
<caixinchen1@huawei.com>
Cc: <linux-security-module@vger.kernel.org>,
<linux-kernel@vger.kernel.org>, <linux-kselftest@vger.kernel.org>,
<bpf@vger.kernel.org>, <lujialin4@huawei.com>
Subject: [PATCH v3 0/8] lockdown: fix the securityfs interface and add tests
Date: Thu, 26 Nov 2026 21:13:07 +0800 [thread overview]
Message-ID: <20261126131315.1256553-1-caixinchen1@huawei.com> (raw)
The lockdown LSM provides /sys/kernel/security/lockdown, but the file is
neither documented nor covered by a selftest. While reviewing the
interface, we also found a Kconfig bug and a few accumulated cleanups.
The series is organized as follows:
- patches 1-2 are small cleanups in lockdown_write(): stop scanning
after the matching level, and drop an update to a length variable
that is not used afterwards.
- patch 3 makes the LSM select SECURITYFS. Without it, a kernel built
with CONFIG_SECURITYFS=n logs "failed LSM lockdown core initcall
with
errno -19" and does not create the file that the
LOCK_DOWN_KERNEL_FORCE_NONE help text points users at.
- patch 4 removes LSM_AUDIT_DATA_LOCKDOWN and its formatting code,
which became dead when the SELinux lockdown implementation was
removed by commit f5d0e5e9d72d.
- patch 5 drops an unused include and moves lockdown_reasons[] next to
its only user.
- patch 6 replaces sprintf() with scnprintf() and sizes the status
buffer for the string it holds, whose length is the same whichever
level is active: all level labels with their trailing spaces, the
brackets around the active one, and the terminating NUL.
- patch 7 documents the ABI and adds the new file to the LOCKDOWN
SECURITY MODULE entry in MAINTAINERS.
- patch 8 adds a kselftest covering the read format, invalid levels,
the rejection of the current or a lower level, and an upgrade to the
next level.
The only functional change is patch 3; the rest are cleanups,
documentation, or test coverage.
Changes since v2:
- The scnprintf() patch sizes the status buffer from the label lengths
instead of keeping temp[80] with a BUILD_BUG_ON() (Serge E. Hallyn).
- The selftest read_file() helper reads up to size bytes again and
rejects a completely filled buffer, so read_sysfs_lsms() keeps
failing when its buffer is too small (Nicolas Bouchinet).
- The selftest read, root and writable checks moved into a
FIXTURE_SETUP, and the upgrade test now runs before the tests that
expect an already locked down kernel, so they never run at the none
level (Nicolas Bouchinet).
- The ABI documentation now mentions the legacy "security=" kernel
parameter as another way to order in the lockdown LSM, and now also
documents the 0644 file mode, so an unprivileged writer can tell
the EACCES at open() time apart from the EPERM and EINVAL that
lockdown_write() itself returns.
- Clarified the changelogs of patches 1-3: the break in
lockdown_write() is now described as leaving the loop instead of
returning early, the useless decrement patch gained a commit
description, and the SECURITYFS patch now points at the
LOCK_DOWN_KERNEL_FORCE_NONE help text that references the file.
Cai Xinchen (7):
lockdown: Add break in lockdown_write
lockdown: select SECURITYFS
lsm: remove unused lockdown audit data
lockdown: drop an unused include and move lockdown_reasons
lockdown: bound the status string with scnprintf
Documentation/ABI: document the lockdown securityfs file
selftests/lsm: add lockdown securityfs test
Kalevi Kolttonen (1):
lockdown: remove useless decrement operation
Documentation/ABI/testing/securityfs-lockdown | 47 +++++
MAINTAINERS | 1 +
include/linux/lsm_audit.h | 2 -
include/linux/security.h | 2 -
security/lockdown/Kconfig | 1 +
security/lockdown/lockdown.c | 73 ++++++-
security/lsm_audit.c | 4 -
security/security.c | 40 ----
tools/testing/selftests/lsm/Makefile | 8 +
tools/testing/selftests/lsm/common.c | 47 ++++-
tools/testing/selftests/lsm/common.h | 2 +
tools/testing/selftests/lsm/config | 1 +
tools/testing/selftests/lsm/lockdown_test.c | 191 ++++++++++++++++++
13 files changed, 354 insertions(+), 65 deletions(-)
create mode 100644 Documentation/ABI/testing/securityfs-lockdown
create mode 100644 tools/testing/selftests/lsm/lockdown_test.c
--
2.18.0.huawei.25
next reply other threads:[~2026-11-26 12:47 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-26 13:13 Cai Xinchen [this message]
2026-11-26 12:55 ` [PATCH v3 0/8] lockdown: fix the securityfs interface and add tests sashiko-bot
2026-11-26 13:13 ` [PATCH v3 1/8] lockdown: Add break in lockdown_write Cai Xinchen
2026-11-26 13:13 ` [PATCH v3 2/8] lockdown: remove useless decrement operation Cai Xinchen
2026-11-26 13:13 ` [PATCH v3 3/8] lockdown: select SECURITYFS Cai Xinchen
2026-11-26 13:13 ` [PATCH v3 4/8] lsm: remove unused lockdown audit data Cai Xinchen
2026-11-26 13:13 ` [PATCH v3 5/8] lockdown: drop an unused include and move lockdown_reasons Cai Xinchen
2026-11-26 13:13 ` [PATCH v3 6/8] lockdown: bound the status string with scnprintf Cai Xinchen
2026-11-26 12:52 ` sashiko-bot
2026-11-26 13:13 ` [PATCH v3 7/8] Documentation/ABI: document the lockdown securityfs file Cai Xinchen
2026-11-26 13:13 ` [PATCH v3 8/8] selftests/lsm: add lockdown securityfs test Cai Xinchen
2026-11-26 12:55 ` sashiko-bot
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261126131315.1256553-1-caixinchen1@huawei.com \
--to=caixinchen1@huawei.com \
--cc=bpf@vger.kernel.org \
--cc=jmorris@namei.org \
--cc=kalevi@kolttonen.fi \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=linux-security-module@vger.kernel.org \
--cc=lujialin4@huawei.com \
--cc=nicolas.bouchinet@oss.cyber.gouv.fr \
--cc=paul@paul-moore.com \
--cc=serge@hallyn.com \
--cc=shuah@kernel.org \
--cc=xiujianfeng@huawei.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox