From: Gao Xiang <gaoxiang25@huawei.com>
To: Chao Yu <yuchao0@huawei.com>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
<devel@driverdev.osuosl.org>, <linux-fsdevel@vger.kernel.org>
Cc: LKML <linux-kernel@vger.kernel.org>,
<linux-erofs@lists.ozlabs.org>, "Chao Yu" <chao@kernel.org>,
Miao Xie <miaoxie@huawei.com>, <weidu.du@huawei.com>,
Fang Wei <fangwei1@huawei.com>, Gao Xiang <gaoxiang25@huawei.com>
Subject: [PATCH 3/3] staging: erofs: xattr.c: avoid BUG_ON
Date: Tue, 13 Aug 2019 10:30:54 +0800 [thread overview]
Message-ID: <20190813023054.73126-3-gaoxiang25@huawei.com> (raw)
In-Reply-To: <20190813023054.73126-1-gaoxiang25@huawei.com>
Kill all the remaining BUG_ON in EROFS:
- one BUG_ON was used to detect xattr on-disk corruption,
proper error handling should be added for it instead;
- the other BUG_ONs are used to detect potential issues,
use DBG_BUGON only in (eng) debugging version.
Signed-off-by: Gao Xiang <gaoxiang25@huawei.com>
---
drivers/staging/erofs/xattr.c | 14 +++++++++-----
1 file changed, 9 insertions(+), 5 deletions(-)
diff --git a/drivers/staging/erofs/xattr.c b/drivers/staging/erofs/xattr.c
index b29177a17347..289c7850ec96 100644
--- a/drivers/staging/erofs/xattr.c
+++ b/drivers/staging/erofs/xattr.c
@@ -115,7 +115,7 @@ static int init_inode_xattrs(struct inode *inode)
for (i = 0; i < vi->xattr_shared_count; ++i) {
if (unlikely(it.ofs >= EROFS_BLKSIZ)) {
/* cannot be unaligned */
- BUG_ON(it.ofs != EROFS_BLKSIZ);
+ DBG_BUGON(it.ofs != EROFS_BLKSIZ);
xattr_iter_end(&it, atomic_map);
it.page = erofs_get_meta_page(sb, ++it.blkaddr,
@@ -191,7 +191,7 @@ static int inline_xattr_iter_begin(struct xattr_iter *it,
xattr_header_sz = inlinexattr_header_size(inode);
if (unlikely(xattr_header_sz >= vi->xattr_isize)) {
- BUG_ON(xattr_header_sz > vi->xattr_isize);
+ DBG_BUGON(xattr_header_sz > vi->xattr_isize);
return -ENOATTR;
}
@@ -234,7 +234,11 @@ static int xattr_foreach(struct xattr_iter *it,
if (tlimit) {
unsigned int entry_sz = EROFS_XATTR_ENTRY_SIZE(&entry);
- BUG_ON(*tlimit < entry_sz);
+ /* xattr on-disk corruption: xattr entry beyond xattr_isize */
+ if (unlikely(*tlimit < entry_sz)) {
+ DBG_BUGON(1);
+ return -EIO;
+ }
*tlimit -= entry_sz;
}
@@ -253,7 +257,7 @@ static int xattr_foreach(struct xattr_iter *it,
while (processed < entry.e_name_len) {
if (it->ofs >= EROFS_BLKSIZ) {
- BUG_ON(it->ofs > EROFS_BLKSIZ);
+ DBG_BUGON(it->ofs > EROFS_BLKSIZ);
err = xattr_iter_fixup(it);
if (err)
@@ -288,7 +292,7 @@ static int xattr_foreach(struct xattr_iter *it,
while (processed < value_sz) {
if (it->ofs >= EROFS_BLKSIZ) {
- BUG_ON(it->ofs > EROFS_BLKSIZ);
+ DBG_BUGON(it->ofs > EROFS_BLKSIZ);
err = xattr_iter_fixup(it);
if (err)
--
2.17.1
next prev parent reply other threads:[~2019-08-13 2:31 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-08-13 2:30 [PATCH 1/3] staging: erofs: inline erofs_inode_is_data_compressed() Gao Xiang
2019-08-13 2:30 ` [PATCH 2/3] staging: erofs: remove incomplete cleancache Gao Xiang
2019-08-13 3:09 ` Chao Yu
2019-08-13 2:30 ` Gao Xiang [this message]
2019-08-13 3:20 ` [PATCH 3/3] staging: erofs: xattr.c: avoid BUG_ON Chao Yu
2019-08-13 3:57 ` Gao Xiang
2019-08-13 6:10 ` Chao Yu
2019-08-13 3:08 ` [PATCH 1/3] staging: erofs: inline erofs_inode_is_data_compressed() Chao Yu
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=20190813023054.73126-3-gaoxiang25@huawei.com \
--to=gaoxiang25@huawei.com \
--cc=chao@kernel.org \
--cc=devel@driverdev.osuosl.org \
--cc=fangwei1@huawei.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-erofs@lists.ozlabs.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=miaoxie@huawei.com \
--cc=weidu.du@huawei.com \
--cc=yuchao0@huawei.com \
/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;
as well as URLs for NNTP newsgroup(s).