Skip to content

Commit 520da69

Browse files
yshuiMiklos Szeredi
authored andcommitted
ovl: initialize error in ovl_copy_xattr
In ovl_copy_xattr, if all the xattrs to be copied are overlayfs private xattrs, the copy loop will terminate without assigning anything to the error variable, thus returning an uninitialized value. If ovl_copy_xattr is called from ovl_clear_empty, this uninitialized error value is put into a pointer by ERR_PTR(), causing potential invalid memory accesses down the line. This commit initialize error with 0. This is the correct value because when there's no xattr to copy, because all xattrs are private, ovl_copy_xattr should succeed. This bug is discovered with the help of INIT_STACK_ALL and clang. Signed-off-by: Yuxuan Shui <[email protected]> Link: https://bugs.chromium.org/p/chromium/issues/detail?id=1050405 Fixes: 0956254 ("ovl: don't copy up opaqueness") Cc: [email protected] # v4.8 Signed-off-by: Alexander Potapenko <[email protected]> Signed-off-by: Miklos Szeredi <[email protected]>
1 parent 1434a65 commit 520da69

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

fs/overlayfs/copy_up.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ int ovl_copy_xattr(struct dentry *old, struct dentry *new)
4747
{
4848
ssize_t list_size, size, value_size = 0;
4949
char *buf, *name, *value = NULL;
50-
int uninitialized_var(error);
50+
int error = 0;
5151
size_t slen;
5252

5353
if (!(old->d_inode->i_opflags & IOP_XATTR) ||

0 commit comments

Comments
 (0)