Allow versioning information in ACM XML policy
This patch allows version information to be embedded in the XML representation of the ACM policy. The translation tool has been adapted to parse the version found in the XML representation and put it into the binary policy. Xen has been adapted
to remember the version information and report it when asked for the current
policy.
xen-unstable.hg/tools/security/policies/security_policy.xsd +15 -0
@@ -22,6 +22,8 @@ <xsd:element name="Reference" type="xsd:string" minOccurs="0" maxOccurs="1" /> <xsd:element name="Date" minOccurs="0" maxOccurs="1" type="xsd:string"></xsd:element> <xsd:element name="NameSpaceUrl" minOccurs="0" maxOccurs="1" type="xsd:string"></xsd:element> + <xsd:element name="Version" minOccurs="0" maxOccurs="1" type="VersionFormat"/> + <xsd:element ref="FromPolicy" minOccurs="0" maxOccurs="1"/> </xsd:sequence> </xsd:complexType> </xsd:element>
@@ -116,4 +118,17 @@ <xsd:enumeration value="PrimaryPolicyComponent"></xsd:enumeration> </xsd:restriction> </xsd:simpleType> + <xsd:element name="FromPolicy"> + <xsd:complexType> + <xsd:sequence> + <xsd:element name="PolicyName" minOccurs="1" maxOccurs="1" type="xsd:string"/> + <xsd:element name="Version" minOccurs="1" maxOccurs="1" type="VersionFormat"/> + </xsd:sequence> + </xsd:complexType> + </xsd:element> + <xsd:simpleType name="VersionFormat"> + <xsd:restriction base="xsd:string"> + <xsd:pattern value="[0-9]{1,8}.[0-9]{1,8}"></xsd:pattern> + </xsd:restriction> + </xsd:simpleType> </xsd:schema>
xen-unstable.hg/xen/include/acm/acm_core.h +1 -0
@@ -29,6 +29,7 @@ struct acm_binary_policy {char *policy_reference_name;u16 primary_policy_code;u16 secondary_policy_code; +struct acm_policy_version xml_pol_version; };struct chwall_binary_policy {
xen-unstable.hg/tools/security/secpol_xml2bin.c +53 -24
119 lines not on this page · raw message
xen-unstable.hg/tools/security/secpol_xml2bin.h +37 -27
94 lines not on this page · raw message
xen-unstable.hg/xen/acm/acm_policy.c +9 -1
@@ -116,6 +116,10 @@ do_acm_set_policy(void *buf, u32 buf_siz acm_secondary_ops->set_binary_policy(buf + offset, length)) goto error_lock_free; +memcpy (&acm_bin_pol.xml_pol_version, + &pol->xml_pol_version, +sizeof (acm_bin_pol.xml_pol_version)); +write_unlock (&acm_bin_pol_rwlock);return ACM_OK ;
@@ -132,7 +136,7 @@ acm_get_policy(XEN_GUEST_HANDLE(void) buu8 *policy_buffer;int ret;struct acm_policy_buffer *bin_pol; - +if (buf_size <sizeof (struct acm_policy_buffer ))return -EFAULT ;
@@ -151,6 +155,10 @@ acm_get_policy(XEN_GUEST_HANDLE(void) bu bin_pol->primary_buffer_offset =cpu_to_be32 (be32_to_cpu (bin_pol->len)); bin_pol->secondary_buffer_offset =cpu_to_be32 (be32_to_cpu (bin_pol->len)); +memcpy (&bin_pol->xml_pol_version, + &acm_bin_pol.xml_pol_version, +sizeof (struct acm_policy_version )); + ret =acm_dump_policy_reference (policy_buffer +be32_to_cpu (bin_pol->policy_reference_offset), buf_size -be32_to_cpu (bin_pol->policy_reference_offset));if (ret <0 )
xen-unstable.hg/xen/include/public/acm.h +18 -8
@@ -78,7 +78,7 @@* whenever the interpretation of the related * policy's data structure changes */ -#define ACM_POLICY_VERSION 2 +#define ACM_POLICY_VERSION 3#define ACM_CHWALL_VERSION 1#define ACM_STE_VERSION 1
@@ -119,6 +119,14 @@ typedef uint16_t domaintype_t;/* each offset in bytes from start of the struct they * are part of */ +/* V3 of the policy buffer aded a version structure */ +struct acm_policy_version +{ +uint32_t major; +uint32_t minor; +} __attribute__((packed)); + +/* each buffer consists of all policy information for * the respective policy given in the policy code *
@@ -136,11 +144,13 @@ struct acm_policy_buffer {uint32_t primary_buffer_offset;uint32_t secondary_policy_code;uint32_t secondary_buffer_offset; -}; +struct acm_policy_version xml_pol_version;/* add in V3 */ +} __attribute__((packed)); +struct acm_policy_reference_buffer {uint32_t len; -}; +} __attribute__((packed));struct acm_chwall_policy_buffer {uint32_t policy_version;/* ACM_CHWALL_VERSION */
@@ -152,7 +162,7 @@ struct acm_chwall_policy_buffer {uint32_t chwall_conflict_sets_offset;uint32_t chwall_running_types_offset;uint32_t chwall_conflict_aggregate_offset; -}; +} __attribute__((packed));struct acm_ste_policy_buffer {uint32_t policy_version;/* ACM_STE_VERSION */
@@ -160,7 +170,7 @@ struct acm_ste_policy_buffer {uint32_t ste_max_types;uint32_t ste_max_ssidrefs;uint32_t ste_ssid_offset; -}; +} __attribute__((packed));struct acm_stats_buffer {uint32_t magic;
@@ -169,7 +179,7 @@ struct acm_stats_buffer {uint32_t primary_stats_offset;uint32_t secondary_policy_code;uint32_t secondary_stats_offset; -}; +} __attribute__((packed));struct acm_ste_stats_buffer {uint32_t ec_eval_count;
@@ -178,7 +188,7 @@ struct acm_ste_stats_buffer {uint32_t gt_denied_count;uint32_t ec_cachehit_count;uint32_t gt_cachehit_count; -}; +} __attribute__((packed));struct acm_ssid_buffer {uint32_t len;
@@ -190,7 +200,7 @@ struct acm_ssid_buffer {uint32_t secondary_policy_code;uint32_t secondary_max_types;uint32_t secondary_types_offset; -}; +} __attribute__((packed));#endif
xen-unstable.hg/tools/security/secpol_tool.c +3 -0
@@ -172,6 +172,9 @@ void acm_dump_policy_buffer(void *buf, iprintf ("============\n" );printf ("POLICY REFERENCE = %s.\n" , policy_reference_name);printf ("PolicyVer = %x.\n" ,ntohl (pol->policy_version)); +printf ("XML Vers. = %d.%d\n" , +ntohl (pol->xml_pol_version.major), +ntohl (pol->xml_pol_version.minor));printf ("Magic = %x.\n" ,ntohl (pol->magic));printf ("Len = %x.\n" ,ntohl (pol->len)); printf("Primary = %s (c=%x, off=%x).\n",
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel
Keir Fraser
AppliedQuoted 6 lines · Stefan Berger
This patch allows version information to be embedded in the XML representation of the ACM policy. The
translation tool has been adapted to parse the version found in the XML representation and put it into the binary policy. Xen has been adapted to remember the version information and report it when asked for the current policy.
Applied.
Are the changes to make the structs all packed really required? We usually avoid gcc extensions in public header files (except in some very small number of cases).
-- Keir
[email protected] wrote on 03/28/2007 09:02:47 AM:
Quoted 6 lines · Stefan Berger
Quoted 2 lines
This patch allows version information to be embedded in the XML
representation
Quoted 2 lines
of the ACM policy. The
translation tool has been adapted to parse the version found in the
XML
Quoted 2 lines
Quoted 2 lines
representation and put it into the binary policy. Xen has been adapted to remember the version information and report it when asked for the
current
Quoted 5 lines
Quoted 1 line
policy.
Applied.
Are the changes to make the structs all packed really required? We
usually
Quoted 2 lines
avoid gcc extensions in public header files (except in some very small number of cases).
The structures are all serialized by for example writing them directly into a file. With the 'packed' I want to prevent that on different architectures different binary policies are generated due to architecture-dependent padding inside the structures. With the way the structures are at the moment, there would not be any padding between the uint32_t from what I can tell after a test on x86 and powerpc, though maybe in the future. So the packed is there, but does not affect the padding at the moment.
Stefan
Quoted 8 lines
-- Keir
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel