File tree Expand file tree Collapse file tree 1 file changed +31
-1
lines changed Expand file tree Collapse file tree 1 file changed +31
-1
lines changed Original file line number Diff line number Diff line change @@ -152,19 +152,49 @@ static int copy_ns_info_to_user(const struct mnt_namespace *mnt_ns,
152
152
return 0 ;
153
153
}
154
154
155
+ static bool nsfs_ioctl_valid (unsigned int cmd )
156
+ {
157
+ switch (cmd ) {
158
+ case NS_GET_USERNS :
159
+ case NS_GET_PARENT :
160
+ case NS_GET_NSTYPE :
161
+ case NS_GET_OWNER_UID :
162
+ case NS_GET_MNTNS_ID :
163
+ case NS_GET_PID_FROM_PIDNS :
164
+ case NS_GET_TGID_FROM_PIDNS :
165
+ case NS_GET_PID_IN_PIDNS :
166
+ case NS_GET_TGID_IN_PIDNS :
167
+ return (_IOC_TYPE (cmd ) == _IOC_TYPE (cmd ));
168
+ }
169
+
170
+ /* Extensible ioctls require some extra handling. */
171
+ switch (_IOC_NR (cmd )) {
172
+ case _IOC_NR (NS_MNT_GET_INFO ):
173
+ case _IOC_NR (NS_MNT_GET_NEXT ):
174
+ case _IOC_NR (NS_MNT_GET_PREV ):
175
+ return (_IOC_TYPE (cmd ) == _IOC_TYPE (cmd ));
176
+ }
177
+
178
+ return false;
179
+ }
180
+
155
181
static long ns_ioctl (struct file * filp , unsigned int ioctl ,
156
182
unsigned long arg )
157
183
{
158
184
struct user_namespace * user_ns ;
159
185
struct pid_namespace * pid_ns ;
160
186
struct task_struct * tsk ;
161
- struct ns_common * ns = get_proc_ns ( file_inode ( filp )) ;
187
+ struct ns_common * ns ;
162
188
struct mnt_namespace * mnt_ns ;
163
189
bool previous = false;
164
190
uid_t __user * argp ;
165
191
uid_t uid ;
166
192
int ret ;
167
193
194
+ if (!nsfs_ioctl_valid (ioctl ))
195
+ return - ENOIOCTLCMD ;
196
+
197
+ ns = get_proc_ns (file_inode (filp ));
168
198
switch (ioctl ) {
169
199
case NS_GET_USERNS :
170
200
return open_related_ns (ns , ns_get_owner );
You can’t perform that action at this time.
0 commit comments