diff options
Diffstat (limited to 'fs/ext4')
-rw-r--r-- | fs/ext4/ext4_common.c | 21 | ||||
-rw-r--r-- | fs/ext4/ext4_common.h | 5 | ||||
-rw-r--r-- | fs/ext4/ext4_write.c | 12 | ||||
-rw-r--r-- | fs/ext4/ext4fs.c | 2 |
4 files changed, 33 insertions, 7 deletions
diff --git a/fs/ext4/ext4_common.c b/fs/ext4/ext4_common.c index 52152a2295a..76f7102456e 100644 --- a/fs/ext4/ext4_common.c +++ b/fs/ext4/ext4_common.c @@ -2181,13 +2181,18 @@ static char *ext4fs_read_symlink(struct ext2fs_node *node) struct ext2fs_node *diro = node; int status; loff_t actread; + size_t alloc_size; if (!diro->inode_read) { status = ext4fs_read_inode(diro->data, diro->ino, &diro->inode); if (status == 0) return NULL; } - symlink = zalloc(le32_to_cpu(diro->inode.size) + 1); + + if (__builtin_add_overflow(le32_to_cpu(diro->inode.size), 1, &alloc_size)) + return NULL; + + symlink = zalloc(alloc_size); if (!symlink) return NULL; @@ -2383,6 +2388,20 @@ int ext4fs_mount(void) fs->inodesz = 128; fs->gdsize = 32; } else { + int missing = __le32_to_cpu(data->sblock.feature_incompat) & + ~(EXT4_FEATURE_INCOMPAT_SUPP | + EXT4_FEATURE_INCOMPAT_SUPP_LAZY_RO); + + if (missing) { + /* + * This code used to be relaxed about feature flags. + * We don't stop the mount to avoid breaking existing setups. + * But, incompatible features can cause serious read errors. + */ + log_err("fs uses incompatible features: %08x, ignoring\n", + missing); + } + debug("EXT4 features COMPAT: %08x INCOMPAT: %08x RO_COMPAT: %08x\n", __le32_to_cpu(data->sblock.feature_compatibility), __le32_to_cpu(data->sblock.feature_incompat), diff --git a/fs/ext4/ext4_common.h b/fs/ext4/ext4_common.h index 84500e990aa..346752092b0 100644 --- a/fs/ext4/ext4_common.h +++ b/fs/ext4/ext4_common.h @@ -24,6 +24,7 @@ #include <ext4fs.h> #include <malloc.h> #include <asm/cache.h> +#include <linux/compat.h> #include <linux/errno.h> #if defined(CONFIG_EXT4_WRITE) #include "ext4_journal.h" @@ -43,9 +44,7 @@ static inline void *zalloc(size_t size) { - void *p = memalign(ARCH_DMA_MINALIGN, size); - memset(p, 0, size); - return p; + return kzalloc(size, 0); } int ext4fs_read_inode(struct ext2_data *data, int ino, diff --git a/fs/ext4/ext4_write.c b/fs/ext4/ext4_write.c index a2dfff81979..d109ed6e90d 100644 --- a/fs/ext4/ext4_write.c +++ b/fs/ext4/ext4_write.c @@ -866,6 +866,7 @@ int ext4fs_write(const char *fname, const char *buffer, ALLOC_CACHE_ALIGN_BUFFER(char, filename, 256); bool store_link_in_inode = false; memset(filename, 0x00, 256); + int missing_feat; if (type != FILETYPE_REG && type != FILETYPE_SYMLINK) return -1; @@ -879,8 +880,15 @@ int ext4fs_write(const char *fname, const char *buffer, return -1; } - if (le32_to_cpu(fs->sb->feature_ro_compat) & EXT4_FEATURE_RO_COMPAT_METADATA_CSUM) { - printf("Unsupported feature metadata_csum found, not writing.\n"); + missing_feat = le32_to_cpu(fs->sb->feature_incompat) & ~EXT4_FEATURE_INCOMPAT_SUPP; + if (missing_feat) { + log_err("Unsupported features found %08x, not writing.\n", missing_feat); + return -1; + } + + missing_feat = le32_to_cpu(fs->sb->feature_ro_compat) & ~EXT4_FEATURE_RO_COMPAT_SUPP; + if (missing_feat) { + log_err("Unsupported RO compat features found %08x, not writing.\n", missing_feat); return -1; } diff --git a/fs/ext4/ext4fs.c b/fs/ext4/ext4fs.c index da59cb008fc..15587e92e3e 100644 --- a/fs/ext4/ext4fs.c +++ b/fs/ext4/ext4fs.c @@ -27,7 +27,7 @@ #include <div64.h> #include <malloc.h> #include <part.h> -#include <uuid.h> +#include <u-boot/uuid.h> int ext4fs_symlinknest; struct ext_filesystem ext_fs; |