From patchwork Tue Nov 24 11:41:37 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chen Qi X-Patchwork-Id: 105396 Received: from cetc.com.cn (cetc.com.cn [220.181.39.39]) by mx.groups.io with SMTP id smtpd.msgproc01-g2.15943.1795520516614188248 for ; Tue, 24 Nov 2026 03:41:57 -0800 Authentication-Results: mx.groups.io; dkim=none (message not signed); spf=pass (domain: cetc.com.cn, ip: 220.181.39.39, mailfrom: chenqi_hycx@cetc.com.cn) Received: from mail.cetc.com.cn (unknown [123.125.172.206]) by mtasvr (Coremail) with SMTP id _____wAHMWB3dwVrRdQAAA--.4185S3; Tue, 24 Nov 2026 19:39:35 +0800 (CST) Received: from chenqi-Redmi.. (unknown [123.125.172.206]) by front01 (Coremail) with SMTP id C6CowACXKWr5dwVrLcFAAA--.28459S6; Tue, 24 Nov 2026 19:41:50 +0800 (CST) From: chenqi_hycx@cetc.com.cn To: yocto-patches@lists.yoctoproject.org Cc: chen_q07@163.com Subject: [meta-selinux][PATCH 4/4] refpolicy: run selint over the policy sources Date: Tue, 24 Nov 2026 19:41:37 +0800 Message-ID: <20261124114137.2203106-5-chenqi_hycx@cetc.com.cn> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20261124114137.2203106-1-chenqi_hycx@cetc.com.cn> References: <20261124114137.2203106-1-chenqi_hycx@cetc.com.cn> MIME-Version: 1.0 X-CM-TRANSID: C6CowACXKWr5dwVrLcFAAA--.28459S6 X-CM-SenderInfo: xfkh015lbk5un06fv33fof0zgofq/1tbiAgYBCmsEQRspEwAAsA X-CM-DELIVERINFO: =?B?kzOgTac9tbm9bwt5VqgwP2Pu2dSP9LtrOQxHOAXUJl/eWtrOBydmTZkAAV6p44o2Ir PoOOlI2Du8d65gBCGhVRqdwZXxbs2EkPD7wReo4SgJeaGZRqxzCf5ZXoVyqvWm4+cYuE2F g9m7v2rCZYab04BYzZXvq/Oy/3z4zCRlZrQ78qjqv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jxVAFwI0_Gr0_Gr1UYxBIdaVFxhVjvjDU0xZF pf9x07j7hL8UUUUU= List-Id: X-Webhook-Received: from 45-33-107-173.ip.linodeusercontent.com [45.33.107.173] by lin-tor-korg-lkml-alma10-1 with HTTPS for ; Tue, 24 Nov 2026 11:42:02 -0000 X-Groupsio-URL: https://lists.yoctoproject.org/g/yocto-patches/message/5504 From: Chen Qi Lint the policy sources so that a local patch introducing a SELint finding fails the build instead of silently reaching the image. The check runs after do_compile, which leaves behind the modules.conf and the generated files that selint wants in source mode; the check then only reads ${S}. Hanging it off do_compile also keeps it correct under devtool: externalsrc puts the source tree in do_compile's file-checksums, so an edited source re-runs do_compile and with it the check. do_selint is deliberately not [nostamp]. A task that always runs invalidates its dependents, so every bitbake invocation would redo compile, install and packaging. A .bbappend can set do_selint[noexec] = "1" to skip the check. The config is selint's default plus the three checks that refpolicy CI disables (C-005, C-008, W-005). Assisted-by: Codewhale:deepseek-flash Signed-off-by: Chen Qi --- recipes-security/refpolicy/files/selint.conf | 16 ++++++++++++++++ recipes-security/refpolicy/refpolicy_common.inc | 11 ++++++++++- 2 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 recipes-security/refpolicy/files/selint.conf diff --git a/recipes-security/refpolicy/files/selint.conf b/recipes-security/refpolicy/files/selint.conf new file mode 100644 index 0000000..0bb14cf --- /dev/null +++ b/recipes-security/refpolicy/files/selint.conf @@ -0,0 +1,16 @@ +# Plain copy of selint v1.5.1's default config, plus refpolicy CI's disables. +# -c replaces the installed config, so re-sync this when bumping SRCREV. + +severity = "convention" + +# C-005, C-008 and W-005 are disabled like in refpolicy's lint-policy CI. +disable = { C-001, C-005, C-006, C-008, W-005, W-010, W-011, E-003, E-004 } + +enable_source = { W-010, W-011, E-003, E-004 } + +assume_users = { system_u } +assume_roles = { object_r } + +ordering_rules = "refpolicy-lax" +ordering_requires = { bool, attribute, attribute_role, type, class, role } +ordering_requires_same_flavor = false diff --git a/recipes-security/refpolicy/refpolicy_common.inc b/recipes-security/refpolicy/refpolicy_common.inc index be0aa83..c9d752b 100644 --- a/recipes-security/refpolicy/refpolicy_common.inc +++ b/recipes-security/refpolicy/refpolicy_common.inc @@ -10,6 +10,7 @@ RPROVIDES:${PN} = "refpolicy" SRC_URI += "file://customizable_types \ file://setrans-mls.conf \ file://setrans-mcs.conf \ + file://selint.conf \ " # Base patches applied to all Yocto-based platforms. Your own version of @@ -94,7 +95,7 @@ FILES:${PN}-dev =+ " \ EXTRANATIVEPATH += "bzip2-native" -DEPENDS = "bzip2-replacement-native checkpolicy-native policycoreutils-native semodule-utils-native m4-native" +DEPENDS = "bzip2-replacement-native checkpolicy-native policycoreutils-native semodule-utils-native m4-native selint-native" RDEPENDS:${PN}-dev = " \ python3-core \ @@ -192,6 +193,14 @@ set_policy_booleans() { done } +# Lint the policy sources so that a SELint finding fails the build. +do_selint() { + cd ${S} + selint -c ${UNPACKDIR}/selint.conf \ + --source --recursive --summary --fail policy +} +addtask selint after do_compile before do_install + do_compile() { oe_runmake bare if [ -f "${WORKDIR}/modules.conf" ] ; then