Skip to content

Commit 380cb5d

Browse files
committed
Merge tag 'fsnotify_for_v6.18-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/jack/linux-fs
Pull fsnotify fixes from Jan Kara: - Stop-gap solution for a race between unmount of a filesystem with fsnotify marks and someone inspecting fdinfo of fsnotify group with those marks in procfs. A proper solution is in the works but it will get a while to settle. - Fix for non-decodable file handles (used by unprivileged apps using fanotify) * tag 'fsnotify_for_v6.18-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/jack/linux-fs: fs/notify: call exportfs_encode_fid with s_umount expfs: Fix exportfs_can_encode_fh() for EXPORT_FH_FID
2 parents 211ddde + a7c4bb4 commit 380cb5d

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

fs/notify/fdinfo.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#include "fanotify/fanotify.h"
1818
#include "fdinfo.h"
1919
#include "fsnotify.h"
20+
#include "../internal.h"
2021

2122
#if defined(CONFIG_PROC_FS)
2223

@@ -46,7 +47,12 @@ static void show_mark_fhandle(struct seq_file *m, struct inode *inode)
4647

4748
size = f->handle_bytes >> 2;
4849

50+
if (!super_trylock_shared(inode->i_sb))
51+
return;
52+
4953
ret = exportfs_encode_fid(inode, (struct fid *)f->f_handle, &size);
54+
up_read(&inode->i_sb->s_umount);
55+
5056
if ((ret == FILEID_INVALID) || (ret < 0))
5157
return;
5258

include/linux/exportfs.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -320,16 +320,17 @@ static inline bool exportfs_can_decode_fh(const struct export_operations *nop)
320320
static inline bool exportfs_can_encode_fh(const struct export_operations *nop,
321321
int fh_flags)
322322
{
323-
if (!nop)
324-
return false;
325-
326323
/*
327324
* If a non-decodeable file handle was requested, we only need to make
328325
* sure that filesystem did not opt-out of encoding fid.
329326
*/
330327
if (fh_flags & EXPORT_FH_FID)
331328
return exportfs_can_encode_fid(nop);
332329

330+
/* Normal file handles cannot be created without export ops */
331+
if (!nop)
332+
return false;
333+
333334
/*
334335
* If a connectable file handle was requested, we need to make sure that
335336
* filesystem can also decode connected file handles.

0 commit comments

Comments
 (0)