Commit 98a716ce authored by Greg Kroah-Hartman's avatar Greg Kroah-Hartman

Merge branch 'erofs_fix' into staging-next

erofs needed a fix in both -linus and -next branches at the same time.
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parents faa39884 5efe5137
...@@ -17,10 +17,16 @@ ...@@ -17,10 +17,16 @@
#define EROFS_SUPER_MAGIC_V1 0xE0F5E1E2 #define EROFS_SUPER_MAGIC_V1 0xE0F5E1E2
#define EROFS_SUPER_OFFSET 1024 #define EROFS_SUPER_OFFSET 1024
/*
* Any bits that aren't in EROFS_ALL_REQUIREMENTS should be
* incompatible with this kernel version.
*/
#define EROFS_ALL_REQUIREMENTS 0
struct erofs_super_block { struct erofs_super_block {
/* 0 */__le32 magic; /* in the little endian */ /* 0 */__le32 magic; /* in the little endian */
/* 4 */__le32 checksum; /* crc32c(super_block) */ /* 4 */__le32 checksum; /* crc32c(super_block) */
/* 8 */__le32 features; /* 8 */__le32 features; /* (aka. feature_compat) */
/* 12 */__u8 blkszbits; /* support block_size == PAGE_SIZE only */ /* 12 */__u8 blkszbits; /* support block_size == PAGE_SIZE only */
/* 13 */__u8 reserved; /* 13 */__u8 reserved;
...@@ -34,9 +40,10 @@ struct erofs_super_block { ...@@ -34,9 +40,10 @@ struct erofs_super_block {
/* 44 */__le32 xattr_blkaddr; /* 44 */__le32 xattr_blkaddr;
/* 48 */__u8 uuid[16]; /* 128-bit uuid for volume */ /* 48 */__u8 uuid[16]; /* 128-bit uuid for volume */
/* 64 */__u8 volume_name[16]; /* volume name */ /* 64 */__u8 volume_name[16]; /* volume name */
/* 80 */__le32 requirements; /* (aka. feature_incompat) */
/* 80 */__u8 reserved2[48]; /* 128 bytes */ /* 84 */__u8 reserved2[44];
} __packed; } __packed; /* 128 bytes */
/* /*
* erofs inode data mapping: * erofs inode data mapping:
......
...@@ -115,6 +115,8 @@ struct erofs_sb_info { ...@@ -115,6 +115,8 @@ struct erofs_sb_info {
u8 uuid[16]; /* 128-bit uuid for volume */ u8 uuid[16]; /* 128-bit uuid for volume */
u8 volume_name[16]; /* volume name */ u8 volume_name[16]; /* volume name */
u32 requirements;
char *dev_name; char *dev_name;
unsigned int mount_opt; unsigned int mount_opt;
......
...@@ -71,6 +71,22 @@ static void free_inode(struct inode *inode) ...@@ -71,6 +71,22 @@ static void free_inode(struct inode *inode)
kmem_cache_free(erofs_inode_cachep, vi); kmem_cache_free(erofs_inode_cachep, vi);
} }
static bool check_layout_compatibility(struct super_block *sb,
struct erofs_super_block *layout)
{
const unsigned int requirements = le32_to_cpu(layout->requirements);
EROFS_SB(sb)->requirements = requirements;
/* check if current kernel meets all mandatory requirements */
if (requirements & (~EROFS_ALL_REQUIREMENTS)) {
errln("unidentified requirements %x, please upgrade kernel version",
requirements & ~EROFS_ALL_REQUIREMENTS);
return false;
}
return true;
}
static int superblock_read(struct super_block *sb) static int superblock_read(struct super_block *sb)
{ {
struct erofs_sb_info *sbi; struct erofs_sb_info *sbi;
...@@ -104,6 +120,9 @@ static int superblock_read(struct super_block *sb) ...@@ -104,6 +120,9 @@ static int superblock_read(struct super_block *sb)
goto out; goto out;
} }
if (!check_layout_compatibility(sb, layout))
goto out;
sbi->blocks = le32_to_cpu(layout->blocks); sbi->blocks = le32_to_cpu(layout->blocks);
sbi->meta_blkaddr = le32_to_cpu(layout->meta_blkaddr); sbi->meta_blkaddr = le32_to_cpu(layout->meta_blkaddr);
#ifdef CONFIG_EROFS_FS_XATTR #ifdef CONFIG_EROFS_FS_XATTR
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment