Merge tag 'fsnotify_for_v5.3-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/jack/linux-fs
Pull fsnotify updates from Jan Kara: "This contains cleanups of the fsnotify name removal hook and also a patch to disable fanotify permission events for 'proc' filesystem" * tag 'fsnotify_for_v5.3-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/jack/linux-fs: fsnotify: get rid of fsnotify_nameremove() fsnotify: move fsnotify_nameremove() hook out of d_delete() configfs: call fsnotify_rmdir() hook debugfs: call fsnotify_{unlink,rmdir}() hooks debugfs: simplify __debugfs_remove_file() devpts: call fsnotify_unlink() hook tracefs: call fsnotify_{unlink,rmdir}() hooks rpc_pipefs: call fsnotify_{unlink,rmdir}() hooks btrfs: call fsnotify_rmdir() hook fsnotify: add empty fsnotify_{unlink,rmdir}() hooks fanotify: Disallow permission events for proc filesystem
このコミットが含まれているのは:
@@ -920,6 +920,22 @@ static int fanotify_test_fid(struct path *path, __kernel_fsid_t *fsid)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int fanotify_events_supported(struct path *path, __u64 mask)
|
||||
{
|
||||
/*
|
||||
* Some filesystems such as 'proc' acquire unusual locks when opening
|
||||
* files. For them fanotify permission events have high chances of
|
||||
* deadlocking the system - open done when reporting fanotify event
|
||||
* blocks on this "unusual" lock while another process holding the lock
|
||||
* waits for fanotify permission event to be answered. Just disallow
|
||||
* permission events for such filesystems.
|
||||
*/
|
||||
if (mask & FANOTIFY_PERM_EVENTS &&
|
||||
path->mnt->mnt_sb->s_type->fs_flags & FS_DISALLOW_NOTIFY_PERM)
|
||||
return -EINVAL;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int do_fanotify_mark(int fanotify_fd, unsigned int flags, __u64 mask,
|
||||
int dfd, const char __user *pathname)
|
||||
{
|
||||
@@ -1018,6 +1034,12 @@ static int do_fanotify_mark(int fanotify_fd, unsigned int flags, __u64 mask,
|
||||
if (ret)
|
||||
goto fput_and_out;
|
||||
|
||||
if (flags & FAN_MARK_ADD) {
|
||||
ret = fanotify_events_supported(&path, mask);
|
||||
if (ret)
|
||||
goto path_put_and_out;
|
||||
}
|
||||
|
||||
if (FAN_GROUP_FLAG(group, FAN_REPORT_FID)) {
|
||||
ret = fanotify_test_fid(&path, &__fsid);
|
||||
if (ret)
|
||||
|
@@ -94,47 +94,6 @@ void fsnotify_sb_delete(struct super_block *sb)
|
||||
fsnotify_clear_marks_by_sb(sb);
|
||||
}
|
||||
|
||||
/*
|
||||
* fsnotify_nameremove - a filename was removed from a directory
|
||||
*
|
||||
* This is mostly called under parent vfs inode lock so name and
|
||||
* dentry->d_parent should be stable. However there are some corner cases where
|
||||
* inode lock is not held. So to be on the safe side and be reselient to future
|
||||
* callers and out of tree users of d_delete(), we do not assume that d_parent
|
||||
* and d_name are stable and we use dget_parent() and
|
||||
* take_dentry_name_snapshot() to grab stable references.
|
||||
*/
|
||||
void fsnotify_nameremove(struct dentry *dentry, int isdir)
|
||||
{
|
||||
struct dentry *parent;
|
||||
struct name_snapshot name;
|
||||
__u32 mask = FS_DELETE;
|
||||
|
||||
/* d_delete() of pseudo inode? (e.g. __ns_get_path() playing tricks) */
|
||||
if (IS_ROOT(dentry))
|
||||
return;
|
||||
|
||||
if (isdir)
|
||||
mask |= FS_ISDIR;
|
||||
|
||||
parent = dget_parent(dentry);
|
||||
/* Avoid unneeded take_dentry_name_snapshot() */
|
||||
if (!(d_inode(parent)->i_fsnotify_mask & FS_DELETE) &&
|
||||
!(dentry->d_sb->s_fsnotify_mask & FS_DELETE))
|
||||
goto out_dput;
|
||||
|
||||
take_dentry_name_snapshot(&name, dentry);
|
||||
|
||||
fsnotify(d_inode(parent), mask, d_inode(dentry), FSNOTIFY_EVENT_INODE,
|
||||
&name.name, 0);
|
||||
|
||||
release_dentry_name_snapshot(&name);
|
||||
|
||||
out_dput:
|
||||
dput(parent);
|
||||
}
|
||||
EXPORT_SYMBOL(fsnotify_nameremove);
|
||||
|
||||
/*
|
||||
* Given an inode, first check if we care what happens to our children. Inotify
|
||||
* and dnotify both tell their parents about events. If we care about any event
|
||||
|
新しいイシューから参照
ユーザーをブロックする