* [PATCH 4.4-stable] jffs2: return -ERANGE when xattr buffer is too small
@ 2018-10-05 7:13 Hou Tao
2018-10-11 14:01 ` gregkh@linuxfoundation.org >> Greg Kroah-Hartman
0 siblings, 1 reply; 2+ messages in thread
From: Hou Tao @ 2018-10-05 7:13 UTC (permalink / raw)
To: gregkh@linuxfoundation.org >> Greg Kroah-Hartman,
Andreas Gruenbacher
Cc: David Woodhouse, linux-mtd, stable, houtao1@huawei.com
Hi Greg,
The problem had been fixed by 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. Which one is your preference ?
Hi Andreas,
Could you please help review the patch ?
Thanks,
Tao
---
From: Hou Tao <houtao1@huawei.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 occurs
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.
Signed-off-by: Hou Tao <houtao1@huawei.com>
---
fs/jffs2/xattr.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/fs/jffs2/xattr.c b/fs/jffs2/xattr.c
index 4c2c03663533..8e1427762eeb 100644
--- a/fs/jffs2/xattr.c
+++ b/fs/jffs2/xattr.c
@@ -1004,12 +1004,14 @@ ssize_t jffs2_listxattr(struct dentry *dentry, char *buffer, size_t size)
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;
--
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH 4.4-stable] jffs2: return -ERANGE when xattr buffer is too small
2018-10-05 7:13 [PATCH 4.4-stable] jffs2: return -ERANGE when xattr buffer is too small Hou Tao
@ 2018-10-11 14:01 ` gregkh@linuxfoundation.org >> Greg Kroah-Hartman
0 siblings, 0 replies; 2+ messages in thread
From: gregkh@linuxfoundation.org >> Greg Kroah-Hartman @ 2018-10-11 14:01 UTC (permalink / raw)
To: Hou Tao; +Cc: Andreas Gruenbacher, David Woodhouse, linux-mtd, stable
On Fri, Oct 05, 2018 at 03:13:20PM +0800, Hou Tao wrote:
> Hi Greg,
>
> The problem had been fixed by 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. Which one is your preference ?
This single patch is good. But the tabs are all converted to spaces and
this does not apply :(
Please fix up and resend.
thanks,
greg k-h
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2018-10-11 21:29 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-10-05 7:13 [PATCH 4.4-stable] jffs2: return -ERANGE when xattr buffer is too small Hou Tao
2018-10-11 14:01 ` gregkh@linuxfoundation.org >> Greg Kroah-Hartman
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).