]> git.proxmox.com Git - mirror_ubuntu-hirsute-kernel.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)
committerStefan Bader <stefan.bader@canonical.com>
Wed, 19 May 2021 08:31:53 +0000 (10:31 +0200)
BugLink: https://bugs.launchpad.net/bugs/1928857
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>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
fs/erofs/erofs_fs.h
fs/erofs/inode.c

index 9ad1615f447437209dd5c7e4a5af00c5b5232907..e8d04d808fa628d6206bbc0339f0471953faebae 100644 (file)
@@ -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 */
index 3e21c0e8adae73aa75e02af892ad5b30ecfa0c1e..0a94a52a119fbcb89f2d8a1e8662ee362dc2a0a9 100644 (file)
@@ -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",