@@ -68,25 +68,6 @@ static int proc_ipc_sem_dointvec(struct ctl_table *table, int write,
68
68
return ret ;
69
69
}
70
70
71
- #ifdef CONFIG_CHECKPOINT_RESTORE
72
- static int proc_ipc_dointvec_minmax_checkpoint_restore (struct ctl_table * table ,
73
- int write , void * buffer , size_t * lenp , loff_t * ppos )
74
- {
75
- struct ipc_namespace * ns = table -> extra1 ;
76
- struct ctl_table ipc_table ;
77
-
78
- if (write && !checkpoint_restore_ns_capable (ns -> user_ns ))
79
- return - EPERM ;
80
-
81
- memcpy (& ipc_table , table , sizeof (ipc_table ));
82
-
83
- ipc_table .extra1 = SYSCTL_ZERO ;
84
- ipc_table .extra2 = SYSCTL_INT_MAX ;
85
-
86
- return proc_dointvec_minmax (& ipc_table , write , buffer , lenp , ppos );
87
- }
88
- #endif
89
-
90
71
int ipc_mni = IPCMNI ;
91
72
int ipc_mni_shift = IPCMNI_SHIFT ;
92
73
int ipc_min_cycle = RADIX_TREE_MAP_SIZE ;
@@ -172,22 +153,28 @@ static struct ctl_table ipc_sysctls[] = {
172
153
.procname = "sem_next_id" ,
173
154
.data = & init_ipc_ns .ids [IPC_SEM_IDS ].next_id ,
174
155
.maxlen = sizeof (init_ipc_ns .ids [IPC_SEM_IDS ].next_id ),
175
- .mode = 0666 ,
176
- .proc_handler = proc_ipc_dointvec_minmax_checkpoint_restore ,
156
+ .mode = 0444 ,
157
+ .proc_handler = proc_dointvec_minmax ,
158
+ .extra1 = SYSCTL_ZERO ,
159
+ .extra2 = SYSCTL_INT_MAX ,
177
160
},
178
161
{
179
162
.procname = "msg_next_id" ,
180
163
.data = & init_ipc_ns .ids [IPC_MSG_IDS ].next_id ,
181
164
.maxlen = sizeof (init_ipc_ns .ids [IPC_MSG_IDS ].next_id ),
182
- .mode = 0666 ,
183
- .proc_handler = proc_ipc_dointvec_minmax_checkpoint_restore ,
165
+ .mode = 0444 ,
166
+ .proc_handler = proc_dointvec_minmax ,
167
+ .extra1 = SYSCTL_ZERO ,
168
+ .extra2 = SYSCTL_INT_MAX ,
184
169
},
185
170
{
186
171
.procname = "shm_next_id" ,
187
172
.data = & init_ipc_ns .ids [IPC_SHM_IDS ].next_id ,
188
173
.maxlen = sizeof (init_ipc_ns .ids [IPC_SHM_IDS ].next_id ),
189
- .mode = 0666 ,
190
- .proc_handler = proc_ipc_dointvec_minmax_checkpoint_restore ,
174
+ .mode = 0444 ,
175
+ .proc_handler = proc_dointvec_minmax ,
176
+ .extra1 = SYSCTL_ZERO ,
177
+ .extra2 = SYSCTL_INT_MAX ,
191
178
},
192
179
#endif
193
180
{}
@@ -203,8 +190,25 @@ static int set_is_seen(struct ctl_table_set *set)
203
190
return & current -> nsproxy -> ipc_ns -> ipc_set == set ;
204
191
}
205
192
193
+ static int ipc_permissions (struct ctl_table_header * head , struct ctl_table * table )
194
+ {
195
+ int mode = table -> mode ;
196
+
197
+ #ifdef CONFIG_CHECKPOINT_RESTORE
198
+ struct ipc_namespace * ns = current -> nsproxy -> ipc_ns ;
199
+
200
+ if (((table -> data == & ns -> ids [IPC_SEM_IDS ].next_id ) ||
201
+ (table -> data == & ns -> ids [IPC_MSG_IDS ].next_id ) ||
202
+ (table -> data == & ns -> ids [IPC_SHM_IDS ].next_id )) &&
203
+ checkpoint_restore_ns_capable (ns -> user_ns ))
204
+ mode = 0666 ;
205
+ #endif
206
+ return mode ;
207
+ }
208
+
206
209
static struct ctl_table_root set_root = {
207
210
.lookup = set_lookup ,
211
+ .permissions = ipc_permissions ,
208
212
};
209
213
210
214
bool setup_ipc_sysctls (struct ipc_namespace * ns )
@@ -244,15 +248,12 @@ bool setup_ipc_sysctls(struct ipc_namespace *ns)
244
248
#ifdef CONFIG_CHECKPOINT_RESTORE
245
249
} else if (tbl [i ].data == & init_ipc_ns .ids [IPC_SEM_IDS ].next_id ) {
246
250
tbl [i ].data = & ns -> ids [IPC_SEM_IDS ].next_id ;
247
- tbl [i ].extra1 = ns ;
248
251
249
252
} else if (tbl [i ].data == & init_ipc_ns .ids [IPC_MSG_IDS ].next_id ) {
250
253
tbl [i ].data = & ns -> ids [IPC_MSG_IDS ].next_id ;
251
- tbl [i ].extra1 = ns ;
252
254
253
255
} else if (tbl [i ].data == & init_ipc_ns .ids [IPC_SHM_IDS ].next_id ) {
254
256
tbl [i ].data = & ns -> ids [IPC_SHM_IDS ].next_id ;
255
- tbl [i ].extra1 = ns ;
256
257
#endif
257
258
} else {
258
259
tbl [i ].data = NULL ;
0 commit comments