lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <4AF9E366.50901@gmx.de>
Date:	Tue, 10 Nov 2009 23:04:22 +0100
From:	Helge Deller <deller@....de>
To:	Andrew Morton <akpm@...ux-foundation.org>
CC:	linux-kernel@...r.kernel.org, Anton Blanchard <anton@...ba.org>,
	Paul Mackerras <paulus@...ba.org>
Subject: Re: [PATCH] Implement prctl(PR_GET_ENDIAN) for all architectures

On 11/09/2009 09:46 PM, Andrew Morton wrote:
> On Thu, 22 Oct 2009 21:35:33 +0200
> Helge Deller<deller@....de>  wrote:
>
>> The PR_GET_ENDIAN and PR_SET_ENDIAN prctl() calls have been implemented
>> to allow to switch processes at runtime from big-endian to little-endian
>> mode (and vice versa) on PowerPC processors. Since the other architectures
>> don't support this feature, they currently will just fail and return -EINVAL.
>>
>> This patch adds just minimal overhead and implements the PR_GET_ENDIAN
>> call for all other architectures by returning the native endianess of
>> the architecture. Furthermore, calling prctl(PR_SET_ENDIAN) with the
>> native endianess of the architecture will succeed, while trying to
>> set another (not-supported) endianess, will fail.
>>
>> The patch can be tested with the following program:
>>
>> #include<stdio.h>
>> #include<linux/prctl.h>
>>
>> int main(int argc, char **argv)
>> {
>> 	int endian, ret;
>>
>> 	ret = prctl(PR_GET_ENDIAN,&endian);
>> 	if (ret)
>> 		perror("prctl(PR_GET_ENDIAN) not implemented");
>> 	printf("current process/machine is running in %s endian mode (%d)\n",
>> 		endian == PR_ENDIAN_LITTLE ? "little":"big", endian);
>>
>> 	/* setting native endianess should succeed */
>> 	ret = prctl(PR_SET_ENDIAN, endian);
>> 	printf("prctl(PR_SET_ENDIAN,%d) should succeed: %s\n",
>> 		endian, ret == 0 ? "OK":"FAIL");
>>
>> 	/* setting foreign endianess should fail */
>> 	endian = (endian == PR_ENDIAN_LITTLE) ?
>> 		PR_ENDIAN_BIG : PR_ENDIAN_LITTLE;
>> 	ret = prctl(PR_SET_ENDIAN, endian);
>> 	printf("prctl(PR_SET_ENDIAN,%d) should fail: %s\n",
>> 		endian, ret == 0 ? "OK":"FAIL");
>> }
>>
>
> The changelog forgot to provide any reason for making this change to
> the kernel.

The reason - and the patch - is pretty trivial.
The kernel provides an interface (for all architectures) which is  currently
only useable on one single architecture (ppc).
So, either we could just remove the interface alltogether for all architectures
beside ppc, or implement the functionality for all architectures so that they
return at least some kind of useful values back to userspace.
I hope this qualifies for kernel inclusion?

Helge
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ