public inbox for linux-ia64@vger.kernel.org
 help / color / mirror / Atom feed
* SELinux & ia64
@ 2004-11-23 15:13 Prarit Bhargava
  2004-11-23 16:13 ` Matthew Wilcox
  2004-11-23 18:23 ` Prarit Bhargava
  0 siblings, 2 replies; 4+ messages in thread
From: Prarit Bhargava @ 2004-11-23 15:13 UTC (permalink / raw)
  To: linux-ia64, selinux

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.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: SELinux & ia64
  2004-11-23 15:13 SELinux & ia64 Prarit Bhargava
@ 2004-11-23 16:13 ` Matthew Wilcox
  2004-11-23 17:16   ` Prarit Bhargava
  2004-11-23 18:23 ` Prarit Bhargava
  1 sibling, 1 reply; 4+ messages in thread
From: Matthew Wilcox @ 2004-11-23 16:13 UTC (permalink / raw)
  To: linux-ia64

On Tue, Nov 23, 2004 at 10:13:27AM -0500, Prarit Bhargava wrote:
> 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);
}

-- 
"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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: SELinux & ia64
  2004-11-23 16:13 ` Matthew Wilcox
@ 2004-11-23 17:16   ` Prarit Bhargava
  0 siblings, 0 replies; 4+ messages in thread
From: Prarit Bhargava @ 2004-11-23 17:16 UTC (permalink / raw)
  To: Matthew Wilcox; +Cc: linux-ia64, selinux

Hi Matthew,

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

Prarit

Matthew Wilcox wrote:

>On Tue, Nov 23, 2004 at 10:13:27AM -0500, Prarit Bhargava wrote:
>  
>
>>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);
>}
>
>  
>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: SELinux & ia64
  2004-11-23 15:13 SELinux & ia64 Prarit Bhargava
  2004-11-23 16:13 ` Matthew Wilcox
@ 2004-11-23 18:23 ` Prarit Bhargava
  1 sibling, 0 replies; 4+ messages in thread
From: Prarit Bhargava @ 2004-11-23 18:23 UTC (permalink / raw)
  To: linux-ia64

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

P.

Matthew Wilcox wrote:

>On Tue, Nov 23, 2004 at 10:13:27AM -0500, Prarit Bhargava wrote:
>  
>
>>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);
>}
>
>  
>

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2004-11-23 18:23 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-11-23 15:13 SELinux & ia64 Prarit Bhargava
2004-11-23 16:13 ` Matthew Wilcox
2004-11-23 17:16   ` Prarit Bhargava
2004-11-23 18:23 ` Prarit Bhargava

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox