提交 0e6d4edf 编写于 作者: D David Howells 提交者: Yang Yingliang

afs: Fix the afs.cell and afs.volume xattr handlers

[ Upstream commit c73aa4102f5b9f261a907c3b3df94cd2c478504d ]

Fix the ->get handlers for the afs.cell and afs.volume xattrs to pass the
source data size to memcpy() rather than target buffer size.

Overcopying the source data occasionally causes the kernel to oops.

Fixes: d3e3b7ea ("afs: Add metadata xattrs")
Signed-off-by: NDavid Howells <dhowells@redhat.com>
Signed-off-by: NSasha Levin <sashal@kernel.org>
Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
上级 e8e4f88c
...@@ -50,7 +50,7 @@ static int afs_xattr_get_cell(const struct xattr_handler *handler, ...@@ -50,7 +50,7 @@ static int afs_xattr_get_cell(const struct xattr_handler *handler,
return namelen; return namelen;
if (namelen > size) if (namelen > size)
return -ERANGE; return -ERANGE;
memcpy(buffer, cell->name, size); memcpy(buffer, cell->name, namelen);
return namelen; return namelen;
} }
...@@ -104,7 +104,7 @@ static int afs_xattr_get_volume(const struct xattr_handler *handler, ...@@ -104,7 +104,7 @@ static int afs_xattr_get_volume(const struct xattr_handler *handler,
return namelen; return namelen;
if (namelen > size) if (namelen > size)
return -ERANGE; return -ERANGE;
memcpy(buffer, volname, size); memcpy(buffer, volname, namelen);
return namelen; return namelen;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册