Commit 6e3028fa authored by Andrew Vagin's avatar Andrew Vagin Committed by Pavel Emelyanov

fsnotify: open mount point relative to a proper root

Each mountpoint belongs to a mount namespace, so we need to
find a root of the mount namespace and open mountpoint
ralative to this root.

The same logic is used in get_mark_path().
Signed-off-by: 's avatarAndrew Vagin <avagin@openvz.org>
Signed-off-by: 's avatarAndrey Vagin <avagin@openvz.org>
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent dd63975b
......@@ -456,6 +456,7 @@ static int restore_one_fanotify(int fd, struct fsnotify_mark_info *mark)
if (fme->type == MARK_TYPE__MOUNT) {
struct mount_info *m;
int mntns_root;
m = lookup_mnt_id(fme->me->mnt_id);
if (!m) {
......@@ -463,8 +464,17 @@ static int restore_one_fanotify(int fd, struct fsnotify_mark_info *mark)
return -1;
}
mntns_root = mntns_get_root_fd(m->nsid);
target = openat(mntns_root, m->mountpoint, O_PATH);
if (target == -1) {
pr_perror("Unable to open %s\n", m->mountpoint);
goto err;
}
flags |= FAN_MARK_MOUNT;
path = m->mountpoint;
snprintf(buf, sizeof(buf), "/proc/self/fd/%d", target);
path = buf;
} else if (fme->type == MARK_TYPE__INODE) {
path = get_mark_path("fanotify", mark->remap,
fme->ie->f_handle, fme->ie->i_ino,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment