@@ -279,28 +279,32 @@ static int do_handle_to_path(struct file_handle *handle, struct path *path,
279
279
return 0 ;
280
280
}
281
281
282
- /*
283
- * Allow relaxed permissions of file handles if the caller has the
284
- * ability to mount the filesystem or create a bind-mount of the
285
- * provided @mountdirfd.
286
- *
287
- * In both cases the caller may be able to get an unobstructed way to
288
- * the encoded file handle. If the caller is only able to create a
289
- * bind-mount we need to verify that there are no locked mounts on top
290
- * of it that could prevent us from getting to the encoded file.
291
- *
292
- * In principle, locked mounts can prevent the caller from mounting the
293
- * filesystem but that only applies to procfs and sysfs neither of which
294
- * support decoding file handles.
295
- */
296
282
static inline bool may_decode_fh (struct handle_to_path_ctx * ctx ,
297
283
unsigned int o_flags )
298
284
{
299
285
struct path * root = & ctx -> root ;
300
286
287
+ if (capable (CAP_DAC_READ_SEARCH ))
288
+ return true;
289
+
301
290
/*
302
- * Restrict to O_DIRECTORY to provide a deterministic API that avoids a
303
- * confusing api in the face of disconnected non-dir dentries.
291
+ * Allow relaxed permissions of file handles if the caller has
292
+ * the ability to mount the filesystem or create a bind-mount of
293
+ * the provided @mountdirfd.
294
+ *
295
+ * In both cases the caller may be able to get an unobstructed
296
+ * way to the encoded file handle. If the caller is only able to
297
+ * create a bind-mount we need to verify that there are no
298
+ * locked mounts on top of it that could prevent us from getting
299
+ * to the encoded file.
300
+ *
301
+ * In principle, locked mounts can prevent the caller from
302
+ * mounting the filesystem but that only applies to procfs and
303
+ * sysfs neither of which support decoding file handles.
304
+ *
305
+ * Restrict to O_DIRECTORY to provide a deterministic API that
306
+ * avoids a confusing api in the face of disconnected non-dir
307
+ * dentries.
304
308
*
305
309
* There's only one dentry for each directory inode (VFS rule)...
306
310
*/
@@ -337,7 +341,7 @@ static int handle_to_path(int mountdirfd, struct file_handle __user *ufh,
337
341
if (retval )
338
342
goto out_err ;
339
343
340
- if (!capable ( CAP_DAC_READ_SEARCH ) && ! may_decode_fh (& ctx , o_flags )) {
344
+ if (!may_decode_fh (& ctx , o_flags )) {
341
345
retval = - EPERM ;
342
346
goto out_path ;
343
347
}
0 commit comments