Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 559030
Collapse All | Expand All

(-)a/src/runtime/linux-os.c (-4 / +9 lines)
Lines 64-69 Link Here
64
/* Prototype for personality(2). Done inline here since the header file
64
/* Prototype for personality(2). Done inline here since the header file
65
 * for this isn't available on old versions of glibc. */
65
 * for this isn't available on old versions of glibc. */
66
int personality (unsigned long);
66
int personality (unsigned long);
67
#define ADDR_NO_RANDOMIZE 0x0040000
67
#else
68
#else
68
#include <sys/personality.h>
69
#include <sys/personality.h>
69
#endif
70
#endif
Lines 261-269 os_init(char *argv[], char *envp[]) Link Here
261
        || major_version >= 3)
262
        || major_version >= 3)
262
    {
263
    {
263
        int pers = personality(0xffffffffUL);
264
        int pers = personality(0xffffffffUL);
264
        /* 0x40000 aka. ADDR_NO_RANDOMIZE */
265
        if (!(pers & ADDR_NO_RANDOMIZE)) {
265
        if (!(pers & 0x40000)) {
266
            int retval = personality(pers | ADDR_NO_RANDOMIZE);
266
            int retval = personality(pers | 0x40000);
267
            /* Allegedly some Linux kernels (the reported case was
267
            /* Allegedly some Linux kernels (the reported case was
268
             * "hardened Linux 2.6.7") won't set the new personality,
268
             * "hardened Linux 2.6.7") won't set the new personality,
269
             * but nor will they return -1 for an error. So as a
269
             * but nor will they return -1 for an error. So as a
Lines 298-304 os_init(char *argv[], char *envp[]) Link Here
298
            fprintf(stderr, "WARNING:\
298
            fprintf(stderr, "WARNING:\
299
\nCouldn't re-execute SBCL with proper personality flags (/proc isn't mounted? setuid?)\
299
\nCouldn't re-execute SBCL with proper personality flags (/proc isn't mounted? setuid?)\
300
\nTrying to continue anyway.\n");
300
\nTrying to continue anyway.\n");
301
        } else {
301
        } else if (getenv("SBCL_IS_RESTARTING")) {
302
            /* We restarted due to previously enabled ASLR.  Now,
303
             * reenable it for fork()'ed children. */
304
            int pers = personality(0xffffffffUL);
305
            personality(pers & ~ADDR_NO_RANDOMIZE);
306
302
            unsetenv("SBCL_IS_RESTARTING");
307
            unsetenv("SBCL_IS_RESTARTING");
303
        }
308
        }
304
    }
309
    }

Return to bug 559030