Skip to contentSkip to conversation

SELinux & ia64

DISCUSSION Prarit Bhargava 2 participants 4 messages Nov 23, 2004 SELinux security module

lore
Share & tools
lore
#0 lore raw

SELinux appears to cause warnings while attempting mounts both at boot-time and run-time:

kernel unaligned access to 0xa0000002003a0056, ip=0xa0000001002076d0 kernel unaligned access to 0xa0000002003a005e, ip=0xa0000001002076d0 kernel unaligned access to 0xa0000002003a0066, ip=0xa0000001002076d0 kernel unaligned access to 0xa0000002003a006e, ip=0xa0000001002076d0

I've tracked this to the usage of le32_to_cpu in

security/selinux/ss/policydb.c

The code in question uses:

    len = le32_to_cpu(buf[0]);

and should be

    len = le32_to_cpu(get_unaligned(&buf[0]));

However, this is probably not a good solution as the get_unaligned macro can be expensive
on platforms other than ia64.

I'm tempted to redefine the le32_to_cpu function for policydb.c for the ia64 platform, but
before I go down that road I was wondering if anyone had hit this issue elsewhere in the kernel?

Prarit.

#1 lore raw
Quoted 11 lines · Prarit Bhargava

I've tracked this to the usage of le32_to_cpu in

security/selinux/ss/policydb.c

The code in question uses:

   len = le32_to_cpu(buf[0]);

and should be

   len = le32_to_cpu(get_unaligned(&buf[0]));

It would probably be better to find out why buf is unaligned, and see if we can make other changes to make it aligned. If we can't, then I recommend a new macro for accessing this element, rather than nest the macros like this. It could look something like:

	len = get_unaligned_le32(buf + 0);

and be implemented perhaps as:

static u32 get_unaligned_le32(u32 *buf)

{
	char *bufc = buf;
	return *bufc | (*(bufc+1) << 8) | (*(bufc+2) << 16) | (*(bufc+3) << 24);
}
Signature · 6 lines
"Next the statesmen will invent cheap lies, putting the blame upon 
the nation that is attacked, and every man will be glad of those
conscience-soothing falsities, and will diligently study them, and refuse
to examine any refutations of them; and thus he will by and by convince 
himself that the war is just, and will thank God for the better sleep 
he enjoys after this process of grotesque self-deception." -- Mark Twain
#2 lore raw

Hi Matthew,

Thanks for the reply. In this instance, buf[0] points to a char* -- it might not be aligned to u16.

Prarit

Quoted 34 lines · Matthew Wilcox
Quoted 4 lines · Prarit Bhargava

I've tracked this to the usage of le32_to_cpu in

security/selinux/ss/policydb.c

Quoted 9 lines

The code in question uses:

  len = le32_to_cpu(buf[0]);

and should be

  len = le32_to_cpu(get_unaligned(&buf[0]));

It would probably be better to find out why buf is unaligned, and see if we can make other changes to make it aligned. If we can't, then I recommend a new macro for accessing this element, rather than nest the macros like this. It could look something like:

	len = get_unaligned_le32(buf + 0);

and be implemented perhaps as:

static u32 get_unaligned_le32(u32 *buf)

{
	char *bufc = buf;
	return *bufc | (*(bufc+1) << 8) | (*(bufc+2) << 16) | (*(bufc+3) << 24);
}
#3 lore raw
In reply to Prarit Bhargava

This is being discussed further on selinux -- sorry for the crosstalk.

P.

Quoted 34 lines · Matthew Wilcox
Quoted 4 lines · Prarit Bhargava

I've tracked this to the usage of le32_to_cpu in

security/selinux/ss/policydb.c

Quoted 9 lines

The code in question uses:

  len = le32_to_cpu(buf[0]);

and should be

  len = le32_to_cpu(get_unaligned(&buf[0]));

It would probably be better to find out why buf is unaligned, and see if we can make other changes to make it aligned. If we can't, then I recommend a new macro for accessing this element, rather than nest the macros like this. It could look something like:

	len = get_unaligned_le32(buf + 0);

and be implemented perhaps as:

static u32 get_unaligned_le32(u32 *buf)

{
	char *bufc = buf;
	return *bufc | (*(bufc+1) << 8) | (*(bufc+2) << 16) | (*(bufc+3) << 24);
}