Go to:
Gentoo Home
Documentation
Forums
Lists
Bugs
Planet
Store
Wiki
Get Gentoo!
Gentoo's Bugzilla – Attachment 161391 Details for
Bug 222343
configure for dev-lisp/gcl-2.6.7-r3 failes
Home
|
New
–
[Ex]
|
Browse
|
Search
|
Privacy Policy
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
gcl-sbrk.patch
gcl-sbrk.patch (text/plain), 7.13 KB, created by
Ingo Bormuth
on 2008-07-26 07:37:43 UTC
(
hide
)
Description:
gcl-sbrk.patch
Filename:
MIME Type:
Creator:
Ingo Bormuth
Created:
2008-07-26 07:37:43 UTC
Size:
7.13 KB
patch
obsolete
>--- a/configure.in >+++ b/configure.in >@@ -1000,78 +1000,51 @@ > AC_MSG_RESULT([no: WARNING you must be able to emulate sbrk: as on mingw or macosx])) > > if test "$HAVE_SBRK" = "1" ; then >- AC_MSG_CHECKING([for randomized sbrk]) >- AC_TRY_RUN([#include <unistd.h> >- #include <stdio.h> >- int main() { >+ AC_CHECK_HEADER(sys/personality.h, true, >+ AC_MSG_ERROR(sys/personality.h not found)) >+ >+ AC_MSG_CHECKING([for ADDR_NO_RANDOMIZE constant]) >+ AC_TRY_RUN([#include <sys/personality.h> >+ #include <stdio.h> >+ int main(int argc,char *argv[],char *envp[]) { > FILE *f; > if (!(f=fopen("conftest1","w"))) > return -1; >- fprintf(f,"%u",sbrk(0)); >+ fprintf(f,"%x",ADDR_NO_RANDOMIZE); > return 0; > }], >- SBRK=`cat conftest1`,SBRK=0,SBRK=0) >- if test "$SBRK" = "0" ; then >- AC_MSG_RESULT(cannot trap sbrk) >- exit 1 >+ ADDR_NO_RANDOMIZE=`cat conftest1`,ADDR_NO_RANDOMIZE=0,ADDR_NO_RANDOMIZE=0) >+ if test "$ADDR_NO_RANDOMIZE" = "0" ; then >+ AC_MSG_RESULT([no, assuming 0x40000]) >+ AC_DEFINE_UNQUOTED(ADDR_NO_RANDOMIZE,0x40000) >+ else >+ AC_MSG_RESULT([yes]) > fi >- AC_TRY_RUN([#include <unistd.h> >+ >+ AC_MSG_CHECKING([for personality(ADDR_NO_RANDOMIZE) support]) >+ AC_TRY_RUN([#include <sys/personality.h> > #include <stdio.h> >- int main() { >+ int main(int argc,char *argv[]) { > FILE *f; > if (!(f=fopen("conftest1","w"))) > return -1; >- fprintf(f,"%u",sbrk(0)); >+ long retval = personality(ADDR_NO_RANDOMIZE); >+ long newpers = personality(0xffffffffUL); >+ fprintf(f,"%d",retval != -1 && newpers & ADDR_NO_RANDOMIZE); > return 0; > }], >- SBRK1=`cat conftest1`,SBRK1=0,SBRK1=0) >- if test "$SBRK1" = "0" ; then >- AC_MSG_RESULT(cannot trap sbrk) >- exit 1 >- fi >- >- if test "$SBRK" != "$SBRK1" ; then >+ NEED_NONRANDOM_SBRK=`cat conftest1`,NEED_NONRANDOM_SBRK=0,NEED_NONRANDOM_SBRK=0) >+ >+ if test "$NEED_NONRANDOM_SBRK" = 1 ; then > AC_MSG_RESULT(yes) >-# AC_CHECK_HEADER(linux/personality.h, true, >-# AC_MSG_ERROR(linux/personality.h not found)) >-# AC_TRY_RUN([#include <syscall.h> >-# #include <linux/personality.h> >-# #include <stdio.h> >-# #include <unistd.h> >-# int main(int argc,char *argv[],char *envp[]) { >-# FILE *f; >-# if (!(f=fopen("conftest1","w"))) >-# return -1; >-# fprintf(f,"%x",ADDR_NO_RANDOMIZE); >-# return 0; >-# }], >-# ADDR_NO_RANDOMIZE=`cat conftest1`,ADDR_NO_RANDOMIZE=0,ADDR_NO_RANDOMIZE=0) >-# if test "$ADDR_NO_RANDOMIZE" = "0" ; then >-# AC_MSG_RESULT(cannot get ADDR_NO_RANDOMIZE constant) >-# exit 1 >-# fi >-# AC_DEFINE_UNQUOTED(ADDR_NO_RANDOMIZE,$ADDR_NO_RANGOMIZE) >-# >-# Many boxes do not have the definition yet >-# >- ADDR_NO_RANDOMIZE=0x40000 >- AC_DEFINE_UNQUOTED(ADDR_NO_RANDOMIZE,$ADDR_NO_RANDOMIZE) >- AC_MSG_CHECKING([for ADDR_NO_RANOMIZE constant]) >- AC_MSG_RESULT($ADDR_NO_RANDOMIZE) >- AC_CHECK_HEADER(sys/personality.h, true, >- AC_MSG_ERROR(sys/personality.h not found)) >- AC_TRY_RUN([#include <syscall.h> >- #include <sys/personality.h> >- #include <stdio.h> >- #include <unistd.h> >- int main(int argc,char *argv[],char *envp[]) { >+ AC_DEFINE(NEED_NONRANDOM_SBRK) >+ else >+ AC_MSG_RESULT(no) >+ AC_MSG_CHECKING([for randomized sbrk]) >+ AC_TRY_RUN([#include <unistd.h> >+ #include <stdio.h> >+ int main() { > FILE *f; >- long pers; >- pers=personality(-1); >- if (!(pers & ADDR_NO_RANDOMIZE)) { >- personality(pers | ADDR_NO_RANDOMIZE); >- execve(*argv,argv,envp); >- } > if (!(f=fopen("conftest1","w"))) > return -1; > fprintf(f,"%u",sbrk(0)); >@@ -1082,18 +1055,10 @@ > AC_MSG_RESULT(cannot trap sbrk) > exit 1 > fi >- AC_TRY_RUN([#include <syscall.h> >- #include <sys/personality.h> >+ AC_TRY_RUN([#include <unistd.h> > #include <stdio.h> >- #include <unistd.h> >- int main(int argc,char * argv[],char *envp[]) { >+ int main() { > FILE *f; >- long pers; >- pers=personality(-1); >- if (!(pers & ADDR_NO_RANDOMIZE)) { >- personality(pers | ADDR_NO_RANDOMIZE); >- execve(*argv,argv,envp); >- } > if (!(f=fopen("conftest1","w"))) > return -1; > fprintf(f,"%u",sbrk(0)); >@@ -1104,17 +1069,16 @@ > AC_MSG_RESULT(cannot trap sbrk) > exit 1 > fi >- AC_MSG_CHECKING([for randomized brk remedy]) > if test "$SBRK" = "$SBRK1" ; then >- AC_MSG_RESULT(yes) >- AC_DEFINE(NEED_NONRANDOM_SBRK) >- else > AC_MSG_RESULT(no) >- echo "Cannot build with randomized sbrk" >+ else >+ AC_MSG_RESULT(yes) >+ echo "Cannot build with randomized sbrk. Your options:" >+ echo " - upgrade to a kernel/libc that knows about personality(ADDR_NO_RANDOMIZE)" >+ echo " - recompile your kernel with CONFIG_COMPAT_BRK (if it has that option)" >+ echo " - run sysctl kernel.randomize_va_space=0 before using gcl" > exit 1 >- fi >- else >- AC_MSG_RESULT(no) >+ fi > fi > fi > >@@ -1150,7 +1114,7 @@ > FILE *fp; > > #ifdef NEED_NONRANDOM_SBRK >- pers=personality(-1); >+ pers=personality(0xffffffffUL); > if (!(pers & ADDR_NO_RANDOMIZE)) { > personality(pers | ADDR_NO_RANDOMIZE); > execve(*argv,argv,envp); >--- a/o/main.c >+++ b/o/main.c >@@ -133,12 +133,43 @@ > > #ifdef NEED_NONRANDOM_SBRK > { >- long pers; >- pers=personality(-1); >- if (!(pers & ADDR_NO_RANDOMIZE)) { >- personality(pers | ADDR_NO_RANDOMIZE); >- execve(*argv,argv,envp); >- } >+ /* adapted from SBCL */ >+ int pers = personality(0xffffffffUL); >+ /* 0x40000 aka. ADDR_NO_RANDOMIZE */ >+ if (!(pers & 0x40000)) { >+ int retval = personality(pers | 0x40000); >+ /* Allegedly some Linux kernels (the reported case was >+ * "hardened Linux 2.6.7") won't set the new personality, >+ * but nor will they return -1 for an error. So as a >+ * workaround query the new personality... >+ */ >+ int newpers = personality(0xffffffffUL); >+ /* ... and don't re-execute if either the setting resulted >+ * in an error or if the value didn't change. Otherwise >+ * this might result in an infinite loop. >+ */ >+ if (retval != -1 && newpers != pers) { >+ /* Use /proc/self/exe instead of trying to figure out >+ * the executable path from PATH and argv[0], since >+ * that's unreliable. We follow the symlink instead of >+ * executing the file directly in order to prevent top >+ * from displaying the name of the process as "exe". */ >+ char runtime[PATH_MAX+1]; >+ int i = readlink("/proc/self/exe", runtime, PATH_MAX); >+ if (i != -1) { >+ runtime[i] = '\0'; >+#ifdef GCL_GPROF >+ gprof_cleanup(); >+#endif >+ execve(runtime, argv, envp); >+ } >+ } >+ /* Either changing the personality or execve() failed. Either >+ * way we might as well continue, and hope that the random >+ * memory maps are ok this time around. >+ */ >+ fprintf(stderr, "WARNING: Couldn't re-execute with the proper personality flags (maybe /proc isn't mounted?). Trying to continue anyway.\n"); >+ } > } > #endif >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 222343
:
153285
| 161391 |
161393
|
161394
|
182398