summary refs log tree commit diff
path: root/fs/erofs/inode.c
diff options
context:
space:
mode:
authorGao Xiang <hsiangkao@redhat.com>2021-03-29 08:36:14 +0800
committerGao Xiang <hsiangkao@redhat.com>2021-03-29 10:20:45 +0800
commit24a806d849c0b0c1d0cd6a6b93ba4ae4c0ec9f08 (patch)
tree9cae419066736369e8d0ca46508166c323bb4016 /fs/erofs/inode.c
parent8137824eddd2e790c61c70c20d70a087faca95fa (diff)
downloadlinux-24a806d849c0b0c1d0cd6a6b93ba4ae4c0ec9f08.tar.gz
erofs: add unsupported inode i_format check
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>
Diffstat (limited to 'fs/erofs/inode.c')
-rw-r--r--fs/erofs/inode.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/fs/erofs/inode.c b/fs/erofs/inode.c
index 119fdce1b520..7ed2d7391692 100644
--- a/fs/erofs/inode.c
+++ b/fs/erofs/inode.c
@@ -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",