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
|
Index: linux-2.6.17/include/linux/vserver/network.h
===================================================================
--- linux-2.6.17.orig/include/linux/vserver/network.h
+++ linux-2.6.17/include/linux/vserver/network.h
@@ -13,6 +13,8 @@
/* network flags */
+#define NXF_INFO_LOCK 0x00000001
+
#define NXF_STATE_SETUP (1ULL<<32)
#define NXF_STATE_ADMIN (1ULL<<34)
Index: linux-2.6.17/kernel/vserver/context.c
===================================================================
--- linux-2.6.17.orig/kernel/vserver/context.c
+++ linux-2.6.17/kernel/vserver/context.c
@@ -3,7 +3,7 @@
*
* Virtual Server: Context Support
*
- * Copyright (C) 2003-2005 Herbert P�tzl
+ * Copyright (C) 2003-2006 Herbert P�tzl
*
* V0.01 context helper
* V0.02 vx_ctx_kill syscall command
@@ -578,6 +578,10 @@ int vx_migrate_user(struct task_struct *
if (!p || !vxi)
BUG();
+
+ if (vx_info_flags(vxi, VXF_INFO_LOCK, 0))
+ return -EACCES;
+
new_user = alloc_uid(vxi->vx_id, p->uid);
if (!new_user)
return -ENOMEM;
@@ -636,6 +640,9 @@ int vx_migrate_task(struct task_struct *
if (!p || !vxi)
BUG();
+ if (vx_info_flags(vxi, VXF_INFO_LOCK, 0))
+ return -EACCES;
+
old_vxi = task_get_vx_info(p);
if (old_vxi == vxi)
goto out;
@@ -851,9 +858,10 @@ int vc_ctx_create(uint32_t xid, void __u
vx_set_persistent(new_vxi);
vs_state_change(new_vxi, VSC_STARTUP);
- ret = new_vxi->vx_id;
- vx_migrate_task(current, new_vxi);
+ ret = vx_migrate_task(current, new_vxi);
/* if this fails, we might end up with a hashed vx_info */
+ if (ret == 0)
+ ret = new_vxi->vx_id;
put_vx_info(new_vxi);
return ret;
}
@@ -863,6 +871,7 @@ int vc_ctx_migrate(uint32_t id, void __u
{
struct vcmd_ctx_migrate vc_data = { .flagword = 0 };
struct vx_info *vxi;
+ int ret;
if (data && copy_from_user (&vc_data, data, sizeof(vc_data)))
return -EFAULT;
@@ -876,13 +885,22 @@ int vc_ctx_migrate(uint32_t id, void __u
vxi = lookup_vx_info(id);
if (!vxi)
return -ESRCH;
- vx_migrate_task(current, vxi);
+
+ ret = vx_migrate_task(current, vxi);
+ if (ret)
+ goto out_put;
if (vc_data.flagword & VXM_SET_INIT)
- vx_set_init(vxi, current);
+ ret = vx_set_init(vxi, current);
+ if (ret)
+ goto out_put;
if (vc_data.flagword & VXM_SET_REAPER)
- vx_set_reaper(vxi, current);
+ ret = vx_set_reaper(vxi, current);
+ if (ret)
+ goto out_put;
+ ret = 0;
+out_put:
put_vx_info(vxi);
- return 0;
+ return ret;
}
@@ -912,6 +930,7 @@ int vc_set_cflags(uint32_t id, void __us
struct vx_info *vxi;
struct vcmd_ctx_flags_v0 vc_data;
uint64_t mask, trigger;
+ int ret;
if (copy_from_user (&vc_data, data, sizeof(vc_data)))
return -EFAULT;
@@ -932,8 +951,12 @@ int vc_set_cflags(uint32_t id, void __us
if (trigger & VXF_STATE_SETUP)
vx_mask_cap_bset(vxi, current);
if (trigger & VXF_STATE_INIT) {
- vx_set_init(vxi, current);
- vx_set_reaper(vxi, current);
+ ret = vx_set_init(vxi, current);
+ if (!ret)
+ goto out_put;
+ ret = vx_set_reaper(vxi, current);
+ if (!ret)
+ goto out_put;
}
}
@@ -941,9 +964,10 @@ int vc_set_cflags(uint32_t id, void __us
vc_data.flagword, mask);
if (trigger & VXF_PERSISTENT)
vx_set_persistent(vxi);
-
+ ret = 0;
+out_put:
put_vx_info(vxi);
- return 0;
+ return ret;
}
static int do_get_caps(xid_t xid, uint64_t *bcaps, uint64_t *ccaps)
Index: linux-2.6.17/kernel/vserver/namespace.c
===================================================================
--- linux-2.6.17.orig/kernel/vserver/namespace.c
+++ linux-2.6.17/kernel/vserver/namespace.c
@@ -3,7 +3,7 @@
*
* Virtual Server: Context Namespace Support
*
- * Copyright (C) 2003-2005 Herbert P�tzl
+ * Copyright (C) 2003-2006 Herbert P�tzl
*
* V0.01 broken out from context.c 0.07
* V0.02 added task locking for namespace
@@ -62,6 +62,10 @@ int vc_enter_namespace(uint32_t id, void
if (!vxi->vx_namespace)
goto out_put;
+ ret = -EACCES;
+ if (vx_info_flags(vxi, VXF_INFO_LOCK, 0))
+ goto out_put;
+
ret = -ENOMEM;
fs = copy_fs_struct(vxi->vx_fs);
if (!fs)
Index: linux-2.6.17/kernel/vserver/network.c
===================================================================
--- linux-2.6.17.orig/kernel/vserver/network.c
+++ linux-2.6.17/kernel/vserver/network.c
@@ -3,7 +3,7 @@
*
* Virtual Server: Network Support
*
- * Copyright (C) 2003-2005 Herbert P�tzl
+ * Copyright (C) 2003-2006 Herbert P�tzl
*
* V0.01 broken out from vcontext V0.05
* V0.02 cleaned up implementation
@@ -605,13 +605,21 @@ int vc_net_create(uint32_t nid, void __u
int vc_net_migrate(uint32_t id, void __user *data)
{
struct nx_info *nxi;
+ int ret;
nxi = lookup_nx_info(id);
if (!nxi)
return -ESRCH;
+
+ ret = -EPERM;
+ if (nx_info_flags(nxi, NXF_INFO_LOCK, 0))
+ goto out_put;
+
nx_migrate_task(current, nxi);
+ ret = 0;
+out_put:
put_nx_info(nxi);
- return 0;
+ return ret;
}
int vc_net_add(uint32_t nid, void __user *data)
|