Skip to content

Commit dbaf435

Browse files
Gao Xianggregkh
authored andcommitted
erofs: add unsupported inode i_format check
commit 24a806d upstream. If any unknown i_format fields are set (may be of some new incompat inode features), mark such inode as unsupported. Just in case of any new incompat i_format fields added in the future. Link: https://lore.kernel.org/r/20210329003614.6583-1-hsiangkao@aol.com Fixes: 431339b ("staging: erofs: add inode operations") Cc: <stable@vger.kernel.org> # 4.19+ Signed-off-by: Gao Xiang <hsiangkao@redhat.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 34ec706 commit dbaf435

2 files changed

Lines changed: 10 additions & 0 deletions

File tree

‎fs/erofs/erofs_fs.h‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,9 @@ static inline bool erofs_inode_is_data_compressed(unsigned int datamode)
7575
#define EROFS_I_VERSION_BIT 0
7676
#define EROFS_I_DATALAYOUT_BIT 1
7777

78+
#define EROFS_I_ALL \
79+
((1 << (EROFS_I_DATALAYOUT_BIT + EROFS_I_DATALAYOUT_BITS)) - 1)
80+
7881
/* 32-byte reduced form of an ondisk inode */
7982
struct erofs_inode_compact {
8083
__le16 i_format; /* inode format hints */

‎fs/erofs/inode.c‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,13 @@ static struct page *erofs_read_inode(struct inode *inode,
4444
dic = page_address(page) + *ofs;
4545
ifmt = le16_to_cpu(dic->i_format);
4646

47+
if (ifmt & ~EROFS_I_ALL) {
48+
erofs_err(inode->i_sb, "unsupported i_format %u of nid %llu",
49+
ifmt, vi->nid);
50+
err = -EOPNOTSUPP;
51+
goto err_out;
52+
}
53+
4754
vi->datalayout = erofs_inode_datalayout(ifmt);
4855
if (vi->datalayout >= EROFS_INODE_DATALAYOUT_MAX) {
4956
erofs_err(inode->i_sb, "unsupported datalayout %u of nid %llu",

0 commit comments

Comments
 (0)