Commit a3fbc9d4 authored by Amir Goldstein's avatar Amir Goldstein Committed by Zheng Zengkai
Browse files

shmem: allow reporting fanotify events with file handles on tmpfs

mainline inclusion
from mainline-5.13-rc1
commit 59cda49e
category: feature
bugzilla: 187162, https://gitee.com/openeuler/kernel/issues/I5FYKV
CVE: NA

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=59cda49ecf6c9a32fae4942420701b6e087204f6

-------------------------------------------------

Since kernel v5.1, fanotify_init(2) supports the flag FAN_REPORT_FID
for identifying objects using file handle and fsid in events.

fanotify_mark(2) fails with -ENODEV when trying to set a mark on
filesystems that report null f_fsid in stasfs(2).

Use the digest of uuid as f_fsid for tmpfs to uniquely identify tmpfs
objects as best as possible and allow setting an fanotify mark that
reports events with file handles on tmpfs.

Link: https://lore.kernel.org/r/20210322173944.449469-3-amir73il@gmail.com


Acked-by: default avatarHugh Dickins <hughd@google.com>
Reviewed-by: default avatarChristian Brauner <christian.brauner@ubuntu.com>
Signed-off-by: default avatarAmir Goldstein <amir73il@gmail.com>
Signed-off-by: default avatarJan Kara <jack@suse.cz>
Signed-off-by: default avatarBaokun Li <libaokun1@huawei.com>
Reviewed-by: default avatarchengzhihao <chengzhihao1@huawei.com>
Reviewed-by: default avatarZhang Yi <yi.zhang@huawei.com>
Signed-off-by: default avatarZheng Zengkai <zhengzengkai@huawei.com>
parent 3e854509
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -2869,6 +2869,9 @@ static int shmem_statfs(struct dentry *dentry, struct kstatfs *buf)
		buf->f_ffree = sbinfo->free_inodes;
	}
	/* else leave those fields 0 like simple_statfs */

	buf->f_fsid = uuid_to_fsid(dentry->d_sb->s_uuid.b);

	return 0;
}