Commit a7a8ac2a authored by Miklos Szeredi's avatar Miklos Szeredi Committed by Kleber Sacilotto de Souza

fuse: verify nlink

BugLink: https://bugs.launchpad.net/bugs/1858489

commit c634da71 upstream.

When adding a new hard link, make sure that i_nlink doesn't overflow.

Fixes: ac45d613 ("fuse: fix nlink after unlink")
Cc: <stable@vger.kernel.org> # v3.4
Signed-off-by: default avatarMiklos Szeredi <mszeredi@redhat.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: default avatarConnor Kuehl <connor.kuehl@canonical.com>
Signed-off-by: default avatarKleber Sacilotto de Souza <kleber.souza@canonical.com>
parent 82753f89
...@@ -814,7 +814,8 @@ static int fuse_link(struct dentry *entry, struct inode *newdir, ...@@ -814,7 +814,8 @@ static int fuse_link(struct dentry *entry, struct inode *newdir,
spin_lock(&fc->lock); spin_lock(&fc->lock);
fi->attr_version = ++fc->attr_version; fi->attr_version = ++fc->attr_version;
inc_nlink(inode); if (likely(inode->i_nlink < UINT_MAX))
inc_nlink(inode);
spin_unlock(&fc->lock); spin_unlock(&fc->lock);
fuse_invalidate_attr(inode); fuse_invalidate_attr(inode);
fuse_update_ctime(inode); fuse_update_ctime(inode);
......
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