2021-09-22 09:54:05

by Gao Xiang

[permalink] [raw]
Subject: [PATCH] erofs: fix misbehavior of unsupported chunk format check

Unsupported chunk format should be checked with
"if (vi->chunkformat & ~EROFS_CHUNK_FORMAT_ALL)"

Found when checking with 4k-byte blockmap (although currently mkfs
uses inode chunk indexes format by default.)

Fixes: c5aa903a59db ("erofs: support reading chunk-based uncompressed files")
Cc: Liu Bo <[email protected]>
Cc: Chao Yu <[email protected]>
Signed-off-by: Gao Xiang <[email protected]>
---
fs/erofs/inode.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/erofs/inode.c b/fs/erofs/inode.c
index 31ac3a7..a552399 100644
--- a/fs/erofs/inode.c
+++ b/fs/erofs/inode.c
@@ -176,7 +176,7 @@ static struct page *erofs_read_inode(struct inode *inode,
}

if (vi->datalayout == EROFS_INODE_CHUNK_BASED) {
- if (!(vi->chunkformat & EROFS_CHUNK_FORMAT_ALL)) {
+ if (vi->chunkformat & ~EROFS_CHUNK_FORMAT_ALL) {
erofs_err(inode->i_sb,
"unsupported chunk format %x of nid %llu",
vi->chunkformat, vi->nid);
--
1.8.3.1


2021-09-22 17:50:14

by Liu Bo

[permalink] [raw]
Subject: Re: [PATCH] erofs: fix misbehavior of unsupported chunk format check

On Wed, Sep 22, 2021 at 05:51:41PM +0800, Gao Xiang wrote:
> Unsupported chunk format should be checked with
> "if (vi->chunkformat & ~EROFS_CHUNK_FORMAT_ALL)"
>
> Found when checking with 4k-byte blockmap (although currently mkfs
> uses inode chunk indexes format by default.)
>

Good catch.

Reviewed-by: Liu Bo <[email protected]>

thanks,
liubo

> Fixes: c5aa903a59db ("erofs: support reading chunk-based uncompressed files")
> Cc: Liu Bo <[email protected]>
> Cc: Chao Yu <[email protected]>
> Signed-off-by: Gao Xiang <[email protected]>
> ---
> fs/erofs/inode.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/fs/erofs/inode.c b/fs/erofs/inode.c
> index 31ac3a7..a552399 100644
> --- a/fs/erofs/inode.c
> +++ b/fs/erofs/inode.c
> @@ -176,7 +176,7 @@ static struct page *erofs_read_inode(struct inode *inode,
> }
>
> if (vi->datalayout == EROFS_INODE_CHUNK_BASED) {
> - if (!(vi->chunkformat & EROFS_CHUNK_FORMAT_ALL)) {
> + if (vi->chunkformat & ~EROFS_CHUNK_FORMAT_ALL) {
> erofs_err(inode->i_sb,
> "unsupported chunk format %x of nid %llu",
> vi->chunkformat, vi->nid);
> --
> 1.8.3.1

2021-09-23 15:11:55

by Chao Yu

[permalink] [raw]
Subject: Re: [PATCH] erofs: fix misbehavior of unsupported chunk format check

On 2021/9/22 17:51, Gao Xiang wrote:
> Unsupported chunk format should be checked with
> "if (vi->chunkformat & ~EROFS_CHUNK_FORMAT_ALL)"
>
> Found when checking with 4k-byte blockmap (although currently mkfs

That means for 4k-byte blockmap, chunkformat should be zero, right?

> uses inode chunk indexes format by default.)
>
> Fixes: c5aa903a59db ("erofs: support reading chunk-based uncompressed files")
> Cc: Liu Bo <[email protected]>
> Cc: Chao Yu <[email protected]>
> Signed-off-by: Gao Xiang <[email protected]>

Reviewed-by: Chao Yu <[email protected]>

Thanks,

2021-09-23 15:24:05

by Gao Xiang

[permalink] [raw]
Subject: Re: [PATCH] erofs: fix misbehavior of unsupported chunk format check

On Thu, Sep 23, 2021 at 11:09:25PM +0800, Chao Yu wrote:
> On 2021/9/22 17:51, Gao Xiang wrote:
> > Unsupported chunk format should be checked with
> > "if (vi->chunkformat & ~EROFS_CHUNK_FORMAT_ALL)"
> >
> > Found when checking with 4k-byte blockmap (although currently mkfs
>
> That means for 4k-byte blockmap, chunkformat should be zero, right?

Yeah, correct. It's a regression of 4kb chunk blockmap..

>
> > uses inode chunk indexes format by default.)
> >
> > Fixes: c5aa903a59db ("erofs: support reading chunk-based uncompressed files")
> > Cc: Liu Bo <[email protected]>
> > Cc: Chao Yu <[email protected]>
> > Signed-off-by: Gao Xiang <[email protected]>
>
> Reviewed-by: Chao Yu <[email protected]>

Thanks!

Thanks,
Gao Xiang

>
> Thanks,