mirror of
https://gitlab.com/apparmor/apparmor
synced 2025-08-31 06:16:03 +00:00
Add the ability to separate policy_version from kernel and parser abi
This will allow for the parser to invalidate its caches separate of whether the kernel policy version has changed. This can be desirable if a parser bug is discovered, a new version the parser is shipped and we need to force cache files to be regenerated. Policy current stores a 32 bit version number in the header binary policy. For newer policy (> v5 kernel abi) split this number into 3 separate fields policy_version, parser_abi, kernel_abi. If binary policy with a split version number is loaded to an older kernel it will be correctly rejected as unsupported as those kernels will see it as a none v5 version. For kernels that only support v5 policy on the kernel abi version is written. The rules for policy versioning should be policy_version: Set by text policy language version. Parsers that don't understand a specified version may fail, or drop rules they are unaware of. parser_abi_version: gets bumped when a userspace bug is discovered that requires policy be recompiled. The policy version could be reset for each new kernel version but since the parser needs to support multiple kernel versions tracking this is extra work and should be avoided. kernel_abi_version: gets bumped when semantic changes need to be applied. Eg unix domain sockets being mediated at connect. the kernel abi version does not encapsulate all supported features. As kernels could have different sets of patches supplied. Basic feature support is determined by the policy_mediates() encoding in the policydb. As such comparing cache features to kernel features is still needed to determine if cached policy is best matched to the kernel. Signed-off-by: John Johansen <john.johansen@canonical.com> Acked-by: Seth Arnold <seth.arnold@canonical.com>
This commit is contained in:
@@ -22,10 +22,50 @@
|
||||
#define _(s) gettext(s)
|
||||
#include "parser.h"
|
||||
|
||||
/* Policy versioning is determined by a combination of 3 values:
|
||||
* policy_version: version of txt policy
|
||||
* parser_abi_version: version of abi revision of policy generated by parser
|
||||
* kernel_abi_version: version of abi revision for the kernel
|
||||
*
|
||||
* The version info is stored in a single 32 bit version field in the
|
||||
* header portion of each binary policy file.
|
||||
*
|
||||
* policy_version:
|
||||
* a gross revision number indicating what features and semantics are
|
||||
* expected by the text policy. This does not necessarily map directly
|
||||
* to a feature set as a kernel may not have all the supported features
|
||||
* patched/builtin.
|
||||
*
|
||||
* policy_version is not supported by kernels that only support v5
|
||||
* kernel abi, so it will not be written when creating policy for
|
||||
* those kernels.
|
||||
*
|
||||
* kernel_abi_version:
|
||||
* should be set to the highest version supported by both the parser and
|
||||
* the kernel.
|
||||
* This allows new kernels to detect old userspaces, and new parsers
|
||||
* to support old kernels and policies semantics.
|
||||
*
|
||||
* parser_abi_version:
|
||||
* should be bumped when a compiler error or some other event happens
|
||||
* and policy cache needs to be forced to be recomputed, when the
|
||||
* policy_version or kernel version has not changed.
|
||||
*
|
||||
* parser_abi_version is not supported by kernels that only support
|
||||
* v5 kernel abi so it will not be written when creating policy for those
|
||||
* kernels.
|
||||
*
|
||||
* Default values set to v5 kernel abi before the different versioning
|
||||
* numbers where supported.
|
||||
*/
|
||||
uint32_t policy_version = 2;
|
||||
uint32_t parser_abi_version = 0;
|
||||
uint32_t kernel_abi_version = 5;
|
||||
|
||||
int force_complain = 0;
|
||||
int perms_create = 0; /* perms contain create flag */
|
||||
int net_af_max_override = -1; /* use kernel to determine af_max */
|
||||
int kernel_load = 1;
|
||||
int kernel_policy_version = 5; /* default to base version */
|
||||
int kernel_supports_network = 0; /* kernel supports network rules */
|
||||
int kernel_supports_policydb = 0; /* kernel supports new policydb */
|
||||
int kernel_supports_mount = 0; /* kernel supports mount rules */
|
||||
|
Reference in New Issue
Block a user