[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20181018175428.883959029@linuxfoundation.org>
Date: Thu, 18 Oct 2018 19:54:51 +0200
From: Greg Kroah-Hartman <gregkh@...uxfoundation.org>
To: linux-kernel@...r.kernel.org
Cc: Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
stable@...r.kernel.org, Hou Tao <houtao1@...wei.com>,
David Woodhouse <dwmw2@...radead.org>
Subject: [PATCH 4.4 16/48] jffs2: return -ERANGE when xattr buffer is too small
4.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hou Tao <houtao1@...wei.com>
When a file have multiple xattrs and the passed buffer is
smaller than the required size, jffs2_listxattr() should
return -ERANGE instead of continue, else Oops may occur
due to memory corruption.
Also remove the unnecessary check ("rc < 0"), because
xhandle->list(...) will not return an error number.
Spotted by generic/377 in xfstests-dev.
NB: The problem had been fixed by commit 764a5c6b1fa4 ("xattr
handlers: Simplify list operation") in v4.5-rc1, but the
modification in that commit may be too much because it modifies
all file-systems which implement xattr, so I create a single
patch for jffs2 to fix the problem.
Signed-off-by: Hou Tao <houtao1@...wei.com>
Cc: David Woodhouse <dwmw2@...radead.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@...uxfoundation.org>
---
fs/jffs2/xattr.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
--- a/fs/jffs2/xattr.c
+++ b/fs/jffs2/xattr.c
@@ -1004,12 +1004,14 @@ ssize_t jffs2_listxattr(struct dentry *d
rc = xhandle->list(xhandle, dentry, buffer + len,
size - len, xd->xname,
xd->name_len);
+ if (rc > size - len) {
+ rc = -ERANGE;
+ goto out;
+ }
} else {
rc = xhandle->list(xhandle, dentry, NULL, 0,
xd->xname, xd->name_len);
}
- if (rc < 0)
- goto out;
len += rc;
}
rc = len;
Powered by blists - more mailing lists