PERFORCE change 66108 for review

Andrew Reisse areisse at FreeBSD.org
Tue Nov 30 16:38:31 GMT 2004


http://perforce.freebsd.org/chv.cgi?CH=66108

Change 66108 by areisse at areisse_tislabs on 2004/11/30 16:37:43

	libsepol changes:
	-Freebsd byte order swapping
	-64-bit access vectors

Affected files ...

.. //depot/projects/trustedbsd/sebsd/contrib/sebsd/libsepol/include/sepol/avtab.h#2 edit
.. //depot/projects/trustedbsd/sebsd/contrib/sebsd/libsepol/include/sepol/flask_types.h#2 edit
.. //depot/projects/trustedbsd/sebsd/contrib/sebsd/libsepol/src/avtab.c#2 edit
.. //depot/projects/trustedbsd/sebsd/contrib/sebsd/libsepol/src/private.h#2 edit
.. //depot/projects/trustedbsd/sebsd/contrib/sebsd/libsepol/src/write.c#2 edit

Differences ...

==== //depot/projects/trustedbsd/sebsd/contrib/sebsd/libsepol/include/sepol/avtab.h#2 (text+ko) ====

@@ -26,6 +26,7 @@
 
 #include <sys/types.h>
 #include <stdint.h>
+#include <sepol/flask_types.h>
 
 typedef struct avtab_key {
 	uint32_t source_type;	/* source type */
@@ -44,7 +45,7 @@
 #define AVTAB_TYPE       (AVTAB_TRANSITION | AVTAB_MEMBER | AVTAB_CHANGE)
 #define AVTAB_ENABLED    0x80000000 /* reserved for used in cond_avtab */
 	uint32_t specified;	/* what fields are specified */
-        uint32_t data[3];          /* access vectors or types */
+        access_vector_t data[3];          /* access vectors or types */
 #define avtab_allowed(x) (x)->data[0]
 #define avtab_auditdeny(x) (x)->data[1]
 #define avtab_auditallow(x) (x)->data[2]

==== //depot/projects/trustedbsd/sebsd/contrib/sebsd/libsepol/include/sepol/flask_types.h#2 (text+ko) ====

@@ -34,7 +34,7 @@
  * for permissions are defined in the automatically generated
  * header file av_permissions.h.
  */
-typedef uint32_t access_vector_t;
+typedef uint64_t access_vector_t;
 
 /*
  * Each object class is identified by a fixed-size value.

==== //depot/projects/trustedbsd/sebsd/contrib/sebsd/libsepol/src/avtab.c#2 (text+ko) ====

@@ -362,12 +362,21 @@
 		return -1;
 	}
 	if (avdatum->specified & AVTAB_AV) {
-		if (avdatum->specified & AVTAB_ALLOWED)
-			avtab_allowed(avdatum) = le32_to_cpu(buf[items++]);
-		if (avdatum->specified & AVTAB_AUDITDENY) 
-			avtab_auditdeny(avdatum) = le32_to_cpu(buf[items++]);
-		if (avdatum->specified & AVTAB_AUDITALLOW) 
-			avtab_auditallow(avdatum) = le32_to_cpu(buf[items++]);
+		if (avdatum->specified & AVTAB_ALLOWED) {
+			uint32_t b1 = le32_to_cpu (buf[items++]);
+			uint32_t b2 = le32_to_cpu (buf[items++]);
+			avtab_allowed(avdatum) = (((uint64_t) b1) << 32) | b2;
+		}
+		if (avdatum->specified & AVTAB_AUDITDENY) {
+			uint32_t b1 = le32_to_cpu (buf[items++]);
+			uint32_t b2 = le32_to_cpu (buf[items++]);
+			avtab_auditdeny(avdatum) = (((uint64_t) b1) << 32) | b2;
+		}
+		if (avdatum->specified & AVTAB_AUDITALLOW) {
+			uint32_t b1 = le32_to_cpu (buf[items++]);
+			uint32_t b2 = le32_to_cpu (buf[items++]);
+			avtab_auditallow(avdatum) = (((uint64_t) b1) << 32) | b2;
+		}
 	} else {		
 		if (avdatum->specified & AVTAB_TRANSITION)
 			avtab_transition(avdatum) = le32_to_cpu(buf[items++]);

==== //depot/projects/trustedbsd/sebsd/contrib/sebsd/libsepol/src/private.h#2 (text+ko) ====

@@ -2,20 +2,20 @@
 
 /* Endian conversion for reading and writing binary policies */
 
-#include <byteswap.h>
-#include <endian.h>
+#include <sys/types.h>
+#include <sys/endian.h>
 
-#if __BYTE_ORDER == __LITTLE_ENDIAN
-#define cpu_to_le32(x) (x)
-#define le32_to_cpu(x) (x)
-#define cpu_to_le64(x) (x)
-#define le64_to_cpu(x) (x)
-#else
-#define cpu_to_le32(x) bswap_32(x)
-#define le32_to_cpu(x) bswap_32(x)
-#define cpu_to_le64(x) bswap_64(x)
-#define le64_to_cpu(x) bswap_64(x)
-#endif
+#if BYTE_ORDER == LITTLE_ENDIAN
+#define	cpu_to_le32(x)	((__uint32_t)(x))
+#define	cpu_to_le64(x)	((__uint64_t)(x))
+#define	le32_to_cpu(x)	((__uint32_t)(x))
+#define	le64_to_cpu(x)	((__uint64_t)(x))
+#else /* BYTE_ORDER != LITTLE_ENDIAN */
+#define	cpu_to_le32(x)	bswap32((x))
+#define	cpu_to_le64(x)	bswap64((x))
+#define	le32_to_cpu(x)	bswap32((x))
+#define	le64_to_cpu(x)	bswap64((x))
+#endif /* BYTE_ORDER */
 
 /* Policy compatibility information. */
 struct policydb_compat_info {

==== //depot/projects/trustedbsd/sebsd/contrib/sebsd/libsepol/src/write.c#2 (text+ko) ====

@@ -107,12 +107,18 @@
 		return -1;
 	}
 	if (cur->datum.specified & AVTAB_AV) {
-		if (cur->datum.specified & AVTAB_ALLOWED)
-			buf[items++] = cpu_to_le32(avtab_allowed(&cur->datum));
-		if (cur->datum.specified & AVTAB_AUDITDENY)
-			buf[items++] = cpu_to_le32(avtab_auditdeny(&cur->datum));
-		if (cur->datum.specified & AVTAB_AUDITALLOW)
-			buf[items++] = cpu_to_le32(avtab_auditallow(&cur->datum));
+		if (cur->datum.specified & AVTAB_ALLOWED) {
+			buf[items++] = cpu_to_le32(avtab_allowed(&cur->datum) >> 32);
+			buf[items++] = cpu_to_le32(avtab_allowed(&cur->datum) & 0xffffffff);
+		}
+		if (cur->datum.specified & AVTAB_AUDITDENY) {
+			buf[items++] = cpu_to_le32(avtab_auditdeny(&cur->datum) >> 32);
+			buf[items++] = cpu_to_le32(avtab_auditdeny(&cur->datum) & 0xffffffff);
+		}
+		if (cur->datum.specified & AVTAB_AUDITALLOW) {
+			buf[items++] = cpu_to_le32(avtab_auditallow(&cur->datum) >> 32);
+			buf[items++] = cpu_to_le32(avtab_auditallow(&cur->datum) & 0xffffffff);
+		}
 	} else {
 		if (cur->datum.specified & AVTAB_TRANSITION)
 			buf[items++] = cpu_to_le32(avtab_transition(&cur->datum));
To Unsubscribe: send mail to majordomo at trustedbsd.org
with "unsubscribe trustedbsd-cvs" in the body of the message



More information about the trustedbsd-cvs mailing list