* Re: Bug#380531: linux-2.6: mips and mipsel personality(2) support is broken [not found] <20060730183939.7119.48747.reportbug@hardknott.home.whinlatter.ukfsn.org> @ 2006-07-30 22:41 ` Martin Michlmayr 2006-07-30 23:19 ` Thiemo Seufer 2006-07-30 23:20 ` Roger Leigh 0 siblings, 2 replies; 3+ messages in thread From: Martin Michlmayr @ 2006-07-30 22:41 UTC (permalink / raw) To: linux-mips; +Cc: Roger Leigh, 380531-silent [-- Attachment #1: Type: text/plain, Size: 1247 bytes --] FYI, but report tht "mips and mipsel personality(2) support is broken" * Roger Leigh <rleigh@debian.org> [2006-07-30 19:39]: > personality(2) only works the first time it is called [in the lifetime > of a process/program]. All subsequent calls return EPERM, which is > not a documented return value; I can see no mention of it in > kernel/execdomain.c. None of the other architectures I have tested > (amd64, arm, i386, ia64, powerpc) behave this way: personality(2) is > not a privileged call. > > This happens no matter what the value of persona is, even if it is > just 0xffffffff to query the current personality. > > The attached testcase demonstrates the breakage. On a working > platform (powerpc), the output is like this: > > ------------------------ > $ ./testpersona > Getting personality > Get returned '0' > Setting personality '8' > Set OK > Getting personality > Get returned '8' > Setting personality '0' > Set OK > Getting personality > Get returned '0' > ------------------------ > > 0 == PER_LINUX > 8 == PER_LINUX32 > > It successfully switched from PER_LINUX to PER_LINUX32 and back again, > checking the personality before and after each change. > > > Regards, > Roger -- Martin Michlmayr http://www.cyrius.com/ [-- Attachment #2: testpersona.c --] [-- Type: text/x-csrc, Size: 739 bytes --] #include <stdio.h> #include <string.h> #include <errno.h> #include <sys/personality.h> int set_persona (unsigned long p) { fprintf (stderr, "Setting personality '%lu'\n", p); int status = personality(p); if (status == -1) fprintf(stderr, "Set failed: %s\n", strerror(errno)); fprintf(stderr, "Set OK\n"); return status; } int get_persona (void) { fprintf (stderr, "Getting personality\n"); int status = personality(0xffffffff); if (status == -1) fprintf(stderr, "Get failed: %s\n", strerror(errno)); fprintf(stderr, "Get returned '%d'\n", status); return status; } int main (void) { get_persona(); set_persona(PER_LINUX32); get_persona(); set_persona(PER_LINUX); get_persona(); return 0; } ^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Bug#380531: linux-2.6: mips and mipsel personality(2) support is broken 2006-07-30 22:41 ` Bug#380531: linux-2.6: mips and mipsel personality(2) support is broken Martin Michlmayr @ 2006-07-30 23:19 ` Thiemo Seufer 2006-07-30 23:20 ` Roger Leigh 1 sibling, 0 replies; 3+ messages in thread From: Thiemo Seufer @ 2006-07-30 23:19 UTC (permalink / raw) To: Martin Michlmayr; +Cc: linux-mips, Roger Leigh, 380531-silent Martin Michlmayr wrote: > FYI, but report tht "mips and mipsel personality(2) support is broken" This patch fixes sys_personality for the o32 emulation by a) killing the sign extension bits b) tighten the bitmask match for current->personality (like it is done for x86_64) Thiemo Signed-off-by: Thiemo Seufer <ths@networkno.de> --- a/arch/mips/kernel/linux32.c +++ b/arch/mips/kernel/linux32.c @@ -1053,7 +1053,9 @@ asmlinkage long sys32_newuname(struct ne asmlinkage int sys32_personality(unsigned long personality) { int ret; - if (current->personality == PER_LINUX32 && personality == PER_LINUX) + personality &= 0xffffffff; + if (personality(current->personality) == PER_LINUX32 && + personality == PER_LINUX) personality = PER_LINUX32; ret = sys_personality(personality); if (ret == PER_LINUX32) ^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Bug#380531: linux-2.6: mips and mipsel personality(2) support is broken 2006-07-30 22:41 ` Bug#380531: linux-2.6: mips and mipsel personality(2) support is broken Martin Michlmayr 2006-07-30 23:19 ` Thiemo Seufer @ 2006-07-30 23:20 ` Roger Leigh 1 sibling, 0 replies; 3+ messages in thread From: Roger Leigh @ 2006-07-30 23:20 UTC (permalink / raw) To: Martin Michlmayr; +Cc: linux-mips, 380531-silent [-- Attachment #1: Type: text/plain, Size: 1746 bytes --] Martin Michlmayr <tbm@cyrius.com> writes: > FYI, but report tht "mips and mipsel personality(2) support is broken" > > * Roger Leigh <rleigh@debian.org> [2006-07-30 19:39]: >> personality(2) only works the first time it is called [in the lifetime >> of a process/program]. All subsequent calls return EPERM, which is >> not a documented return value; I can see no mention of it in >> kernel/execdomain.c. None of the other architectures I have tested >> (amd64, arm, i386, ia64, powerpc) behave this way: personality(2) is >> not a privileged call. >> >> This happens no matter what the value of persona is, even if it is >> just 0xffffffff to query the current personality. Just a follow up: There is a twist to the behaviour: If personality(2) is called with a personality other than 0xffffffff (query), and it fails, a subsequent call (any persona value) will succeed. I can't see any reason for the behaviour looking at the kernel/execdomain.c or arch/mips/kernel/linux32.c. ths believes it's due to a bug in the syscall interface: <ths> I believe it is related to sign extension. <ths> o32 queries with 0xffffffff, which is really 0xffffffffffffffff, then the kernel compares against 0xffffffff. <rleigh> I haven't heard of that. Is it MIPS-specific, or a 64-bit-specific thing? <ths> mips uses sign-extended registers for 32bit values. <ths> There's no 64bit mode switch. <ths> (The argument for the sys32_personality should be int, not long.) -- .''`. Roger Leigh : :' : Debian GNU/Linux http://people.debian.org/~rleigh/ `. `' Printing on GNU/Linux? http://gutenprint.sourceforge.net/ `- GPG Public Key: 0x25BFB848 Please sign and encrypt your mail. [-- Attachment #2: Type: application/pgp-signature, Size: 188 bytes --] ^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2006-07-30 23:21 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <20060730183939.7119.48747.reportbug@hardknott.home.whinlatter.ukfsn.org>
2006-07-30 22:41 ` Bug#380531: linux-2.6: mips and mipsel personality(2) support is broken Martin Michlmayr
2006-07-30 23:19 ` Thiemo Seufer
2006-07-30 23:20 ` Roger Leigh
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox