summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYuxuan Shui <yshuiv7@gmail.com>2020-05-27 04:08:02 +0100
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2020-06-20 10:23:17 +0200
commit339b105933be6b2c4deb6fa56fa88e8da807863f (patch)
tree0fcd4b28cc8260f370aeeb911fac5cc148d593cb
parent1c6221b430a091fc1f62ea04b05a672e37ff7713 (diff)
ovl: initialize error in ovl_copy_xattr
commit 520da69d265a91c6536c63851cbb8a53946974f0 upstream. 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 <yshuiv7@gmail.com> Link: https://bugs.chromium.org/p/chromium/issues/detail?id=1050405 Fixes: 0956254a2d5b ("ovl: don't copy up opaqueness") Cc: stable@vger.kernel.org # v4.8 Signed-off-by: Alexander Potapenko <glider@google.com> Signed-off-by: Miklos Szeredi <mszeredi@redhat.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--fs/overlayfs/copy_up.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/fs/overlayfs/copy_up.c b/fs/overlayfs/copy_up.c
index 64c5386d0c1b..3972ac87a8cb 100644
--- a/fs/overlayfs/copy_up.c
+++ b/fs/overlayfs/copy_up.c
@@ -24,7 +24,7 @@ int ovl_copy_xattr(struct dentry *old, struct dentry *new)
{
ssize_t list_size, size, value_size = 0;
char *buf, *name, *value = NULL;
- int uninitialized_var(error);
+ int error = 0;
size_t slen;
if (!old->d_inode->i_op->getxattr ||