* personality(ADDR_LIMIT_3GB) results in EFAULT
@ 2010-05-27 17:17 Michael Tokarev
2010-05-27 18:38 ` Andi Kleen
0 siblings, 1 reply; 3+ messages in thread
From: Michael Tokarev @ 2010-05-27 17:17 UTC (permalink / raw)
To: Kernel Mailing List
Hello.
I noticed an.. interesting issue here.
Running a 32bit executable on a 64bit kernel,
and doing
personality(ADDR_LIMIT_3GB);
That call succedes, but any further execve()
and friends results in EFAULT, unless whole
argv[] and envp[] are copied to a malloc'ed
space. alloca sometimes helps and sometimes
not.
This simple program demonstrates the issue:
===== cut =====
#include <sys/types.h>
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
int main(int ac, char **av, char **ev) {
int i;
personality(ADDR_LIMIT_3GB);
++av; --ac;
for (i = 0; i < ac; ++i)
av[i] = strdup(av[i]);
for(i = 0; ev[i]; ++i)
ev[i] = strdup(ev[i]);
execve(av[0], av, ev);
printf("unable to execute %s: %m\n", av[0]);
return 1;
}
===== cut =====
Run as ./a.out /bin/echo
(or any other 32bit program).
Without the two for() loops it fails with EFAULT
error. Changing strdup into strdupa results in
it working in the above simplest case, but
failing in more complex situation as a part of
larger program.
For now, in order to set this personality, I use
a 64bit helper program that executes the 32bit
binary (for which that personality is important).
Which look a bit ugly, esp. since it is in a chain
of other, all 32bit, programs.
Is it easy enough to fix? :)
The issue here, original issue, is a need to run
some legacy application (oracle database v.8 in
in this particular example), so it's not very
interesting to fix. But doing ugly workarounds
aren't good either :)
Thanks!
/mjt
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: personality(ADDR_LIMIT_3GB) results in EFAULT
2010-05-27 17:17 personality(ADDR_LIMIT_3GB) results in EFAULT Michael Tokarev
@ 2010-05-27 18:38 ` Andi Kleen
2010-06-13 18:20 ` Michael Tokarev
0 siblings, 1 reply; 3+ messages in thread
From: Andi Kleen @ 2010-05-27 18:38 UTC (permalink / raw)
To: Michael Tokarev; +Cc: Kernel Mailing List
Michael Tokarev <mjt@tls.msk.ru> writes:
> I noticed an.. interesting issue here.
>
> Running a 32bit executable on a 64bit kernel,
> and doing
>
> personality(ADDR_LIMIT_3GB);
>
> That call succedes, but any further execve()
> and friends results in EFAULT, unless whole
> argv[] and envp[] are copied to a malloc'ed
> space. alloca sometimes helps and sometimes
> not.
It worked when I wrote it originally.
Sounds like a regression, perhaps related to
b6a2fea39318e43fee84fa7b0b90d68bed92d2ba
-Andi
--
ak@linux.intel.com -- Speaking for myself only.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: personality(ADDR_LIMIT_3GB) results in EFAULT
2010-05-27 18:38 ` Andi Kleen
@ 2010-06-13 18:20 ` Michael Tokarev
0 siblings, 0 replies; 3+ messages in thread
From: Michael Tokarev @ 2010-06-13 18:20 UTC (permalink / raw)
To: Andi Kleen; +Cc: Kernel Mailing List, Ollie Wild
[replying to somewhat old email...]
27.05.2010 22:38, Andi Kleen wrote:
> Michael Tokarev<mjt@tls.msk.ru> writes:
>
>> I noticed an.. interesting issue here.
>>
>> Running a 32bit executable on a 64bit kernel,
>> and doing
>>
>> personality(ADDR_LIMIT_3GB);
>>
>> That call succedes, but any further execve()
>> and friends results in EFAULT, unless whole
>> argv[] and envp[] are copied to a malloc'ed
>> space. alloca sometimes helps and sometimes
>> not.
>
> It worked when I wrote it originally.
>
> Sounds like a regression, perhaps related to
> b6a2fea39318e43fee84fa7b0b90d68bed92d2ba
This is this commit:
commit b6a2fea39318e43fee84fa7b0b90d68bed92d2ba
Author: Ollie Wild <aaw@google.com>
Date: Thu Jul 19 01:48:16 2007 -0700
mm: variable length argument support
Remove the arg+env limit of MAX_ARG_PAGES by copying the strings directly from
the old mm into the new mm.
We create the new mm before the binfmt code runs, and place the new stack at
the very top of the address space. Once the binfmt code runs and figures out
where the stack should be, we move it downwards.
It is a bit peculiar in that we have one task with two mm's, one of which is
inactive.
[a.p.zijlstra@chello.nl: limit stack size]
Signed-off-by: Ollie Wild <aaw@google.com>
Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: <linux-arch@vger.kernel.org>
Cc: Hugh Dickins <hugh@veritas.com>
[bunk@stusta.de: unexport bprm_mm_init]
Signed-off-by: Adrian Bunk <bunk@stusta.de>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
(Author of this commit CC'ed).
Folks, I really need some advise here.
Right now I've a 64 wrapper executable to run the legacy
database (which we didn't finish migrating from yet, it's
always long process). It sets the necessary personality
and executes the real binary. But the problem is that after
a recompile (I added something else to it), the whole thing
stopped working on a machine with 4Gb memory: the execve()
call, now when made from 64bit binary, immediately fails
with EFAULT. Before, this were happening only when the
wrapper is 32bit code (try `setarch i686 -3 any_32bit_exe' --
it will fail if setarch itself is 32bit executable). Now
it fails from 64bits too, even just recompiling the old
.c code (with single personality() call in it) now results
in non-working thing - apparently due to some gcc diff.
Can we restore this personality thing, please?.. :)
I'm not good at all this code, so I need someone who is
able to understand what's going on.... ;)
Thanks!
/mjt
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2010-06-13 18:20 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-05-27 17:17 personality(ADDR_LIMIT_3GB) results in EFAULT Michael Tokarev
2010-05-27 18:38 ` Andi Kleen
2010-06-13 18:20 ` Michael Tokarev
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox