summaryrefslogtreecommitdiff
blob: 617940d60fa39fda50cde562e3e463656ec71c3b (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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
Index: linux-2.6.17/arch/alpha/kernel/ptrace.c
===================================================================
--- linux-2.6.17.orig/arch/alpha/kernel/ptrace.c
+++ linux-2.6.17/arch/alpha/kernel/ptrace.c
@@ -284,7 +284,7 @@ do_sys_ptrace(long request, long pid, lo
 		goto out_notsk;
 	}
 
-	if (!vx_check(vx_task_xid(child), VX_WATCH|VX_IDENT)) {
+	if (!vx_check(vx_task_xid(child), VX_WATCH_P|VX_IDENT)) {
 		ret = -EPERM;
 		goto out;
 	}
Index: linux-2.6.17/arch/ia64/kernel/ptrace.c
===================================================================
--- linux-2.6.17.orig/arch/ia64/kernel/ptrace.c
+++ linux-2.6.17/arch/ia64/kernel/ptrace.c
@@ -1444,7 +1444,7 @@ sys_ptrace (long request, pid_t pid, uns
 	read_unlock(&tasklist_lock);
 	if (!child)
 		goto out;
-	if (!vx_check(vx_task_xid(child), VX_WATCH|VX_IDENT))
+	if (!vx_check(vx_task_xid(child), VX_WATCH_P|VX_IDENT))
 		goto out_tsk;
 
 	ret = -EPERM;
Index: linux-2.6.17/arch/m68k/kernel/ptrace.c
===================================================================
--- linux-2.6.17.orig/arch/m68k/kernel/ptrace.c
+++ linux-2.6.17/arch/m68k/kernel/ptrace.c
@@ -280,7 +280,7 @@ long arch_ptrace(struct task_struct *chi
 		ret = ptrace_request(child, request, addr, data);
 		break;
 	}
-	if (!vx_check(vx_task_xid(child), VX_WATCH|VX_IDENT))
+	if (!vx_check(vx_task_xid(child), VX_WATCH_P|VX_IDENT))
 		goto out_tsk;
 
 	return ret;
Index: linux-2.6.17/arch/mips/kernel/ptrace.c
===================================================================
--- linux-2.6.17.orig/arch/mips/kernel/ptrace.c
+++ linux-2.6.17/arch/mips/kernel/ptrace.c
@@ -490,7 +490,7 @@ asmlinkage void do_syscall_trace(struct 
 		goto out;
 	if (!test_thread_flag(TIF_SYSCALL_TRACE))
 		goto out;
-	if (!vx_check(vx_task_xid(child), VX_WATCH|VX_IDENT))
+	if (!vx_check(vx_task_xid(child), VX_WATCH_P|VX_IDENT))
 		goto out_tsk;
 
 	/* The 0x80 provides a way for the tracing parent to distinguish
Index: linux-2.6.17/arch/s390/kernel/ptrace.c
===================================================================
--- linux-2.6.17.orig/arch/s390/kernel/ptrace.c
+++ linux-2.6.17/arch/s390/kernel/ptrace.c
@@ -723,7 +723,7 @@ sys_ptrace(long request, long pid, long 
 		goto out;
 	}
 
-	if (!vx_check(vx_task_xid(child), VX_WATCH|VX_IDENT)) {
+	if (!vx_check(vx_task_xid(child), VX_WATCH_P|VX_IDENT)) {
 		ret = -EPERM;
 		goto out_tsk;
 	}
Index: linux-2.6.17/arch/sparc/kernel/ptrace.c
===================================================================
--- linux-2.6.17.orig/arch/sparc/kernel/ptrace.c
+++ linux-2.6.17/arch/sparc/kernel/ptrace.c
@@ -300,7 +300,7 @@ asmlinkage void do_ptrace(struct pt_regs
 		pt_error_return(regs, -ret);
 		goto out;
 	}
-	if (!vx_check(vx_task_xid(child), VX_WATCH|VX_IDENT)) {
+	if (!vx_check(vx_task_xid(child), VX_WATCH_P|VX_IDENT)) {
 		pt_error_return(regs, ESRCH);
 		goto out_tsk;
 	}
Index: linux-2.6.17/arch/sparc64/kernel/ptrace.c
===================================================================
--- linux-2.6.17.orig/arch/sparc64/kernel/ptrace.c
+++ linux-2.6.17/arch/sparc64/kernel/ptrace.c
@@ -213,7 +213,7 @@ asmlinkage void do_ptrace(struct pt_regs
 		pt_error_return(regs, -ret);
 		goto out;
 	}
-	if (!vx_check(vx_task_xid(child), VX_WATCH|VX_IDENT)) {
+	if (!vx_check(vx_task_xid(child), VX_WATCH_P|VX_IDENT)) {
 		pt_error_return(regs, ESRCH);
 		goto out_tsk;
 	}
Index: linux-2.6.17/arch/v850/kernel/ptrace.c
===================================================================
--- linux-2.6.17.orig/arch/v850/kernel/ptrace.c
+++ linux-2.6.17/arch/v850/kernel/ptrace.c
@@ -117,7 +117,7 @@ long arch_ptrace(struct task_struct *chi
 {
 	int rval;
 
-	if (!vx_check(vx_task_xid(child), VX_WATCH|VX_IDENT))
+	if (!vx_check(vx_task_xid(child), VX_WATCH_P|VX_IDENT))
 		goto out;
 
 	switch (request) {
Index: linux-2.6.17/fs/devpts/inode.c
===================================================================
--- linux-2.6.17.orig/fs/devpts/inode.c
+++ linux-2.6.17/fs/devpts/inode.c
@@ -26,7 +26,7 @@ static int devpts_permission(struct inod
 	int ret = -EACCES;
 
 	/* devpts is xid tagged */
-	if (vx_check((xid_t)inode->i_tag, VX_IDENT))
+	if (vx_check((xid_t)inode->i_tag, VX_WATCH_P|VX_IDENT))
 		ret = generic_permission(inode, mask, NULL);
 	return ret;
 }
@@ -107,7 +107,7 @@ static int devpts_remount(struct super_b
 static int devpts_filter(struct dentry *de)
 {
 	/* devpts is xid tagged */
-	return vx_check((xid_t)de->d_inode->i_tag, VX_IDENT);
+	return vx_check((xid_t)de->d_inode->i_tag, VX_WATCH_P|VX_IDENT);
 }
 
 static int devpts_readdir(struct file * filp, void * dirent, filldir_t filldir)
Index: linux-2.6.17/fs/locks.c
===================================================================
--- linux-2.6.17.orig/fs/locks.c
+++ linux-2.6.17/fs/locks.c
@@ -2142,7 +2142,7 @@ int get_locks_status(char *buffer, char 
 		struct list_head *btmp;
 		struct file_lock *fl = list_entry(tmp, struct file_lock, fl_link);
 
-		if (!vx_check(fl->fl_xid, VX_IDENT|VX_WATCH))
+		if (!vx_check(fl->fl_xid, VX_WATCH_P|VX_IDENT))
 			continue;
 
 		lock_get_status(q, fl, ++i, "");
Index: linux-2.6.17/fs/namespace.c
===================================================================
--- linux-2.6.17.orig/fs/namespace.c
+++ linux-2.6.17/fs/namespace.c
@@ -406,7 +406,7 @@ static int show_vfsmnt(struct seq_file *
 
 	if (vx_flags(VXF_HIDE_MOUNT, 0))
 		return 0;
-	if (!mnt_is_reachable(mnt) && !vx_check(0, VX_WATCH))
+	if (!mnt_is_reachable(mnt) && !vx_check(0, VX_WATCH_P))
 		return 0;
 
 	if (!vx_check(0, VX_ADMIN|VX_WATCH) &&
@@ -451,7 +451,7 @@ static int show_vfsstat(struct seq_file 
 
 	if (vx_flags(VXF_HIDE_MOUNT, 0))
 		return 0;
-	if (!mnt_is_reachable(mnt) && !vx_check(0, VX_WATCH))
+	if (!mnt_is_reachable(mnt) && !vx_check(0, VX_WATCH_P))
 		return 0;
 
 	if (!vx_check(0, VX_ADMIN|VX_WATCH) &&
Index: linux-2.6.17/include/linux/vserver/context.h
===================================================================
--- linux-2.6.17.orig/include/linux/vserver/context.h
+++ linux-2.6.17/include/linux/vserver/context.h
@@ -188,6 +188,14 @@ struct vx_info_save {
 #define VX_ATR_MASK	0x0F00
 
 
+#ifdef	CONFIG_VSERVER_PRIVACY
+#define VX_ADMIN_P	(0)
+#define VX_WATCH_P	(0)
+#else
+#define VX_ADMIN_P	VX_ADMIN
+#define VX_WATCH_P	VX_WATCH
+#endif
+
 extern void claim_vx_info(struct vx_info *, struct task_struct *);
 extern void release_vx_info(struct vx_info *, struct task_struct *);
 
Index: linux-2.6.17/include/net/af_unix.h
===================================================================
--- linux-2.6.17.orig/include/net/af_unix.h
+++ linux-2.6.17/include/net/af_unix.h
@@ -34,7 +34,7 @@ static inline struct sock *next_unix_soc
 			s = sk_next(s);
 		if (!s)
 			s = next_unix_socket_table(i);
-	} while (s && !vx_check(s->sk_xid, VX_IDENT|VX_WATCH));
+	} while (s && !vx_check(s->sk_xid, VX_WATCH_P|VX_IDENT));
 	return s;
 }
 
Index: linux-2.6.17/ipc/msg.c
===================================================================
--- linux-2.6.17.orig/ipc/msg.c
+++ linux-2.6.17/ipc/msg.c
@@ -827,7 +827,7 @@ static int sysvipc_msg_proc_show(struct 
 {
 	struct msg_queue *msq = it;
 
-	if (!vx_check(msq->q_perm.xid, VX_IDENT))
+	if (!vx_check(msq->q_perm.xid, VX_WATCH_P|VX_IDENT))
 		return 0;
 
 	return seq_printf(s,
Index: linux-2.6.17/ipc/sem.c
===================================================================
--- linux-2.6.17.orig/ipc/sem.c
+++ linux-2.6.17/ipc/sem.c
@@ -1351,7 +1351,7 @@ static int sysvipc_sem_proc_show(struct 
 {
 	struct sem_array *sma = it;
 
-	if (!vx_check(sma->sem_perm.xid, VX_IDENT))
+	if (!vx_check(sma->sem_perm.xid, VX_WATCH_P|VX_IDENT))
 		return 0;
 
 	return seq_printf(s,
Index: linux-2.6.17/ipc/shm.c
===================================================================
--- linux-2.6.17.orig/ipc/shm.c
+++ linux-2.6.17/ipc/shm.c
@@ -926,7 +926,7 @@ static int sysvipc_shm_proc_show(struct 
 #define SMALL_STRING "%10d %10d  %4o %10u %5u %5u  %5d %5u %5u %5u %5u %10lu %10lu %10lu\n"
 #define BIG_STRING   "%10d %10d  %4o %21u %5u %5u  %5d %5u %5u %5u %5u %10lu %10lu %10lu\n"
 
-	if (!vx_check(shp->shm_perm.xid, VX_IDENT))
+	if (!vx_check(shp->shm_perm.xid, VX_WATCH_P|VX_IDENT))
 		return 0;
 
 	if (sizeof(size_t) <= sizeof(int))
Index: linux-2.6.17/ipc/util.c
===================================================================
--- linux-2.6.17.orig/ipc/util.c
+++ linux-2.6.17/ipc/util.c
@@ -160,7 +160,7 @@ int ipc_findkey(struct ipc_ids* ids, key
 		p = ids->entries->p[id];
 		if (p==NULL)
 			continue;
-		if (!vx_check(p->xid, VX_IDENT))
+		if (!vx_check(p->xid, VX_WATCH_P|VX_IDENT))
 			continue;
 		if (key == p->key)
 			return id;
@@ -474,7 +474,7 @@ int ipcperms (struct kern_ipc_perm *ipcp
 	if (unlikely((err = audit_ipc_obj(ipcp))))
 		return err;
 
-	if (!vx_check(ipcp->xid, VX_ADMIN|VX_IDENT)) /* maybe just VX_IDENT? */
+	if (!vx_check(ipcp->xid, VX_WATCH_P|VX_IDENT)) /* maybe just VX_IDENT? */
 		return -1;
 	requested_mode = (flag >> 6) | (flag >> 3) | flag;
 	granted_mode = ipcp->mode;
Index: linux-2.6.17/kernel/ptrace.c
===================================================================
--- linux-2.6.17.orig/kernel/ptrace.c
+++ linux-2.6.17/kernel/ptrace.c
@@ -508,7 +508,7 @@ asmlinkage long sys_ptrace(long request,
 	}
 
 	ret = -EPERM;
-	if (!vx_check(vx_task_xid(child), VX_WATCH|VX_IDENT))
+	if (!vx_check(vx_task_xid(child), VX_WATCH_P|VX_IDENT))
 		goto out_put_task_struct;
 
 	if (request == PTRACE_ATTACH) {
Index: linux-2.6.17/kernel/signal.c
===================================================================
--- linux-2.6.17.orig/kernel/signal.c
+++ linux-2.6.17/kernel/signal.c
@@ -591,7 +591,7 @@ static int check_kill_permission(int sig
 		return error;
 
 	error = -ESRCH;
-	if (user && !vx_check(vx_task_xid(t), VX_ADMIN|VX_IDENT))
+	if (user && !vx_check(vx_task_xid(t), VX_WATCH_P|VX_IDENT))
 		return error;
 
 	error = security_task_kill(t, info, sig);
Index: linux-2.6.17/kernel/vserver/Kconfig
===================================================================
--- linux-2.6.17.orig/kernel/vserver/Kconfig
+++ linux-2.6.17/kernel/vserver/Kconfig
@@ -191,6 +191,14 @@ config	PROPAGATE
 	  a tagid which is to be used for the entire mount
 	  tree.
 
+config	VSERVER_PRIVACY
+	bool	"Honor Privacy Aspects of Guests"
+	default y
+	help
+	  When enabled, most context checks will disallow
+	  access to structures assigned to a specific context,
+	  like ptys or loop devices.
+
 config	VSERVER_DEBUG
 	bool	"VServer Debugging Code"
 	default n
Index: linux-2.6.17/net/ipv4/inet_diag.c
===================================================================
--- linux-2.6.17.orig/net/ipv4/inet_diag.c
+++ linux-2.6.17/net/ipv4/inet_diag.c
@@ -694,7 +694,7 @@ static int inet_diag_dump(struct sk_buff
 			sk_for_each(sk, node, &hashinfo->listening_hash[i]) {
 				struct inet_sock *inet = inet_sk(sk);
 
-				if (!vx_check(sk->sk_xid, VX_IDENT|VX_WATCH))
+				if (!vx_check(sk->sk_xid, VX_WATCH_P|VX_IDENT))
 					continue;
 				if (num < s_num) {
 					num++;
@@ -756,7 +756,7 @@ skip_listen_ht:
 		sk_for_each(sk, node, &head->chain) {
 			struct inet_sock *inet = inet_sk(sk);
 
-			if (!vx_check(sk->sk_xid, VX_IDENT|VX_WATCH))
+			if (!vx_check(sk->sk_xid, VX_WATCH_P|VX_IDENT))
 				continue;
 			if (num < s_num)
 				goto next_normal;
@@ -782,7 +782,7 @@ next_normal:
 			inet_twsk_for_each(tw, node,
 				    &hashinfo->ehash[i + hashinfo->ehash_size].chain) {
 
-				if (!vx_check(tw->tw_xid, VX_IDENT|VX_WATCH))
+				if (!vx_check(tw->tw_xid, VX_WATCH_P|VX_IDENT))
 					continue;
 				if (num < s_num)
 					goto next_dying;
Index: linux-2.6.17/net/ipv4/raw.c
===================================================================
--- linux-2.6.17.orig/net/ipv4/raw.c
+++ linux-2.6.17/net/ipv4/raw.c
@@ -822,7 +822,7 @@ static struct sock *raw_get_first(struct
 
 		sk_for_each(sk, node, &raw_v4_htable[state->bucket])
 			if (sk->sk_family == PF_INET &&
-				vx_check(sk->sk_xid, VX_IDENT|VX_WATCH))
+				vx_check(sk->sk_xid, VX_WATCH_P|VX_IDENT))
 				goto found;
 	}
 	sk = NULL;
@@ -839,7 +839,7 @@ static struct sock *raw_get_next(struct 
 try_again:
 		;
 	} while (sk && (sk->sk_family != PF_INET ||
-		!vx_check(sk->sk_xid, VX_IDENT|VX_WATCH)));
+		!vx_check(sk->sk_xid, VX_WATCH_P|VX_IDENT)));
 
 	if (!sk && ++state->bucket < RAWV4_HTABLE_SIZE) {
 		sk = sk_head(&raw_v4_htable[state->bucket]);
Index: linux-2.6.17/net/ipv4/tcp_ipv4.c
===================================================================
--- linux-2.6.17.orig/net/ipv4/tcp_ipv4.c
+++ linux-2.6.17/net/ipv4/tcp_ipv4.c
@@ -1360,7 +1360,7 @@ static void *listening_get_next(struct s
 					"sk,req: %p [#%d] (from %d)", req->sk,
 					(req->sk)?req->sk->sk_xid:0, vx_current_xid());
 				if (req->sk &&
-					!vx_check(req->sk->sk_xid, VX_IDENT|VX_WATCH))
+					!vx_check(req->sk->sk_xid, VX_WATCH_P|VX_IDENT))
 					continue;
 				if (req->rsk_ops->family == st->family) {
 					cur = req;
@@ -1388,7 +1388,7 @@ get_sk:
 	sk_for_each_from(sk, node) {
 		vxdprintk(VXD_CBIT(net, 6), "sk: %p [#%d] (from %d)",
 			sk, sk->sk_xid, vx_current_xid());
-		if (!vx_check(sk->sk_xid, VX_IDENT|VX_WATCH))
+		if (!vx_check(sk->sk_xid, VX_WATCH_P|VX_IDENT))
 			continue;
 		if (sk->sk_family == st->family) {
 			cur = sk;
@@ -1444,7 +1444,7 @@ static void *established_get_first(struc
 			vxdprintk(VXD_CBIT(net, 6),
 				"sk,egf: %p [#%d] (from %d)",
 				sk, sk->sk_xid, vx_current_xid());
-			if (!vx_check(sk->sk_xid, VX_IDENT|VX_WATCH))
+			if (!vx_check(sk->sk_xid, VX_WATCH_P|VX_IDENT))
 				continue;
 			if (sk->sk_family != st->family)
 				continue;
@@ -1457,7 +1457,7 @@ static void *established_get_first(struc
 			vxdprintk(VXD_CBIT(net, 6),
 				"tw: %p [#%d] (from %d)",
 				tw, tw->tw_xid, vx_current_xid());
-			if (!vx_check(tw->tw_xid, VX_IDENT|VX_WATCH))
+			if (!vx_check(tw->tw_xid, VX_WATCH_P|VX_IDENT))
 				continue;
 			if (tw->tw_family != st->family)
 				continue;
@@ -1485,7 +1485,7 @@ static void *established_get_next(struct
 		tw = tw_next(tw);
 get_tw:
 		while (tw && (tw->tw_family != st->family ||
-			!vx_check(tw->tw_xid, VX_IDENT|VX_WATCH))) {
+			!vx_check(tw->tw_xid, VX_WATCH_P|VX_IDENT))) {
 			tw = tw_next(tw);
 		}
 		if (tw) {
@@ -1512,7 +1512,7 @@ get_tw:
 		vxdprintk(VXD_CBIT(net, 6),
 			"sk,egn: %p [#%d] (from %d)",
 			sk, sk->sk_xid, vx_current_xid());
-		if (!vx_check(sk->sk_xid, VX_IDENT|VX_WATCH))
+		if (!vx_check(sk->sk_xid, VX_WATCH_P|VX_IDENT))
 			continue;
 		if (sk->sk_family == st->family)
 			goto found;
Index: linux-2.6.17/net/ipv4/udp.c
===================================================================
--- linux-2.6.17.orig/net/ipv4/udp.c
+++ linux-2.6.17/net/ipv4/udp.c
@@ -1424,7 +1424,7 @@ static struct sock *udp_get_first(struct
 
 		sk_for_each(sk, node, &udp_hash[state->bucket]) {
 			if (sk->sk_family == state->family &&
-				vx_check(sk->sk_xid, VX_IDENT|VX_WATCH))
+				vx_check(sk->sk_xid, VX_WATCH_P|VX_IDENT))
 				goto found;
 		}
 	}
@@ -1442,7 +1442,7 @@ static struct sock *udp_get_next(struct 
 try_again:
 		;
 	} while (sk && (sk->sk_family != state->family ||
-		!vx_check(sk->sk_xid, VX_IDENT|VX_WATCH)));
+		!vx_check(sk->sk_xid, VX_WATCH_P|VX_IDENT)));
 
 	if (!sk && ++state->bucket < UDP_HTABLE_SIZE) {
 		sk = sk_head(&udp_hash[state->bucket]);
Index: linux-2.6.17/net/unix/af_unix.c
===================================================================
--- linux-2.6.17.orig/net/unix/af_unix.c
+++ linux-2.6.17/net/unix/af_unix.c
@@ -238,7 +238,7 @@ static struct sock *__unix_find_socket_b
 	sk_for_each(s, node, &unix_socket_table[hash ^ type]) {
 		struct unix_sock *u = unix_sk(s);
 
-		if (!vx_check(s->sk_xid, VX_IDENT|VX_WATCH))
+		if (!vx_check(s->sk_xid, VX_WATCH_P|VX_IDENT))
 			continue;
 		if (u->addr->len == len &&
 		    !memcmp(u->addr->name, sunname, len))