Skip to content

Commit e6e8bf4

Browse files
committed
apparmor: fix restricted endian type warnings for dfa unpack
Signed-off-by: John Johansen <john.johansen@canonical.com>
1 parent ca4bd5a commit e6e8bf4

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

security/apparmor/include/match.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,11 +104,11 @@ extern struct aa_dfa *nulldfa;
104104

105105
#define byte_to_byte(X) (X)
106106

107-
#define UNPACK_ARRAY(TABLE, BLOB, LEN, TYPE, NTOHX) \
107+
#define UNPACK_ARRAY(TABLE, BLOB, LEN, TTYPE, BTYPE, NTOHX) \
108108
do { \
109109
typeof(LEN) __i; \
110-
TYPE *__t = (TYPE *) TABLE; \
111-
TYPE *__b = (TYPE *) BLOB; \
110+
TTYPE *__t = (TTYPE *) TABLE; \
111+
BTYPE *__b = (BTYPE *) BLOB; \
112112
for (__i = 0; __i < LEN; __i++) { \
113113
__t[__i] = NTOHX(__b[__i]); \
114114
} \

security/apparmor/match.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -73,11 +73,11 @@ static struct table_header *unpack_table(char *blob, size_t bsize)
7373
/* loaded td_id's start at 1, subtract 1 now to avoid doing
7474
* it every time we use td_id as an index
7575
*/
76-
th.td_id = be16_to_cpu(*(u16 *) (blob)) - 1;
76+
th.td_id = be16_to_cpu(*(__be16 *) (blob)) - 1;
7777
if (th.td_id > YYTD_ID_MAX)
7878
goto out;
79-
th.td_flags = be16_to_cpu(*(u16 *) (blob + 2));
80-
th.td_lolen = be32_to_cpu(*(u32 *) (blob + 8));
79+
th.td_flags = be16_to_cpu(*(__be16 *) (blob + 2));
80+
th.td_lolen = be32_to_cpu(*(__be32 *) (blob + 8));
8181
blob += sizeof(struct table_header);
8282

8383
if (!(th.td_flags == YYTD_DATA16 || th.td_flags == YYTD_DATA32 ||
@@ -95,13 +95,13 @@ static struct table_header *unpack_table(char *blob, size_t bsize)
9595
table->td_lolen = th.td_lolen;
9696
if (th.td_flags == YYTD_DATA8)
9797
UNPACK_ARRAY(table->td_data, blob, th.td_lolen,
98-
u8, byte_to_byte);
98+
u8, u8, byte_to_byte);
9999
else if (th.td_flags == YYTD_DATA16)
100100
UNPACK_ARRAY(table->td_data, blob, th.td_lolen,
101-
u16, be16_to_cpu);
101+
u16, __be16, be16_to_cpu);
102102
else if (th.td_flags == YYTD_DATA32)
103103
UNPACK_ARRAY(table->td_data, blob, th.td_lolen,
104-
u32, be32_to_cpu);
104+
u32, __be32, be32_to_cpu);
105105
else
106106
goto fail;
107107
/* if table was vmalloced make sure the page tables are synced
@@ -249,14 +249,14 @@ struct aa_dfa *aa_dfa_unpack(void *blob, size_t size, int flags)
249249
if (size < sizeof(struct table_set_header))
250250
goto fail;
251251

252-
if (ntohl(*(u32 *) data) != YYTH_MAGIC)
252+
if (ntohl(*(__be32 *) data) != YYTH_MAGIC)
253253
goto fail;
254254

255-
hsize = ntohl(*(u32 *) (data + 4));
255+
hsize = ntohl(*(__be32 *) (data + 4));
256256
if (size < hsize)
257257
goto fail;
258258

259-
dfa->flags = ntohs(*(u16 *) (data + 12));
259+
dfa->flags = ntohs(*(__be16 *) (data + 12));
260260
data += hsize;
261261
size -= hsize;
262262

0 commit comments

Comments
 (0)