提交 3e37dc12 编写于 作者: T Trond Myklebust 提交者: Yang Yingliang

NFS: finish_automount() requires us to hold 2 refs to the mount record

mainline inclusion
from mainline-v5.7-rc1
commit 75da9858
category: bugfix
bugzilla: NA
CVE: NA

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

We must not return from nfs_d_automount() without holding 2 references
to the mount record. Doing so, will trigger the BUG() in finish_automount().
Also ensure that we don't try to reschedule the automount timer with
a negative or zero timeout value.

Fixes: 22a1ae9a ("NFS: If nfs_mountpoint_expiry_timeout < 0, do not expire submounts")
Cc: stable@vger.kernel.org # v5.5+
Signed-off-by: NTrond Myklebust <trond.myklebust@hammerspace.com>

Conflicts:
	fs/nfs/namespace.c
Signed-off-by: NZhang Xiaoxu <zhangxiaoxu5@huawei.com>
Reviewed-by: NZhang Yi <yi.zhang@huawei.com>
Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
上级 89095d99
...@@ -146,6 +146,7 @@ struct vfsmount *nfs_d_automount(struct path *path) ...@@ -146,6 +146,7 @@ struct vfsmount *nfs_d_automount(struct path *path)
struct nfs_server *server = NFS_SERVER(d_inode(path->dentry)); struct nfs_server *server = NFS_SERVER(d_inode(path->dentry));
struct nfs_fh *fh = NULL; struct nfs_fh *fh = NULL;
struct nfs_fattr *fattr = NULL; struct nfs_fattr *fattr = NULL;
int timeout = READ_ONCE(nfs_mountpoint_expiry_timeout);
if (IS_ROOT(path->dentry)) if (IS_ROOT(path->dentry))
return ERR_PTR(-ESTALE); return ERR_PTR(-ESTALE);
...@@ -160,12 +161,12 @@ struct vfsmount *nfs_d_automount(struct path *path) ...@@ -160,12 +161,12 @@ struct vfsmount *nfs_d_automount(struct path *path)
if (IS_ERR(mnt)) if (IS_ERR(mnt))
goto out; goto out;
if (nfs_mountpoint_expiry_timeout < 0) mntget(mnt); /* prevent immediate expiration */
if (timeout <= 0)
goto out; goto out;
mntget(mnt); /* prevent immediate expiration */
mnt_set_expiry(mnt, &nfs_automount_list); mnt_set_expiry(mnt, &nfs_automount_list);
schedule_delayed_work(&nfs_automount_task, nfs_mountpoint_expiry_timeout); schedule_delayed_work(&nfs_automount_task, timeout);
out: out:
nfs_free_fattr(fattr); nfs_free_fattr(fattr);
...@@ -204,10 +205,11 @@ const struct inode_operations nfs_referral_inode_operations = { ...@@ -204,10 +205,11 @@ const struct inode_operations nfs_referral_inode_operations = {
static void nfs_expire_automounts(struct work_struct *work) static void nfs_expire_automounts(struct work_struct *work)
{ {
struct list_head *list = &nfs_automount_list; struct list_head *list = &nfs_automount_list;
int timeout = READ_ONCE(nfs_mountpoint_expiry_timeout);
mark_mounts_for_expiry(list); mark_mounts_for_expiry(list);
if (!list_empty(list)) if (!list_empty(list) && timeout > 0)
schedule_delayed_work(&nfs_automount_task, nfs_mountpoint_expiry_timeout); schedule_delayed_work(&nfs_automount_task, timeout);
} }
void nfs_release_automount_timer(void) void nfs_release_automount_timer(void)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册