From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=113.46.200.225 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796025493; b=GzfTqh6CEXt7V2MzmUvVzADQcvTnliGGYmk9yNO+Zh6QjKtcXKAogVBVybMYG+CY4zoy 9gtJfef0KzW03N/x9uRk7UwPWlBmDKyrv3XfbmwLxzjrorPVZ0cRChRONvXnEfyHZN/PH yBP+gow712jCmev9yTIxIcY8V3XCoJZolE05ipwdCk7qNd39V4ctb9YO1uQqwmVziE6UY VGqcs45IiBHmNQ7DcKwytsbMSM8LhfwzoSLR7mXK6q+vmxSYXATwlI//mct5AivdS6fn7 PhmD8PqkYo672o/HieNnF4Dby3O+EkGxqRUJ9v7TTjDdn2/WYNzNQFsfE+QmHr+8wLw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796025493; h=DMARC-Filter:dkim-signature:Received:Received:Received:From:To:CC: Subject:Date:Message-ID:X-Mailer:MIME-Version:Content-Type: X-Originating-IP:X-ClientProxiedBy; bh=yqllMa5rfUJen3GjvGqldiTZh3n69gtA5QHgSRD58Hg=; b=NxrpTkMqhAAnGLLYF236twsyh3xI1pp/toOTxCVRKfj+8ztnmPhQENayaaUWbomvka5L PAex85qdDEkKOkgmK+cRY9hDYF0TODCKilLpNPyv6WBkt6lHeQTg1laj1RM9dKcKBGW8L jRYUU7L5513sWVn73bChPBf7tXkh9vEF/9N9oorLG4i8mb911oDVJWX742QeczsbR4les UX5pdA6dKhIksfQ0KXThlmlXf4ittWMtJBk9WF7+LujmcT8kJ5M/xnBqF+HkeZesdhleT s08J/EbIvsO+Nysl97BiODv4tL7t9dwhPWUflsr92+qfUZ2o9djND42VimYzL9AHJ3w== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; dkim=pass header.d=huawei.com header.i=@huawei.com header.a=rsa-sha256 header.s=dkim header.b=Vu8tQ9os; arc=none smtp.remote-ip=113.46.200.225 Received: from canpmsgout10.his.huawei.com (canpmsgout10.his.huawei.com [113.46.200.225]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2C93360A260B; Mon, 30 Nov 2026 07:58:12 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 2C93360A260B Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=huawei.com header.i=@huawei.com header.a=rsa-sha256 header.s=dkim header.b=Vu8tQ9os dkim-signature: v=1; a=rsa-sha256; d=huawei.com; s=dkim; c=relaxed/relaxed; q=dns/txt; h=From; bh=yqllMa5rfUJen3GjvGqldiTZh3n69gtA5QHgSRD58Hg=; b=Vu8tQ9os6qtDhnARgK1kUCrjA+vhsrmDWnckHp3fX1AzAj2idNMcdS7RFCVcR6mFwmpefOm7Q 26NhQcyiSa0lcIJA7BqEHJpp4q3dooBEw2CH6e7Nlyi8j1XZI/Y1o7JfMarpQmas2kWTfmLoCk9 WgYkxUplIpFOSoNpJQH0BWE= Received: from mail.maildlp.com (unknown [172.19.162.92]) by canpmsgout10.his.huawei.com (SkyGuard) with ESMTPS id 4jdGb510G8z1K98D; Mon, 30 Nov 2026 15:57:37 +0800 (CST) Received: from whupemk100010.china.huawei.com (unknown [7.152.184.41]) by mail.maildlp.com (Postfix) with ESMTPS id 290AB40565; Mon, 30 Nov 2026 15:57:58 +0800 (CST) Received: from octopus.huawei.com (10.67.174.191) by whupemk100010.china.huawei.com (7.152.184.41) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.56; Mon, 30 Nov 2026 15:57:56 +0800 From: Cai Xinchen To: , , , , , , , , CC: , , , , Subject: [PATCH v4 0/8] lockdown: fix the securityfs interface and add tests Date: Mon, 30 Nov 2026 16:29:06 +0800 Message-ID: <20261130082914.129495-1-caixinchen1@huawei.com> X-Mailer: git-send-email 2.18.0.huawei.25 X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain X-ClientProxiedBy: kwepems500002.china.huawei.com (7.221.188.17) To whupemk100010.china.huawei.com (7.152.184.41) 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, an upgrade to the next level, and the EACCES that an unprivileged writer gets at open() time. The only functional change is patch 3; the rest are cleanups, documentation, or test coverage. Changes since v3: - The selftests Makefile passes $(OUTPUT)/lockdown_test to RUN_TESTS, so that the "make run_lockdown_test" target also works with an out-of-tree OUTPUT directory, as reported by Guicai Ma. - The root and writability checks moved from the selftest fixture setup into the tests that write, and a new test checks that an unprivileged open for writing fails with EACCES, so that runs as an unprivileged user also cover the 0644 mode documented in 7/8, as suggested by Guicai Ma. - The new test fails instead of skipping when an unprivileged open unexpectedly succeeds, skipping when the task holds CAP_DAC_OVERRIDE or its capabilities cannot be queried, and read_format() checks the exact documented status format instead of the mere occurrence of the level names (Sashiko). - The selftest config fragment enables CONFIG_SECURITY_LOCKDOWN_LSM_EARLY, so that the lockdown LSM is ordered in even when another fragment pins CONFIG_LSM without it (Sashiko). 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 | 2 + tools/testing/selftests/lsm/lockdown_test.c | 272 ++++++++++++++++++ 13 files changed, 436 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