SELinux: bigendian problems with filename trans rules
PATCH 1/1 SELinux: bigendian problems with filename trans rules
When writing policy via /sys/fs/selinux/policy I wrote the type and class of filename trans rules in CPU endian instead of little endian. On x86_64 this works just fine, but it means that on big endian arch's like ppc64 and s390 userspace reads the policy and converts it from le32_to_cpu. So the values are all screwed up. Write the values in le format like it should have been to start.
--- security/selinux/ss/policydb.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
security/selinux/ss/policydb.c +4 -4
@@ -3338,10 +3338,10 @@ static int filename_write_helper(void *key, void *data, void *ptr)if (rc)return rc; - buf[0 ] = ft->stype; - buf[1 ] = ft->ttype; - buf[2 ] = ft->tclass; - buf[3 ] = otype->otype; + buf[0 ] =cpu_to_le32 (ft->stype); + buf[1 ] =cpu_to_le32 (ft->ttype); + buf[2 ] =cpu_to_le32 (ft->tclass); + buf[3 ] =cpu_to_le32 (otype->otype); rc =put_entry (buf,sizeof (u32),4 , fp);if (rc)
Signature · 1 line
1.8.5.3
Quoted 22 lines · Eric Paris
When writing policy via
/sys/fs/selinux/policyI wrote the type and class of filename trans rules in CPU endian instead of little endian. Onx86_64this works just fine, but it means that on big endian arch's like ppc64 and s390 userspace reads the policy and converts it fromle32_to_cpu. So the values are all screwed up. Write the values in le format like it should have been to start.Signed-off-by Eric Paris <[email protected]>--- security/selinux/ss/policydb.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)security/selinux/ss/policydb.c +0
-1@@ -3338,10 +3338,10 @@ static int filename_write_helper(void *key, void *data, void *ptr)if (rc)return rc; - buf[0 ] = ft->stype;
security/selinux/ss/policydb.c static int filename_write_helper(void *key, void *data, void *ptr) · line 3347
Quoted 10 lines
security/selinux/ss/policydb.c +4
-3- buf[1 ] = ft->ttype; - buf[2 ] = ft->tclass; - buf[3 ] = otype->otype; + buf[0 ] =cpu_to_le32 (ft->stype); + buf[1 ] =cpu_to_le32 (ft->ttype); + buf[2 ] =cpu_to_le32 (ft->tclass); + buf[3 ] =cpu_to_le32 (otype->otype); rc =put_entry (buf,sizeof (u32),4 , fp);if (rc)
Paul Moore
AppliedQuoted 33 lines · Stephen Smalley
Quoted 32 lines · Eric Paris
When writing policy via
/sys/fs/selinux/policyI wrote the type and class of filename trans rules in CPU endian instead of little endian. Onx86_64this works just fine, but it means that on big endian arch's like ppc64 and s390 userspace reads the policy and converts it fromle32_to_cpu. So the values are all screwed up. Write the values in le format like it should have been to start.Signed-off-by Eric Paris <[email protected]>---
security/selinux/ss/policydb.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)(quoted diff) +0
-0
b/security/selinux/ss/policydb.cindex c0f4988..9c5cdc2 100644security/selinux/ss/policydb.c +4
-4@@ -3338,10 +3338,10 @@ static int filename_write_helper(void *key, void *data, void *ptr)>if (rc)return rc; - buf[0 ] = ft->stype; - buf[1 ] = ft->ttype; - buf[2 ] = ft->tclass; - buf[3 ] = otype->otype; + buf[0 ] =cpu_to_le32 (ft->stype); + buf[1 ] =cpu_to_le32 (ft->ttype); + buf[2 ] =cpu_to_le32 (ft->tclass); + buf[3 ] =cpu_to_le32 (otype->otype);
Quoted 4 lines
security/selinux/ss/policydb.c static int filename_write_helper(void *key, void *data, void *ptr) · line 3347
Quoted 2 lines
security/selinux/ss/policydb.c +0
-0rc =put_entry (buf,sizeof (u32),4 , fp);if (rc)Acked-by Stephen Smalley <[email protected]>
Applied, thanks.
Signature · 2 lines
paul moore security and virtualization @ redhat