erofs: add unsupported inode i_format check
Subsystems (2)
PATCH 1/1 erofs: add unsupported inode i_format check
In reply to a message not in the archiveFrom: Gao Xiang <[email protected]>
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.
Fixes 431339ba9042 ("staging: erofs: add inode operations")
Cc <[email protected]> # 4.19+
Signed-off-by Gao Xiang <[email protected]>
---
new potential inode features can also be covered by COMPR_CFGS & BIG_PCLUSTER in the next cycle at least, and possibly need its new sb incompat feature as well so it's not quite vital.
fs/erofs/erofs_fs.h | 3 +++ fs/erofs/inode.c | 7 +++++++ 2 files changed, 10 insertions(+)
fs/erofs/erofs_fs.h +3 -0
@@ -75,6 +75,9 @@ static inline bool erofs_inode_is_data_compressed(unsigned int datamode)#define EROFS_I_VERSION_BIT 0#define EROFS_I_DATALAYOUT_BIT 1 +#define EROFS_I_ALL \ + ((1 << (EROFS_I_DATALAYOUT_BIT + EROFS_I_DATALAYOUT_BITS)) - 1) +/* 32-byte reduced form of an ondisk inode */ struct erofs_inode_compact {__le16 i_format;/* inode format hints */
fs/erofs/inode.c +7 -0
@@ -44,6 +44,13 @@ static struct page *erofs_read_inode(struct inode *inode, dic =page_address (page) + *ofs; ifmt =le16_to_cpu (dic->i_format); +if (ifmt & ~EROFS_I_ALL ) { +erofs_err (inode->i_sb,"unsupported i_format %u of nid %llu" , + ifmt, vi->nid); + err = -EOPNOTSUPP ; + goto err_out; + } + vi->datalayout =erofs_inode_datalayout (ifmt);if (vi->datalayout >=EROFS_INODE_DATALAYOUT_MAX ) { erofs_err(inode->i_sb, "unsupported datalayout %u of nid %llu",
Signature · 1 line
2.20.1