提交 e56d1e3f 编写于 作者: T Trond Myklebust 提交者: Zheng Zengkai

NFS: Deal correctly with attribute generation counter overflow

stable inclusion
from stable-5.10.38
commit d21a5950cca69d5ac199f011752c90e171f6c5d1
bugzilla: 51875
CVE: NA

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

[ Upstream commit 9fdbfad1 ]

We need to use unsigned long subtraction and then convert to signed in
order to deal correcly with C overflow rules.

Fixes: f5062003 ("NFS: Set an attribute barrier on all updates")
Signed-off-by: NTrond Myklebust <trond.myklebust@hammerspace.com>
Signed-off-by: NSasha Levin <sashal@kernel.org>
Signed-off-by: NChen Jun <chenjun102@huawei.com>
Acked-by: NWeilong Chen <chenweilong@huawei.com>
Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
上级 347220c8
......@@ -1642,10 +1642,10 @@ EXPORT_SYMBOL_GPL(_nfs_display_fhandle);
*/
static int nfs_inode_attrs_need_update(const struct inode *inode, const struct nfs_fattr *fattr)
{
const struct nfs_inode *nfsi = NFS_I(inode);
unsigned long attr_gencount = NFS_I(inode)->attr_gencount;
return ((long)fattr->gencount - (long)nfsi->attr_gencount) > 0 ||
((long)nfsi->attr_gencount - (long)nfs_read_attr_generation_counter() > 0);
return (long)(fattr->gencount - attr_gencount) > 0 ||
(long)(attr_gencount - nfs_read_attr_generation_counter()) > 0;
}
static int nfs_refresh_inode_locked(struct inode *inode, struct nfs_fattr *fattr)
......@@ -2074,7 +2074,7 @@ static int nfs_update_inode(struct inode *inode, struct nfs_fattr *fattr)
nfsi->attrtimeo_timestamp = now;
}
/* Set the barrier to be more recent than this fattr */
if ((long)fattr->gencount - (long)nfsi->attr_gencount > 0)
if ((long)(fattr->gencount - nfsi->attr_gencount) > 0)
nfsi->attr_gencount = fattr->gencount;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册