package/refpolicy: Add option to disable "dontaudit" rules
PATCH v2 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.
---
v1 -> v2: Use POST_BUILD_HOOKS to summon make enableaudit, as per Antoine Tenart adnd Thomas petazzoni's reviews
package/refpolicy/Config.in | 14 ++++++++++++++ package/refpolicy/refpolicy.mk | 8 ++++++++ 2 files changed, 22 insertions(+)
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 +8 -0
@@ -116,6 +116,14 @@ define REFPOLICY_BUILD_CMDS $(REFPOLICY_MAKE) -C $(@D) policy endef +ifeq ($(BR2_REFPOLICY_DISABLE_DONTAUDIT),y) +define REFPOLICY_DISABLE_DONTAUDIT_CMDS + $(REFPOLICY_MAKE) -C $(@D) enableaudit +endef +endif + +REFPOLICY_POST_BUILD_HOOKS += REFPOLICY_DISABLE_DONTAUDIT_CMDS + define REFPOLICY_INSTALL_STAGING_CMDS $(REFPOLICY_MAKE) -C $(@D) DESTDIR=$(STAGING_DIR) \ install-src install-headers
Signature · 1 line
2.25.4
PATCH v2 1/1 package/refpolicy: Add option to disable "dontaudit" rules
Quoting Maxime Chevallier (2021-01-28 13:52:56)
package/refpolicy/refpolicy.mk define REFPOLICY_BUILD_CMDS · line 125
Quoted 13 lines
package/refpolicy/refpolicy.mk +7
-0@@ -116,6 +116,14 @@ define REFPOLICY_BUILD_CMDS $(REFPOLICY_MAKE) -C $(@D) policy endef +ifeq ($(BR2_REFPOLICY_DISABLE_DONTAUDIT),y) +define REFPOLICY_DISABLE_DONTAUDIT_CMDS + $(REFPOLICY_MAKE) -C $(@D) enableaudit +endef +endif + +REFPOLICY_POST_BUILD_HOOKS += REFPOLICY_DISABLE_DONTAUDIT_CMDS
I think this could be in the ifeq block as well.
Otherwise, LGTM.
Thanks!
Antoine
PATCH v3 1/1 package/refpolicy: Add option to disable "dontaudit" rules
In reply to Maxime ChevallierFrom: Maxime Chevallier <[email protected]>
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.
---
Maxime:V1->V2:
* Use POST_BUILD_HOOKS to summon make enableaudit, as per Antoine Tenart and Thomas petazzoni's reviews
Giulio:V2->V3:
* moved REFPOLICY_POST_BUILD_HOOKS into ifeq/endef as suggested by Antoine Tenart
NOTE: this patch superseeds V2:
https://patchwork.ozlabs.org/project/buildroot/patch/[email protected]/
--- package/refpolicy/Config.in | 14 ++++++++++++++ package/refpolicy/refpolicy.mk | 7 +++++++ 2 files changed, 21 insertions(+)
package/refpolicy/Config.in +14 -0
@@ -113,6 +113,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, gcc >= 5, host gcc >= 5"
package/refpolicy/refpolicy.mk +7 -0
@@ -118,6 +118,13 @@ define REFPOLICY_BUILD_CMDS $(REFPOLICY_MAKE) -C $(@D) policy endef +ifeq ($(BR2_REFPOLICY_DISABLE_DONTAUDIT),y) +define REFPOLICY_DISABLE_DONTAUDIT_CMDS + $(REFPOLICY_MAKE) -C $(@D) enableaudit +endef +REFPOLICY_POST_BUILD_HOOKS += REFPOLICY_DISABLE_DONTAUDIT_CMDS +endif + define REFPOLICY_INSTALL_STAGING_CMDS $(REFPOLICY_MAKE) -C $(@D) DESTDIR=$(STAGING_DIR) \ install-src install-headers
Signature · 6 lines
2.25.1 _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot
package/refpolicy/Config.in config BR2_REFPOLICY_EXTRA_MODULES · line 117
Quoted 2 lines · On Wed, 19 Jan 2022 23:23:32 +0100 Giulio Benetti…
package/refpolicy/Config.in +2
-0+config BR2_REFPOLICY_DISABLE_DONTAUDIT + bool "Disable dontaudit"
I am still extremely confused by the name of option, with its double negative.
When enabled, this option will disable something that doesn't audit. Meh.
Is it possible to find a better name / description that doesn't make one's brain segfault when trying to understand what it does ?
The make target that gets triggered is "enableaudit". Would it make sense to call this option BR2_PACKAGE_REFPOLICY_ENABLE_AUDIT ?
It would be nice to get the feedback from Antoine and/or Maxime on this.
Thomas
Signature · 7 lines
Thomas Petazzoni, co-owner and CEO, Bootlin Embedded Linux and Kernel engineering and training https://bootlin.com _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot
Quoted 9 lines · Thomas Petazzoni
package/refpolicy/Config.in config BR2_REFPOLICY_EXTRA_MODULES · line 117
Quoted 2 lines · On Wed, 19 Jan 2022 23:23:32 +0100 Giulio Benetti…
package/refpolicy/Config.in +2
-0+config BR2_REFPOLICY_DISABLE_DONTAUDIT + bool "Disable dontaudit"I am still extremely confused by the name of option, with its double negative.
Quoted 8 lines
When enabled, this option will disable something that doesn't audit. Meh.
Is it possible to find a better name / description that doesn't make one's brain segfault when trying to understand what it does ?
The make target that gets triggered is "enableaudit". Would it make sense to call this option
BR2_PACKAGE_REFPOLICY_ENABLE_AUDIT?
I didn't check well the make argument..... Sorry. I agree with Thomas on changing the option variable to BR2_PACKAGE_REFPOLICY_ENABLE_AUDIT and name to:
"Enable audit"
And I would change the help section from:
``` Builds the refpolicy with the "dontaudit" rules disabled. This will trigger unseen, and ... ``` to: ``` Remove all dontaudit rules from policy.conf. This will trigger unseen, and ... ```
as reported in refpolicy README:
https://github.com/SELinuxProject/refpolicy/blob/master/README#L78
Quoted 1 line
It would be nice to get the feedback from Antoine and/or Maxime on this.
Following this since I'm not used to this package.
Best regards
Signature · 6 lines
Giulio Benetti Benetti Engineering sas _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot
Hello Thomas,
Quoted 11 lines · On Wed, 19 Jan 2022 23:39:44 +0100 Thomas Petazzoni…
package/refpolicy/Config.in config BR2_REFPOLICY_EXTRA_MODULES · line 117
Quoted 2 lines · On Wed, 19 Jan 2022 23:23:32 +0100 Giulio Benetti…
package/refpolicy/Config.in +2
-0+config BR2_REFPOLICY_DISABLE_DONTAUDIT + bool "Disable dontaudit"I am still extremely confused by the name of option, with its double negative.
When enabled, this option will disable something that doesn't audit. Meh.
I agree about the confusing double-negative, but it follows the SELinux terminology from the rules syntax. My personal view is that the "make enableaudit" target is a bit confusing already :)
Quoted 2 lines
Is it possible to find a better name / description that doesn't make one's brain segfault when trying to understand what it does ?
Maybe we can think of an option name like "BR2_REFPOLICY_VERBOSE_DONTAUDIT", suggesting that we're not silencing these 'dontaudit' rules anymore ? The only actual effect is what gets printed in the AVC logs.
Quoted 2 lines
The make target that gets triggered is "enableaudit". Would it make sense to call this option
BR2_PACKAGE_REFPOLICY_ENABLE_AUDIT?
The more I think about that, the more I think that using "enable/disable" here is misleading, the behaviour stays the same with regard to what gets denied/allow, only the logs are going to change.
Thanks,
Maxime
Quoted 3 lines
It would be nice to get the feedback from Antoine and/or Maxime on this.
Thomas
Signature · 7 lines
Maxime Chevallier, Bootlin Embedded Linux and kernel engineering https://bootlin.com _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot
Quoting Maxime Chevallier (2022-01-20 08:48:04)
Quoted 11 lines
Quoted 9 lines · On Wed, 19 Jan 2022 23:39:44 +0100 Thomas Petazzoni…
package/refpolicy/Config.in config BR2_REFPOLICY_EXTRA_MODULES · line 117
Quoted 2 lines · On Wed, 19 Jan 2022 23:23:32 +0100 Giulio Benetti…
package/refpolicy/Config.in +2
-0+config BR2_REFPOLICY_DISABLE_DONTAUDIT + bool "Disable dontaudit"I am still extremely confused by the name of option, with its double negative.
Quoted 6 lines
Quoted 2 lines
When enabled, this option will disable something that doesn't audit. Meh.
I agree about the confusing double-negative, but it follows the SELinux terminology from the rules syntax. My personal view is that the "make enableaudit" target is a bit confusing already :)
Agreed.
Quoted 8 lines
Quoted 2 lines
Is it possible to find a better name / description that doesn't make one's brain segfault when trying to understand what it does ?
Maybe we can think of an option name like "
BR2_REFPOLICY_VERBOSE_DONTAUDIT", suggesting that we're not silencing these 'dontaudit' rules anymore ? The only actual effect is what gets printed in the AVC logs.
Quoted 6 lines
Quoted 2 lines
The make target that gets triggered is "enableaudit". Would it make sense to call this option
BR2_PACKAGE_REFPOLICY_ENABLE_AUDIT?The more I think about that, the more I think that using "enable/disable" here is misleading, the behaviour stays the same with regard to what gets denied/allow, only the logs are going to change.
I would suggest using BR2_PACKAGE_REFPOLICY_WITH_DONTAUDIT, defaulting to y (using _WITHOUT_ would be less clear IMHO).
And in Kconfig something along the lines:
bool "Build with dontaudit rules"
default y
help
The refpolicy comes with 'dontaudit' rules suppressing audit logs for known and expected violations of the policy. These rules are enabled by default. Building without the 'dontaudit' rules will lead in more denied actions being logged, which can be useful for debugging purposes. Note that running 'semodules -DB' from a running system will have the same effect.
Say y if unsure.
(Please check the semodules part, never tried it).
WDYT?
Antoine
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
Hi Antoine, Maxime, Thomas, All,
Quoted 51 lines · Antoine Tenart
Quoting Maxime Chevallier (2022-01-20 08:48:04)
Quoted 11 lines
Quoted 9 lines · On Wed, 19 Jan 2022 23:39:44 +0100 Thomas Petazzoni…
package/refpolicy/Config.in config BR2_REFPOLICY_EXTRA_MODULES · line 117
Quoted 2 lines · On Wed, 19 Jan 2022 23:23:32 +0100 Giulio Benetti…
package/refpolicy/Config.in +2
-0+config BR2_REFPOLICY_DISABLE_DONTAUDIT + bool "Disable dontaudit"I am still extremely confused by the name of option, with its double negative.
Quoted 6 lines
Quoted 2 lines
When enabled, this option will disable something that doesn't audit. Meh.
I agree about the confusing double-negative, but it follows the SELinux terminology from the rules syntax. My personal view is that the "make enableaudit" target is a bit confusing already :)
Agreed.
Quoted 8 lines
Quoted 2 lines
Is it possible to find a better name / description that doesn't make one's brain segfault when trying to understand what it does ?
Maybe we can think of an option name like "
BR2_REFPOLICY_VERBOSE_DONTAUDIT", suggesting that we're not silencing these 'dontaudit' rules anymore ? The only actual effect is what gets printed in the AVC logs.Quoted 6 lines
Quoted 2 lines
The make target that gets triggered is "enableaudit". Would it make sense to call this option
BR2_PACKAGE_REFPOLICY_ENABLE_AUDIT?The more I think about that, the more I think that using "enable/disable" here is misleading, the behaviour stays the same with regard to what gets denied/allow, only the logs are going to change.
I would suggest using
BR2_PACKAGE_REFPOLICY_WITH_DONTAUDIT, defaulting to y (using _WITHOUT_ would be less clear IMHO).And in
Kconfigsomething along the lines:bool "Build with dontaudit rules"
default y
help
The refpolicy comes with 'dontaudit' rules suppressing audit logs for known and expected violations of the policy. These rules are enabled by default. Building without the 'dontaudit' rules will lead in more denied actions being logged, which can be useful for debugging purposes. Note that running 'semodules -DB' from a running system will have the same effect.
Quoted 5 lines
Say y if unsure.
(Please check the semodules part, never tried it).
WDYT?
Re-reading this after some day it looks to me like the simpleBR2_PACKAGE_REFPOLICY_ENABLEAUDIT is correct. Because it "Removes all dontaudit rules from policy.conf", so it's true that it enables audit logs in the end. It's a very specific options and the one who will use it will know what he will enable and most of all we can specify in the help section that:
"Removes all dontaudit rules from policy.conf"
It changes the perspective we are looking at it, but in the end, it "Removes all dontaudit rules from policy.conf" and subsequentially this leads to show the audits logs. So it enables audits.
Does it work for you?
Best regards
Signature · 6 lines
Giulio Benetti Benetti Engineering sas _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot
Quoting Giulio Benetti (2022-01-23 23:21:50)
Quoted 10 lines
Re-reading this after some day it looks to me like the simple
BR2_PACKAGE_REFPOLICY_ENABLEAUDITis correct. Because it "Removes all dontaudit rules from policy.conf", so it's true that it enables audit logs in the end. It's a very specific options and the one who will use it will know what he will enable and most of all we can specify in the help section that:
"Removes all dontaudit rules from policy.conf"Does it work for you?
As long as the help text is clear enough for the user, either config option name should be acceptable. Using the above is good to have an 1:1 mapping with the target name, at the expense of having the help text not matching it and an unclear option name from the user perspective (it's a bit weird not to enable it, at first). For _WITH_DONTAUDIT_, the opposite is true. I'd say there is no perfect solution, we can either stay close to the refpolicy internals or have the Buildroot specifics more consistent; not sure which is better.
Thanks,
Antoine
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
Quoted 15 lines
Il giorno 24 gen 2022, alle ore 09:45, Antoine Tenart <[email protected]> ha scritto:
Quoting Giulio Benetti (2022-01-23 23:21:50)
Quoted 10 lines
Re-reading this after some day it looks to me like the simple
BR2_PACKAGE_REFPOLICY_ENABLEAUDITis correct. Because it "Removes all dontaudit rules from policy.conf", so it's true that it enables audit logs in the end. It's a very specific options and the one who will use it will know what he will enable and most of all we can specify in the help section that:
"Removes all dontaudit rules from policy.conf"Does it work for you?
Quoted 8 lines
As long as the help text is clear enough for the user, either config option name should be acceptable. Using the above is good to have an 1:1 mapping with the target name, at the expense of having the help text not matching it and an unclear option name from the user perspective (it's a bit weird not to enable it, at first). For _WITH_DONTAUDIT_, the opposite is true. I'd say there is no perfect solution, we can either stay close to the refpolicy internals or have the Buildroot specifics more consistent; not sure which is better.
I’d go for Buildroot consistency since we’re in Buildroot. If someone enables refpolicy package and enables “Enable audit”, I expect to see audit log. Right?
This is me at least that I’ve never used refpolicy so I’m agnostic in the topic, so maybe a neutral “use case“ :-)
Best regards
Giulio
Quoted 7 lines
Thanks,
Antoine
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
Quoting Giulio Benetti (2022-01-24 09:59:45)
Quoted 24 lines
Quoted 15 lines
Il giorno 24 gen 2022, alle ore 09:45, Antoine Tenart <[email protected]> ha scritto:
Quoting Giulio Benetti (2022-01-23 23:21:50)
Quoted 10 lines
Re-reading this after some day it looks to me like the simple
BR2_PACKAGE_REFPOLICY_ENABLEAUDITis correct. Because it "Removes all dontaudit rules from policy.conf", so it's true that it enables audit logs in the end. It's a very specific options and the one who will use it will know what he will enable and most of all we can specify in the help section that:
"Removes all dontaudit rules from policy.conf"Does it work for you?
Quoted 8 lines
As long as the help text is clear enough for the user, either config option name should be acceptable. Using the above is good to have an 1:1 mapping with the target name, at the expense of having the help text not matching it and an unclear option name from the user perspective (it's a bit weird not to enable it, at first). For _WITH_DONTAUDIT_, the opposite is true. I'd say there is no perfect solution, we can either stay close to the refpolicy internals or have the Buildroot specifics more consistent; not sure which is better.
Quoted 1 line
I’d go for Buildroot consistency since we’re in Buildroot.
So _WITH_DONTAUDIT_?
Quoted 2 lines
If someone enables refpolicy package and enables “Enable audit”, I expect to see audit log. Right?
Extra audit log*
It's not about enabling audit logs, it's about having some known rules to not be silenced in the audit logs as they're known to be problematic.
Quoted 2 lines
This is me at least that I’ve never used refpolicy so I’m agnostic in the topic, so maybe a neutral “use case“ :-)
I don't really have a preference for either solution tbh.
Antoine
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
Quoted 28 lines
Il giorno 24 gen 2022, alle ore 10:07, Antoine Tenart <[email protected]> ha scritto:
Quoting Giulio Benetti (2022-01-24 09:59:45)
Quoted 24 lines
Quoted 23 lines
Quoted 2 lines
Il giorno 24 gen 2022, alle ore 09:45, Antoine Tenart <[email protected]> ha scritto:
Quoting Giulio Benetti (2022-01-23 23:21:50)
Quoted 10 lines
Re-reading this after some day it looks to me like the simple
BR2_PACKAGE_REFPOLICY_ENABLEAUDITis correct. Because it "Removes all dontaudit rules from policy.conf", so it's true that it enables audit logs in the end. It's a very specific options and the one who will use it will know what he will enable and most of all we can specify in the help section that:
"Removes all dontaudit rules from policy.conf"Does it work for you?
As long as the help text is clear enough for the user, either config option name should be acceptable. Using the above is good to have an 1:1 mapping with the target name, at the expense of having the help text not matching it and an unclear option name from the user perspective (it's a bit weird not to enable it, at first). For _WITH_DONTAUDIT_, the opposite is true. I'd say there is no perfect solution, we can either stay close to the refpolicy internals or have the Buildroot specifics more consistent; not sure which is better.
Quoted 8 lines
Quoted 1 line
I’d go for Buildroot consistency since we’re in Buildroot.
So _WITH_DONTAUDIT_?
Quoted 2 lines
If someone enables refpolicy package and enables “Enable audit”, I expect to see audit log. Right?
Extra audit log*
Aaah, here is the point ^^^.
Quoted 3 lines
It's not about enabling audit logs, it's about having some known rules to not be silenced in the audit logs as they're known to be problematic.
Ok, Thanks for the explanation.
Quoted 5 lines
Quoted 3 lines
This is me at least that I’ve never used refpolicy so I’m agnostic in the topic, so maybe a neutral “use case“ :-)
I don't really have a preference for either solution tbh.
Then I’d go for:BR2_PACKAGE_REFPOLICY_ENABLE_EXTRA_AUDIT_LOG
“Enable extra audit log”
And in the help section I specify all the warnings. Defaulted to n.
This way it’s pretty clear to me that I approach the package for the first time. And most of all it’s what it does as you’ve explained me above.
Well. I try to respin it this way. Will I receive a Reviewed-by: you then? :-)
Best regards
Giulio
Quoted 2 lines
Antoine
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
Quoting Giulio Benetti (2022-01-24 10:20:59)
Quoted 4 lines
Then I’d go for:
BR2_PACKAGE_REFPOLICY_ENABLE_EXTRA_AUDIT_LOG
Quoted 8 lines
“Enable extra audit log”
And in the help section I specify all the warnings. Defaulted to n.
This way it’s pretty clear to me that I approach the package for the first time. And most of all it’s what it does as you’ve explained me above.
But then it's not close to the refpolicy implementation and I don't find it particularly clear either. Extra audit could be nice in many ways :)
Let's wait a bit for other to have time to chime in, they might have an interesting take, or suggestions.
Thanks,
Antoine
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
Quoted 14 lines · Antoine Tenart
Quoting Giulio Benetti (2022-01-24 10:20:59)
Quoted 4 lines
Then I’d go for:
BR2_PACKAGE_REFPOLICY_ENABLE_EXTRA_AUDIT_LOGQuoted 8 lines
“Enable extra audit log”
And in the help section I specify all the warnings. Defaulted to n.
This way it’s pretty clear to me that I approach the package for the first time. And most of all it’s what it does as you’ve explained me above.
Quoted 6 lines
But then it's not close to the refpolicy implementation and I don't find it particularly clear either. Extra audit could be nice in many ways :)
Let's wait a bit for other to have time to chime in, they might have an interesting take, or suggestions.
Ok, good idea
Best regards!
Signature · 6 lines
Giulio Benetti Benetti Engineering sas _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot