From: Michael Tokarev on

I noticed an.. interesting issue here.

Running a 32bit executable on a 64bit kernel,
and doing


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

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;


++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 :)


To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo(a)
More majordomo info at
Please read the FAQ at