Re: Stop mesa W^X violations
Mark Kettenis writes: >> From: j...@wxcvbn.org (Jeremie Courreges-Anglas) >> Date: Mon, 27 Jun 2016 23:40:35 +0200 >> >> Mark Kettenis writes: >> >> > As reported by several people, mesa contains code that violates W^X. >> > As a result glxgears aborts when using the swrast driver. The diff >> > below disables the offending code. The code seems to deal the absence >> > of W|X memory just fine. There is a fallback path that is also used >> > on SELinux systems. >> > >> > Note that the existing code would have worked just fine if mmap >> > returned MAP_FAILED for W^X violations instead of terminating the >> > program. Not entirely sure what the long-term plans are. >> >> [...] >> >> >> The #ifdef excludes the definition of _mesa_exec_malloc and >> _mesa_exec_free. >> >> xlock:/usr/X11R6/lib/modules/dri/i915_dri.so: undefined symbol >> '_mesa_exec_malloc' >> xlock:/usr/X11R6/lib/modules/dri/i915_dri.so: undefined symbol >> '_mesa_exec_free' >> libGL error: unable to load driver: i915_dri.so >> libGL error: driver pointer missing >> libGL error: failed to load driver: i915 > > New diff that should fix this. ok jca@ -- jca | PGP: 0x1524E7EE / 5135 92C1 AD36 5293 2BDF DDCC 0DFA 74AE 1524 E7EE
Re: Stop mesa W^X violations
> From: j...@wxcvbn.org (Jeremie Courreges-Anglas) > Date: Mon, 27 Jun 2016 23:40:35 +0200 > > Mark Kettenis writes: > > > As reported by several people, mesa contains code that violates W^X. > > As a result glxgears aborts when using the swrast driver. The diff > > below disables the offending code. The code seems to deal the absence > > of W|X memory just fine. There is a fallback path that is also used > > on SELinux systems. > > > > Note that the existing code would have worked just fine if mmap > > returned MAP_FAILED for W^X violations instead of terminating the > > program. Not entirely sure what the long-term plans are. > > [...] > > > The #ifdef excludes the definition of _mesa_exec_malloc and > _mesa_exec_free. > > xlock:/usr/X11R6/lib/modules/dri/i915_dri.so: undefined symbol > '_mesa_exec_malloc' > xlock:/usr/X11R6/lib/modules/dri/i915_dri.so: undefined symbol > '_mesa_exec_free' > libGL error: unable to load driver: i915_dri.so > libGL error: driver pointer missing > libGL error: failed to load driver: i915 New diff that should fix this. Index: src/gallium/auxiliary/rtasm/rtasm_execmem.c === RCS file: /cvs/xenocara/lib/mesa/src/gallium/auxiliary/rtasm/rtasm_execmem.c,v retrieving revision 1.1.1.1 diff -u -p -r1.1.1.1 rtasm_execmem.c --- src/gallium/auxiliary/rtasm/rtasm_execmem.c 22 Nov 2015 02:43:24 - 1.1.1.1 +++ src/gallium/auxiliary/rtasm/rtasm_execmem.c 4 Jul 2016 21:38:46 - @@ -69,6 +69,16 @@ static struct mem_block *exec_heap = NUL static unsigned char *exec_mem = NULL; +#ifdef __OpenBSD__ + +static int +init_heap(void) +{ + return 0; +} + +#else + static int init_heap(void) { @@ -82,6 +92,8 @@ init_heap(void) return (exec_mem != MAP_FAILED); } + +#endif void * Index: src/mapi/u_execmem.c === RCS file: /cvs/xenocara/lib/mesa/src/mapi/u_execmem.c,v retrieving revision 1.1.1.1 diff -u -p -r1.1.1.1 u_execmem.c --- src/mapi/u_execmem.c22 Nov 2015 02:45:44 - 1.1.1.1 +++ src/mapi/u_execmem.c4 Jul 2016 21:38:48 - @@ -45,8 +45,15 @@ static unsigned int head = 0; static unsigned char *exec_mem = (unsigned char *)0; +#if defined(__OpenBSD__) -#if defined(__linux__) || defined(__OpenBSD__) || defined(_NetBSD__) || defined(__sun) || defined(__HAIKU__) +static int +init_map(void) +{ + return 0; +} + +#elif defined(__linux__) || defined(_NetBSD__) || defined(__sun) || defined(__HAIKU__) #include #include Index: src/mesa/main/execmem.c === RCS file: /cvs/xenocara/lib/mesa/src/mesa/main/execmem.c,v retrieving revision 1.1.1.1 diff -u -p -r1.1.1.1 execmem.c --- src/mesa/main/execmem.c 22 Nov 2015 02:39:37 - 1.1.1.1 +++ src/mesa/main/execmem.c 4 Jul 2016 21:38:48 - @@ -36,7 +36,20 @@ -#if defined(__linux__) || defined(__OpenBSD__) || defined(_NetBSD__) || defined(__sun) || defined(__HAIKU__) +#if defined(__OpenBSD__) + +void * +_mesa_exec_malloc(GLuint size) +{ + return NULL; +} + +void +_mesa_exec_free(void *addr) +{ +} + +#elif defined(__linux__) || defined(_NetBSD__) || defined(__sun) || defined(__HAIKU__) /* * Allocate a large block of memory which can hold code then dole it out
Re: Stop mesa W^X violations
Mark Kettenis writes: > As reported by several people, mesa contains code that violates W^X. > As a result glxgears aborts when using the swrast driver. The diff > below disables the offending code. The code seems to deal the absence > of W|X memory just fine. There is a fallback path that is also used > on SELinux systems. > > Note that the existing code would have worked just fine if mmap > returned MAP_FAILED for W^X violations instead of terminating the > program. Not entirely sure what the long-term plans are. [...] > Index: src/mesa/main/execmem.c > === > RCS file: /cvs/xenocara/lib/mesa/src/mesa/main/execmem.c,v > retrieving revision 1.1.1.1 > diff -u -p -r1.1.1.1 execmem.c > --- src/mesa/main/execmem.c 22 Nov 2015 02:39:37 - 1.1.1.1 > +++ src/mesa/main/execmem.c 20 Jun 2016 20:08:40 - > @@ -36,7 +36,15 @@ > > > > -#if defined(__linux__) || defined(__OpenBSD__) || defined(_NetBSD__) || > defined(__sun) || defined(__HAIKU__) > +#if defined(__OpenBSD__) > + > +static int > +init_heap(void) > +{ > + return 0; > +} The #ifdef excludes the definition of _mesa_exec_malloc and _mesa_exec_free. xlock:/usr/X11R6/lib/modules/dri/i915_dri.so: undefined symbol '_mesa_exec_malloc' xlock:/usr/X11R6/lib/modules/dri/i915_dri.so: undefined symbol '_mesa_exec_free' libGL error: unable to load driver: i915_dri.so libGL error: driver pointer missing libGL error: failed to load driver: i915 > + > +#elif defined(__linux__) || defined(_NetBSD__) || defined(__sun) || > defined(__HAIKU__) > > /* > * Allocate a large block of memory which can hold code then dole it out > -- jca | PGP: 0x1524E7EE / 5135 92C1 AD36 5293 2BDF DDCC 0DFA 74AE 1524 E7EE
Re: Stop mesa W^X violations
On Mon, Jun 20, 2016 at 10:22:58PM +0200, Mark Kettenis wrote: > As reported by several people, mesa contains code that violates W^X. > As a result glxgears aborts when using the swrast driver. The diff > below disables the offending code. The code seems to deal the absence > of W|X memory just fine. There is a fallback path that is also used > on SELinux systems. > > Note that the existing code would have worked just fine if mmap > returned MAP_FAILED for W^X violations instead of terminating the > program. Not entirely sure what the long-term plans are. > Ok matthieu@ > > Index: src/gallium/auxiliary/rtasm/rtasm_execmem.c > === > RCS file: /cvs/xenocara/lib/mesa/src/gallium/auxiliary/rtasm/rtasm_execmem.c,v > retrieving revision 1.1.1.1 > diff -u -p -r1.1.1.1 rtasm_execmem.c > --- src/gallium/auxiliary/rtasm/rtasm_execmem.c 22 Nov 2015 02:43:24 > - 1.1.1.1 > +++ src/gallium/auxiliary/rtasm/rtasm_execmem.c 20 Jun 2016 20:08:37 > - > @@ -69,6 +69,16 @@ static struct mem_block *exec_heap = NUL > static unsigned char *exec_mem = NULL; > > > +#ifdef __OpenBSD__ > + > +static int > +init_heap(void) > +{ > + return 0; > +} > + > +#else > + > static int > init_heap(void) > { > @@ -82,6 +92,8 @@ init_heap(void) > > return (exec_mem != MAP_FAILED); > } > + > +#endif > > > void * > Index: src/mapi/u_execmem.c > === > RCS file: /cvs/xenocara/lib/mesa/src/mapi/u_execmem.c,v > retrieving revision 1.1.1.1 > diff -u -p -r1.1.1.1 u_execmem.c > --- src/mapi/u_execmem.c 22 Nov 2015 02:45:44 - 1.1.1.1 > +++ src/mapi/u_execmem.c 20 Jun 2016 20:08:39 - > @@ -45,8 +45,15 @@ static unsigned int head = 0; > > static unsigned char *exec_mem = (unsigned char *)0; > > +#if defined(__OpenBSD__) > > -#if defined(__linux__) || defined(__OpenBSD__) || defined(_NetBSD__) || > defined(__sun) || defined(__HAIKU__) > +static int > +init_map(void) > +{ > + return 0; > +} > + > +#elif defined(__linux__) || defined(_NetBSD__) || defined(__sun) || > defined(__HAIKU__) > > #include > #include > Index: src/mesa/main/execmem.c > === > RCS file: /cvs/xenocara/lib/mesa/src/mesa/main/execmem.c,v > retrieving revision 1.1.1.1 > diff -u -p -r1.1.1.1 execmem.c > --- src/mesa/main/execmem.c 22 Nov 2015 02:39:37 - 1.1.1.1 > +++ src/mesa/main/execmem.c 20 Jun 2016 20:08:40 - > @@ -36,7 +36,15 @@ > > > > -#if defined(__linux__) || defined(__OpenBSD__) || defined(_NetBSD__) || > defined(__sun) || defined(__HAIKU__) > +#if defined(__OpenBSD__) > + > +static int > +init_heap(void) > +{ > + return 0; > +} > + > +#elif defined(__linux__) || defined(_NetBSD__) || defined(__sun) || > defined(__HAIKU__) > > /* > * Allocate a large block of memory which can hold code then dole it out -- Matthieu Herrb signature.asc Description: PGP signature
Re: Stop mesa W^X violations
>Note that the existing code would have worked just fine if mmap >returned MAP_FAILED for W^X violations instead of terminating the >program. Not entirely sure what the long-term plans are. Yeah, I am not sure of the long-term plans yet either. In discussions with the ports people the idea was fail-hard behaviour for a while, then we'll try error returns for a while, and maybe we need to see-saw a few times. The approach is still very focused on creating awareness amongst the "right people" who can fix things.
Stop mesa W^X violations
As reported by several people, mesa contains code that violates W^X. As a result glxgears aborts when using the swrast driver. The diff below disables the offending code. The code seems to deal the absence of W|X memory just fine. There is a fallback path that is also used on SELinux systems. Note that the existing code would have worked just fine if mmap returned MAP_FAILED for W^X violations instead of terminating the program. Not entirely sure what the long-term plans are. Index: src/gallium/auxiliary/rtasm/rtasm_execmem.c === RCS file: /cvs/xenocara/lib/mesa/src/gallium/auxiliary/rtasm/rtasm_execmem.c,v retrieving revision 1.1.1.1 diff -u -p -r1.1.1.1 rtasm_execmem.c --- src/gallium/auxiliary/rtasm/rtasm_execmem.c 22 Nov 2015 02:43:24 - 1.1.1.1 +++ src/gallium/auxiliary/rtasm/rtasm_execmem.c 20 Jun 2016 20:08:37 - @@ -69,6 +69,16 @@ static struct mem_block *exec_heap = NUL static unsigned char *exec_mem = NULL; +#ifdef __OpenBSD__ + +static int +init_heap(void) +{ + return 0; +} + +#else + static int init_heap(void) { @@ -82,6 +92,8 @@ init_heap(void) return (exec_mem != MAP_FAILED); } + +#endif void * Index: src/mapi/u_execmem.c === RCS file: /cvs/xenocara/lib/mesa/src/mapi/u_execmem.c,v retrieving revision 1.1.1.1 diff -u -p -r1.1.1.1 u_execmem.c --- src/mapi/u_execmem.c22 Nov 2015 02:45:44 - 1.1.1.1 +++ src/mapi/u_execmem.c20 Jun 2016 20:08:39 - @@ -45,8 +45,15 @@ static unsigned int head = 0; static unsigned char *exec_mem = (unsigned char *)0; +#if defined(__OpenBSD__) -#if defined(__linux__) || defined(__OpenBSD__) || defined(_NetBSD__) || defined(__sun) || defined(__HAIKU__) +static int +init_map(void) +{ + return 0; +} + +#elif defined(__linux__) || defined(_NetBSD__) || defined(__sun) || defined(__HAIKU__) #include #include Index: src/mesa/main/execmem.c === RCS file: /cvs/xenocara/lib/mesa/src/mesa/main/execmem.c,v retrieving revision 1.1.1.1 diff -u -p -r1.1.1.1 execmem.c --- src/mesa/main/execmem.c 22 Nov 2015 02:39:37 - 1.1.1.1 +++ src/mesa/main/execmem.c 20 Jun 2016 20:08:40 - @@ -36,7 +36,15 @@ -#if defined(__linux__) || defined(__OpenBSD__) || defined(_NetBSD__) || defined(__sun) || defined(__HAIKU__) +#if defined(__OpenBSD__) + +static int +init_heap(void) +{ + return 0; +} + +#elif defined(__linux__) || defined(_NetBSD__) || defined(__sun) || defined(__HAIKU__) /* * Allocate a large block of memory which can hold code then dole it out