summaryrefslogtreecommitdiffstats
path: root/mesa-7.0-selinux-awareness.patch
blob: dcce75206237aecb57e315a47ebfc4389aa7f1d8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
diff -up Mesa-7.0/src/mesa/tnl/t_vertex_sse.c.jx Mesa-7.0/src/mesa/tnl/t_vertex_sse.c
--- Mesa-7.0/src/mesa/tnl/t_vertex_sse.c.jx	2007-06-21 18:10:54.000000000 -0400
+++ Mesa-7.0/src/mesa/tnl/t_vertex_sse.c	2007-07-23 15:59:26.000000000 -0400
@@ -348,7 +348,8 @@ static GLboolean build_vertex_emit( stru
    struct x86_reg vp1 = x86_make_reg(file_XMM, 2);
    GLubyte *fixup, *label;
 
-   x86_init_func(&p->func);
+   if (!x86_init_func(&p->func))
+       return GL_FALSE;
    
    /* Push a few regs?
     */
@@ -646,7 +647,10 @@ void _tnl_generate_sse_emit( GLcontext *
    p.identity = x86_make_reg(file_XMM, 6);
    p.chan0 = x86_make_reg(file_XMM, 7);
 
-   x86_init_func(&p.func);
+   if (!x86_init_func(&p.func)) {
+      vtx->codegen_emit = NULL;
+      return;
+   }
 
    if (build_vertex_emit(&p)) {
       _tnl_register_fastpath( vtx, GL_TRUE );
diff -up Mesa-7.0/src/mesa/x86/rtasm/x86sse.h.jx Mesa-7.0/src/mesa/x86/rtasm/x86sse.h
--- Mesa-7.0/src/mesa/x86/rtasm/x86sse.h.jx	2007-06-21 18:10:55.000000000 -0400
+++ Mesa-7.0/src/mesa/x86/rtasm/x86sse.h	2007-07-23 15:59:23.000000000 -0400
@@ -80,8 +80,8 @@ enum sse_cc {
  */
 
 
-void x86_init_func( struct x86_function *p );
-void x86_init_func_size( struct x86_function *p, GLuint code_size );
+int x86_init_func( struct x86_function *p );
+int x86_init_func_size( struct x86_function *p, GLuint code_size );
 void x86_release_func( struct x86_function *p );
 void (*x86_get_func( struct x86_function *p ))( void );
 
diff -up Mesa-7.0/src/mesa/x86/rtasm/x86sse.c.jx Mesa-7.0/src/mesa/x86/rtasm/x86sse.c
--- Mesa-7.0/src/mesa/x86/rtasm/x86sse.c.jx	2007-06-21 18:10:55.000000000 -0400
+++ Mesa-7.0/src/mesa/x86/rtasm/x86sse.c	2007-07-23 15:59:23.000000000 -0400
@@ -1063,15 +1063,17 @@ struct x86_reg x86_fn_arg( struct x86_fu
 }
 
 
-void x86_init_func( struct x86_function *p )
+int x86_init_func( struct x86_function *p )
 {
-   x86_init_func_size(p, 1024);
+   return x86_init_func_size(p, 1024);
 }
 
-void x86_init_func_size( struct x86_function *p, GLuint code_size )
+int x86_init_func_size( struct x86_function *p, GLuint code_size )
 {
    p->store = _mesa_exec_malloc(code_size);
    p->csr = p->store;
+
+   return (p->store != NULL);
 }
 
 void x86_release_func( struct x86_function *p )
diff -up Mesa-7.0/src/mesa/main/execmem.c.jx Mesa-7.0/src/mesa/main/execmem.c
--- Mesa-7.0/src/mesa/main/execmem.c.jx	2007-06-21 18:10:54.000000000 -0400
+++ Mesa-7.0/src/mesa/main/execmem.c	2007-07-23 16:02:30.000000000 -0400
@@ -46,6 +46,7 @@
 #include <unistd.h>
 #include <sys/mman.h>
 #include "mm.h"
+#include <selinux/selinux.h>
 
 #define EXEC_HEAP_SIZE (10*1024*1024)
 
@@ -55,9 +56,16 @@ static struct mem_block *exec_heap = NUL
 static unsigned char *exec_mem = NULL;
 
 
-static void
+static int
 init_heap(void)
 {
+
+   if (is_selinux_enabled()) {
+      if (!security_get_boolean_active("allow_execmem") ||
+	  !security_get_boolean_pending("allow_execmem"))
+      return 0;
+   }
+
    if (!exec_heap)
       exec_heap = mmInit( 0, EXEC_HEAP_SIZE );
    
@@ -65,6 +73,8 @@ init_heap(void)
       exec_mem = (unsigned char *) mmap(0, EXEC_HEAP_SIZE, 
 					PROT_EXEC | PROT_READ | PROT_WRITE, 
 					MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
+
+   return (exec_mem != NULL);
 }
 
 
@@ -76,7 +86,8 @@ _mesa_exec_malloc(GLuint size)
 
    _glthread_LOCK_MUTEX(exec_mutex);
 
-   init_heap();
+   if (!init_heap())
+      goto bail;
 
    if (exec_heap) {
       size = (size + 31) & ~31;
@@ -87,7 +98,8 @@ _mesa_exec_malloc(GLuint size)
       addr = exec_mem + block->ofs;
    else 
       _mesa_printf("_mesa_exec_malloc failed\n");
-   
+
+bail: 
    _glthread_UNLOCK_MUTEX(exec_mutex);
    
    return addr;
diff -up Mesa-7.0/configs/linux-dri.jx Mesa-7.0/configs/linux-dri
--- Mesa-7.0/configs/linux-dri.jx	2007-07-23 15:59:07.000000000 -0400
+++ Mesa-7.0/configs/linux-dri	2007-07-23 17:37:36.000000000 -0400
@@ -39,7 +39,8 @@ EXTRA_LIB_PATH =
 
 LIBDRM_CFLAGS = `pkg-config --cflags libdrm`
 LIBDRM_LIB = `pkg-config --libs libdrm`
-DRI_LIB_DEPS  = $(EXTRA_LIB_PATH) -lm -lpthread -lexpat -ldl $(LIBDRM_LIB)
+DRI_LIB_DEPS  = $(EXTRA_LIB_PATH) -lm -lpthread -lexpat -ldl $(LIBDRM_LIB) \
+		-lselinux
 GL_LIB_DEPS   = $(EXTRA_LIB_PATH) -lX11 -lXext -lXxf86vm -lXdamage -lXfixes \
 		-lm -lpthread -ldl \
                 $(LIBDRM_LIB)