Skip to content

Commit 5402c4d

Browse files
amir73ilbrauner
authored andcommitted
exportfs: require ->fh_to_parent() to encode connectable file handles
When user requests a connectable file handle explicitly with the AT_HANDLE_CONNECTABLE flag, fail the request if filesystem (e.g. nfs) does not know how to decode a connected non-dir dentry. Fixes: c374196 ("fs: name_to_handle_at() support for "explicit connectable" file handles") Signed-off-by: Amir Goldstein <[email protected]> Link: https://lore.kernel.org/[email protected] Reviewed-by: Jan Kara <[email protected]> Signed-off-by: Christian Brauner <[email protected]>
1 parent 21fae34 commit 5402c4d

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

include/linux/exportfs.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -314,13 +314,23 @@ static inline bool exportfs_can_decode_fh(const struct export_operations *nop)
314314
static inline bool exportfs_can_encode_fh(const struct export_operations *nop,
315315
int fh_flags)
316316
{
317+
if (!nop)
318+
return false;
319+
317320
/*
318321
* If a non-decodeable file handle was requested, we only need to make
319322
* sure that filesystem did not opt-out of encoding fid.
320323
*/
321324
if (fh_flags & EXPORT_FH_FID)
322325
return exportfs_can_encode_fid(nop);
323326

327+
/*
328+
* If a connectable file handle was requested, we need to make sure that
329+
* filesystem can also decode connected file handles.
330+
*/
331+
if ((fh_flags & EXPORT_FH_CONNECTABLE) && !nop->fh_to_parent)
332+
return false;
333+
324334
/*
325335
* If a decodeable file handle was requested, we need to make sure that
326336
* filesystem can also decode file handles.

0 commit comments

Comments
 (0)