]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
erofs: add unsupported inode i_format check
authorGao Xiang <hsiangkao@redhat.com>
Mon, 29 Mar 2021 00:36:14 +0000 (08:36 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 22 May 2021 08:59:13 +0000 (10:59 +0200)
commit 24a806d849c0b0c1d0cd6a6b93ba4ae4c0ec9f08 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: 431339ba9042 ("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>
drivers/staging/erofs/erofs_fs.h
drivers/staging/erofs/inode.c

index 7677da889f1255988117bae54bc10fdaedec64c4..d8838ce6694164a12e309bf391e609ca019889cc 100644 (file)
@@ -71,6 +71,9 @@ enum {
 #define EROFS_I_VERSION_BIT             0
 __EROFS_BIT(EROFS_I_, DATA_MAPPING, VERSION);
 
+#define EROFS_I_ALL    \
+       ((1 << (EROFS_I_DATA_MAPPING_BIT + EROFS_I_DATA_MAPPING_BITS)) - 1)
+
 struct erofs_inode_v1 {
 /*  0 */__le16 i_advise;
 
index a43abd530cc105d846e8ece6ef303f38391ffbb6..02398c7eb4a4095abf378e2333a32510a158a8c3 100644 (file)
@@ -48,6 +48,12 @@ static struct page *read_inode(struct inode *inode, unsigned int *ofs)
        v1 = page_address(page) + *ofs;
        ifmt = le16_to_cpu(v1->i_advise);
 
+       if (ifmt & ~EROFS_I_ALL) {
+               errln("unsupported i_format %u of nid %llu", ifmt, vi->nid);
+               err = -EOPNOTSUPP;
+               goto err_out;
+       }
+
        vi->data_mapping_mode = __inode_data_mapping(ifmt);
        if (unlikely(vi->data_mapping_mode >= EROFS_INODE_LAYOUT_MAX)) {
                errln("unknown data mapping mode %u of nid %llu",