diff options
| author | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2019-06-17 16:59:28 -0400 |
|---|---|---|
| committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2019-06-17 16:59:28 -0400 |
| commit | 9b9410766f5422d1e736783dc0c3a053eefedac4 (patch) | |
| tree | bd397aa6fdecfd0713b725f9728d42e8261093d4 | |
| parent | d7a5417b89470d353118a451630ed71f119f58b8 (diff) | |
| parent | 5efe5137f05bbb4688890620934538c005e7d1d6 (diff) | |
Merge branch 'erofs_fix' into staging-linus
A branch is needed here to get the fix into staging-next as well.
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
| -rw-r--r-- | drivers/staging/erofs/erofs_fs.h | 13 | ||||
| -rw-r--r-- | drivers/staging/erofs/internal.h | 2 | ||||
| -rw-r--r-- | drivers/staging/erofs/super.c | 19 |
3 files changed, 31 insertions, 3 deletions
diff --git a/drivers/staging/erofs/erofs_fs.h b/drivers/staging/erofs/erofs_fs.h index fa52898df006..8ddb2b3e7d39 100644 --- a/drivers/staging/erofs/erofs_fs.h +++ b/drivers/staging/erofs/erofs_fs.h | |||
| @@ -17,10 +17,16 @@ | |||
| 17 | #define EROFS_SUPER_MAGIC_V1 0xE0F5E1E2 | 17 | #define EROFS_SUPER_MAGIC_V1 0xE0F5E1E2 |
| 18 | #define EROFS_SUPER_OFFSET 1024 | 18 | #define EROFS_SUPER_OFFSET 1024 |
| 19 | 19 | ||
| 20 | /* | ||
| 21 | * Any bits that aren't in EROFS_ALL_REQUIREMENTS should be | ||
| 22 | * incompatible with this kernel version. | ||
| 23 | */ | ||
| 24 | #define EROFS_ALL_REQUIREMENTS 0 | ||
| 25 | |||
| 20 | struct erofs_super_block { | 26 | struct erofs_super_block { |
| 21 | /* 0 */__le32 magic; /* in the little endian */ | 27 | /* 0 */__le32 magic; /* in the little endian */ |
| 22 | /* 4 */__le32 checksum; /* crc32c(super_block) */ | 28 | /* 4 */__le32 checksum; /* crc32c(super_block) */ |
| 23 | /* 8 */__le32 features; | 29 | /* 8 */__le32 features; /* (aka. feature_compat) */ |
| 24 | /* 12 */__u8 blkszbits; /* support block_size == PAGE_SIZE only */ | 30 | /* 12 */__u8 blkszbits; /* support block_size == PAGE_SIZE only */ |
| 25 | /* 13 */__u8 reserved; | 31 | /* 13 */__u8 reserved; |
| 26 | 32 | ||
| @@ -34,9 +40,10 @@ struct erofs_super_block { | |||
| 34 | /* 44 */__le32 xattr_blkaddr; | 40 | /* 44 */__le32 xattr_blkaddr; |
| 35 | /* 48 */__u8 uuid[16]; /* 128-bit uuid for volume */ | 41 | /* 48 */__u8 uuid[16]; /* 128-bit uuid for volume */ |
| 36 | /* 64 */__u8 volume_name[16]; /* volume name */ | 42 | /* 64 */__u8 volume_name[16]; /* volume name */ |
| 43 | /* 80 */__le32 requirements; /* (aka. feature_incompat) */ | ||
| 37 | 44 | ||
| 38 | /* 80 */__u8 reserved2[48]; /* 128 bytes */ | 45 | /* 84 */__u8 reserved2[44]; |
| 39 | } __packed; | 46 | } __packed; /* 128 bytes */ |
| 40 | 47 | ||
| 41 | /* | 48 | /* |
| 42 | * erofs inode data mapping: | 49 | * erofs inode data mapping: |
diff --git a/drivers/staging/erofs/internal.h b/drivers/staging/erofs/internal.h index c47778b3fabd..382258fc124d 100644 --- a/drivers/staging/erofs/internal.h +++ b/drivers/staging/erofs/internal.h | |||
| @@ -115,6 +115,8 @@ struct erofs_sb_info { | |||
| 115 | 115 | ||
| 116 | u8 uuid[16]; /* 128-bit uuid for volume */ | 116 | u8 uuid[16]; /* 128-bit uuid for volume */ |
| 117 | u8 volume_name[16]; /* volume name */ | 117 | u8 volume_name[16]; /* volume name */ |
| 118 | u32 requirements; | ||
| 119 | |||
| 118 | char *dev_name; | 120 | char *dev_name; |
| 119 | 121 | ||
| 120 | unsigned int mount_opt; | 122 | unsigned int mount_opt; |
diff --git a/drivers/staging/erofs/super.c b/drivers/staging/erofs/super.c index f580d4ef77a1..cadbcc11702a 100644 --- a/drivers/staging/erofs/super.c +++ b/drivers/staging/erofs/super.c | |||
| @@ -71,6 +71,22 @@ static void free_inode(struct inode *inode) | |||
| 71 | kmem_cache_free(erofs_inode_cachep, vi); | 71 | kmem_cache_free(erofs_inode_cachep, vi); |
| 72 | } | 72 | } |
| 73 | 73 | ||
| 74 | static bool check_layout_compatibility(struct super_block *sb, | ||
| 75 | struct erofs_super_block *layout) | ||
| 76 | { | ||
| 77 | const unsigned int requirements = le32_to_cpu(layout->requirements); | ||
| 78 | |||
| 79 | EROFS_SB(sb)->requirements = requirements; | ||
| 80 | |||
| 81 | /* check if current kernel meets all mandatory requirements */ | ||
| 82 | if (requirements & (~EROFS_ALL_REQUIREMENTS)) { | ||
| 83 | errln("unidentified requirements %x, please upgrade kernel version", | ||
| 84 | requirements & ~EROFS_ALL_REQUIREMENTS); | ||
| 85 | return false; | ||
| 86 | } | ||
| 87 | return true; | ||
| 88 | } | ||
| 89 | |||
| 74 | static int superblock_read(struct super_block *sb) | 90 | static int superblock_read(struct super_block *sb) |
| 75 | { | 91 | { |
| 76 | struct erofs_sb_info *sbi; | 92 | struct erofs_sb_info *sbi; |
| @@ -104,6 +120,9 @@ static int superblock_read(struct super_block *sb) | |||
| 104 | goto out; | 120 | goto out; |
| 105 | } | 121 | } |
| 106 | 122 | ||
| 123 | if (!check_layout_compatibility(sb, layout)) | ||
| 124 | goto out; | ||
| 125 | |||
| 107 | sbi->blocks = le32_to_cpu(layout->blocks); | 126 | sbi->blocks = le32_to_cpu(layout->blocks); |
| 108 | sbi->meta_blkaddr = le32_to_cpu(layout->meta_blkaddr); | 127 | sbi->meta_blkaddr = le32_to_cpu(layout->meta_blkaddr); |
| 109 | #ifdef CONFIG_EROFS_FS_XATTR | 128 | #ifdef CONFIG_EROFS_FS_XATTR |
