From: Jingbo Xu <jefflexu@linux.alibaba.com>
To: Gao Xiang <hsiangkao@linux.alibaba.com>,
xiang@kernel.org, chao@kernel.org, huyue2@coolpad.com,
linux-erofs@lists.ozlabs.org
Cc: linux-kernel@vger.kernel.org
Subject: Re: [PATCH v4 4/5] erofs: unify inline/share xattr iterators for listxattr/getxattr
Date: Wed, 31 May 2023 16:16:43 +0800 [thread overview]
Message-ID: <d86cdf32-bc4d-bbab-d756-baef2b12cace@linux.alibaba.com> (raw)
In-Reply-To: <349a1523-6d1c-9e96-d948-78dd4f2a209d@linux.alibaba.com>
On 5/31/23 2:57 PM, Gao Xiang wrote:
>
>
> On 2023/5/31 11:13, Jingbo Xu wrote:
>> -static int inline_xattr_iter_begin(struct erofs_xattr_iter *it,
>> - struct inode *inode)
>> -{
>> - struct erofs_inode *const vi = EROFS_I(inode);
>> - unsigned int xattr_header_sz, inline_xattr_ofs;
>> -
>> - xattr_header_sz = sizeof(struct erofs_xattr_ibody_header) +
>> - sizeof(u32) * vi->xattr_shared_count;
>> - if (xattr_header_sz >= vi->xattr_isize) {
>> - DBG_BUGON(xattr_header_sz > vi->xattr_isize);
>> - return -ENOATTR;
>> - }
In the original implementation, here when xattr_header_sz >=
vi->xattr_isize, inline_xattr_iter_begin() will return -ENOATTR rather
than a negative integer (i.e. vi->xattr_isize - xattr_header_sz).
>> static int erofs_xattr_generic_get(const struct xattr_handler *handler,
>> struct dentry *unused, struct inode *inode,
>> const char *name, void *buffer, size_t size)
>> @@ -542,45 +432,98 @@ static const struct xattr_iter_handlers
>> list_xattr_handlers = {
>> .value = NULL
>> };
>> -static int inline_listxattr(struct erofs_xattr_iter *it)
>> +static int erofs_iter_inline_xattr(struct erofs_xattr_iter *it,
>> + struct inode *inode, bool getxattr)
>> {
>> + struct erofs_inode *const vi = EROFS_I(inode);
>> + const struct xattr_iter_handlers *op;
>> + unsigned int xattr_header_sz, remaining;
>> + erofs_off_t pos;
>> int ret;
>> - unsigned int remaining;
>> - ret = inline_xattr_iter_begin(it, d_inode(it->dentry));
>
> In the past, "ret" here is "an int", and
> vi->xattr_isize - xattr_header_sz < 0 will return
> negative value (although I think that value is problematic).
>
> see below.
See comment above.
>
>
>> - if (ret < 0)
>> - return ret;
>> + xattr_header_sz = sizeof(struct erofs_xattr_ibody_header) +
>> + sizeof(u32) * vi->xattr_shared_count;
>> + if (xattr_header_sz >= vi->xattr_isize) {
>> + DBG_BUGON(xattr_header_sz > vi->xattr_isize);
>> + return -ENOATTR;
>> + }
This checking for "xattr_header_sz >= vi->xattr_isize" is also included
in this patch.
--
Thanks,
Jingbo
next prev parent reply other threads:[~2023-05-31 8:16 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-31 3:13 [PATCH v4 0/5] erofs: cleanup of xattr handling Jingbo Xu
2023-05-31 3:13 ` [PATCH v4 1/5] erofs: enhance erofs_xattr_iter_fixup() helper Jingbo Xu
2023-05-31 4:27 ` Gao Xiang
2023-05-31 3:13 ` [PATCH v4 2/5] erofs: unify xattr_iter structures Jingbo Xu
2023-05-31 6:53 ` Gao Xiang
2023-05-31 8:37 ` Jingbo Xu
2023-05-31 3:13 ` [PATCH v4 3/5] erofs: make the size of read data stored in buffer_ofs Jingbo Xu
2023-05-31 3:13 ` [PATCH v4 4/5] erofs: unify inline/share xattr iterators for listxattr/getxattr Jingbo Xu
2023-05-31 6:57 ` Gao Xiang
2023-05-31 8:16 ` Jingbo Xu [this message]
2023-05-31 8:31 ` Gao Xiang
2023-05-31 3:13 ` [PATCH v4 5/5] erofs: use separate xattr parsers " Jingbo Xu
2023-05-31 7:18 ` Gao Xiang
2023-05-31 8:31 ` Jingbo Xu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=d86cdf32-bc4d-bbab-d756-baef2b12cace@linux.alibaba.com \
--to=jefflexu@linux.alibaba.com \
--cc=chao@kernel.org \
--cc=hsiangkao@linux.alibaba.com \
--cc=huyue2@coolpad.com \
--cc=linux-erofs@lists.ozlabs.org \
--cc=linux-kernel@vger.kernel.org \
--cc=xiang@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox