package/refpolicy: Add option to disable "dontaudit" rules
PATCH 1/1 package/refpolicy: Add option to disable "dontaudit" rules
Some rules in the refpolicy are declared with "dontaudit", effectively suppressing any AVC violation log, while still denying the actions.
This is useful in some cases, where denied actions are to be expected but won't prevent the system from operating.
However in some other cases, the suppressed logs are important to troubleshoot some issues.
Disabling the "dontaudit" rules can be done either from the running system by rebuilding the policy with "semodules -DB", or when initialy building the policy by using the "enableaudit" make target.
This commit allows building the refpolicy with the "enableaudit" target prior to installing it, thanks to a dedicated config option.
--- package/refpolicy/Config.in | 14 ++++++++++++++ package/refpolicy/refpolicy.mk | 6 +++++- 2 files changed, 19 insertions(+), 1 deletion(-)
package/refpolicy/Config.in +14 -0
@@ -111,6 +111,20 @@ config BR2_REFPOLICY_EXTRA_MODULES endif +config BR2_REFPOLICY_DISABLE_DONTAUDIT + bool "Disable dontaudit" + help + Builds the refpolicy with the "dontaudit" rules disabled. + This will trigger unseen, and probably unharmful audit logs that are + explicitely silenced otherwise. This option can be helpful for + debugging purposes, should a silenced message cause a real issue + that would otherwise be hard to troubleshoot. + + This option should be used for debugging purposes only, due to + the amount of avc logs it generates. + + If unsure, select n. + endif comment "refpolicy needs a toolchain w/ threads"
package/refpolicy/refpolicy.mk +5 -1
@@ -34,6 +34,9 @@ REFPOLICY_MAKE = \ $(TARGET_MAKE_ENV) \ $(MAKE1) +REFPOLICY_EXTRA_MAKE_INSTALL_TARGETS = \ + $(if $(BR2_REFPOLICY_DISABLE_DONTAUDIT),enableaudit) + REFPOLICY_POLICY_VERSION = $(BR2_PACKAGE_LIBSEPOL_POLICY_VERSION) REFPOLICY_POLICY_STATE = \ $(call qstrip,$(BR2_PACKAGE_REFPOLICY_POLICY_STATE))
@@ -122,7 +125,8 @@ define REFPOLICY_INSTALL_STAGING_CMDS endef define REFPOLICY_INSTALL_TARGET_CMDS - $(REFPOLICY_MAKE) -C $(@D) DESTDIR=$(TARGET_DIR) install + $(REFPOLICY_MAKE) -C $(@D) DESTDIR=$(TARGET_DIR) \ + $(REFPOLICY_EXTRA_MAKE_INSTALL_TARGETS) install $(INSTALL) -m 0755 -D package/refpolicy/config \ $(TARGET_DIR)/etc/selinux/config $(SED) "/^SELINUX=/c\SELINUX=$(REFPOLICY_POLICY_STATE)" \
Signature · 1 line
2.25.4
PATCH 1/1 package/refpolicy: Add option to disable "dontaudit" rules
Quoted 9 lines · On Wed, 27 Jan 2021 10:56:27 +0100 Maxime Chevallier…
Some rules in the refpolicy are declared with "dontaudit", effectively suppressing any AVC violation log, while still denying the actions.
This is useful in some cases, where denied actions are to be expected but won't prevent the system from operating.
However in some other cases, the suppressed logs are important to troubleshoot some issues.
Quoted 8 lines
Disabling the "dontaudit" rules can be done either from the running system by rebuilding the policy with "semodules -DB", or when initialy building the policy by using the "enableaudit" make target.
This commit allows building the refpolicy with the "enableaudit" target prior to installing it, thanks to a dedicated config option.
Signed-off-by Maxime Chevallier <[email protected]>
Thanks for the patch!
package/refpolicy/refpolicy.mk define REFPOLICY_INSTALL_STAGING_CMDS · line 129
Quoted 4 lines
define
REFPOLICY_INSTALL_TARGET_CMDSpackage/refpolicy/refpolicy.mk +2
-1- $(REFPOLICY_MAKE) -C $(@D) DESTDIR=$(TARGET_DIR) install + $(REFPOLICY_MAKE) -C $(@D) DESTDIR=$(TARGET_DIR) \ + $(REFPOLICY_EXTRA_MAKE_INSTALL_TARGETS) install
The INSTALL_TARGET_CMDS should normally only *install* the policy. The policy is built in BUILD_CMDS. In commit fb2968707bc66afb2c246d92e15f295475f23868, Antoine did some effort to make sure that the policy gets built in BUILD_CMDS, and not in the install, so it would be good to keep this behavior.
That being said, I'm not clear between what the "policy" make target does (invoked in BUILD_CMDS) and what the "enableaudit" make target does.
Thomas
Signature · 3 lines
Thomas Petazzoni, CTO, Bootlin Embedded Linux and Kernel engineering https://bootlin.com
PATCH 1/1 package/refpolicy: Add option to disable "dontaudit" rules
Quoting Thomas Petazzoni (2021-01-27 11:01:48)
Quoted 11 lines
package/refpolicy/refpolicy.mk define REFPOLICY_INSTALL_STAGING_CMDS · line 129
Quoted 4 lines · On Wed, 27 Jan 2021 10:56:27 +0100 Maxime Chevallier…
define
REFPOLICY_INSTALL_TARGET_CMDSpackage/refpolicy/refpolicy.mk +2
-1- $(REFPOLICY_MAKE) -C $(@D) DESTDIR=$(TARGET_DIR) install + $(REFPOLICY_MAKE) -C $(@D) DESTDIR=$(TARGET_DIR) \ + $(REFPOLICY_EXTRA_MAKE_INSTALL_TARGETS) installThat being said, I'm not clear between what the "policy" make target does (invoked in
BUILD_CMDS) and what the "enableaudit" make target does.
The 'policy' target generates a policy.conf file (among other things) and 'enableaudit' removes lines from this file. While 'enableaudit' seems like a configuration step, it is in fact a fixup one.
Maybe a POST_BUILD_HOOK would be better for that?
On a side note, there is no dependency between 'enableaudit' and 'install'. The above change only works because REFPOLICY_MAKE uses MAKE1. (We have the same construct in the configuration step).
Antoine
PATCH 1/1 package/refpolicy: Add option to disable "dontaudit" rules
Hi Antoine, Thomas,
Thanks for the reviews !
Quoted 13 lines · On Wed, 27 Jan 2021 11:34:35 +0100 Antoine Tenart <[email protected]> wrote:
Quoting Thomas Petazzoni (2021-01-27 11:01:48)
Quoted 11 lines
package/refpolicy/refpolicy.mk define REFPOLICY_INSTALL_STAGING_CMDS · line 129
Quoted 4 lines · On Wed, 27 Jan 2021 10:56:27 +0100 Maxime Chevallier…
define
REFPOLICY_INSTALL_TARGET_CMDSpackage/refpolicy/refpolicy.mk +2
-1- $(REFPOLICY_MAKE) -C $(@D) DESTDIR=$(TARGET_DIR) install + $(REFPOLICY_MAKE) -C $(@D) DESTDIR=$(TARGET_DIR) \ + $(REFPOLICY_EXTRA_MAKE_INSTALL_TARGETS) installThat being said, I'm not clear between what the "policy" make target does (invoked in
BUILD_CMDS) and what the "enableaudit" make target does.
Quoted 5 lines
The 'policy' target generates a policy.conf file (among other things) and 'enableaudit' removes lines from this file. While 'enableaudit' seems like a configuration step, it is in fact a fixup one.
Maybe a
POST_BUILD_HOOKwould be better for that?
You're correct, it seems to be a better way to go, I'll send a v2 with that solution :)
Thanks,
Maxime
Quoted 5 lines
On a side note, there is no dependency between 'enableaudit' and 'install'. The above change only works because
REFPOLICY_MAKEuses MAKE1. (We have the same construct in the configuration step).Antoine
Signature · 3 lines
Maxime Chevallier, Bootlin Embedded Linux and kernel engineering https://bootlin.com