From: Jean-Jacques Hiblot Date: Thu, 14 Feb 2019 17:04:01 +0100 Subject: [U-Boot] [PATCH v2 1/7] fs: ext4: do not allow writes if metadata checksum is active In-Reply-To: <20190201152339.GB30838@bill-the-cat> References: <20190201143340.7663-1-jjhiblot@ti.com> <20190201143340.7663-2-jjhiblot@ti.com> <20190201152339.GB30838@bill-the-cat> Message-ID: <3346cae8-419e-eaf1-079e-86b6834c8960@ti.com> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable To: u-boot@lists.denx.de On 01/02/2019 16:23, Tom Rini wrote: > On Fri, Feb 01, 2019 at 03:33:34PM +0100, Jean-Jacques Hiblot wrote: > >> u-boot does not supports updating the metadata chacksums >> >> Signed-off-by: Jean-Jacques Hiblot >> >> --- >> >> Changes in v2: >> - Prevent write access if metadata checksum is enabled >> >> fs/ext4/ext4_write.c | 12 ++++++++++-- >> include/ext4fs.h | 1 + >> 2 files changed, 11 insertions(+), 2 deletions(-) >> >> diff --git a/fs/ext4/ext4_write.c b/fs/ext4/ext4_write.c >> index a7f543f7df..1de29236f0 100644 >> --- a/fs/ext4/ext4_write.c >> +++ b/fs/ext4/ext4_write.c >> @@ -858,12 +858,19 @@ int ext4fs_write(const char *fname, unsigned char = *buffer, >> =20 >> g_parent_inode =3D zalloc(fs->inodesz); >> if (!g_parent_inode) >> - goto fail; >> + goto fail_ext4fs_init; >> =20 >> if (ext4fs_init() !=3D 0) { >> printf("error in File System init\n"); >> - return -1; >> + goto fail_ext4fs_init; >> + } >> + >> + if (le32_to_cpu(fs->sb->feature_ro_compat) & >> + EXT4_FEATURE_RO_COMPAT_METADATA_CSUM) { >> + printf("u-boot doesn't support updating the metadata checksums yet\n"= ); >> + goto fail; >> } >> + >> inodes_per_block =3D fs->blksz / fs->inodesz; >> parent_inodeno =3D ext4fs_get_parent_inode_num(fname, filename, F_FIL= E); >> if (parent_inodeno =3D=3D -1) > I'm following up to myself on this one as, Ugh. To repeat myself from a > while back: > commit 6f94ab6656ceffb3f2a972c8de4c554502b6f2b7 > Author: Tom Rini > Date: Fri Jul 22 17:59:11 2016 -0400 > > ext4: Refuse to mount filesystems with 64bit feature set > =20 > With e2fsprogs after 1.43 the 64bit and metadata_csum features are > enabled by default. The metadata_csum feature changes how > ext4_group_desc->bg_checksum is calculated, which would break write > support. The 64bit feature however introduces changes such that it > cannot be read by implementations that do not support it. Since we = do > not support this, we must not mount it. > =20 > Cc: Stephen Warren > Cc: Simon Glass > Cc: Lukasz Majewski > Cc: Stefan Roese > Reported-by: Andrew Bradford > Signed-off-by: Tom Rini > > Which means that starting way back then I should have also done > something to say we cannot write to these new images either. It's good > and important to finally catch this failure now. I suspect it's however > going to start to be an unexpected problem. Have you any idea how much > work would go in to supporting the metadata_csum feature? Thanks again! I had a look and this is going to be a non-trivial job. The ext4 code is=20 showing its age.=C2=A0 And then there would be another couple of flags to=20 handle too like journal checksuming, and then also hashtree dirs. There are a couple of ext4 libs out there (I'm thinking of lwext4 or=20 e2fsprogs) that do a much better job at handling the=20 compatible/incompatible/read-only flags. I wonder if we wouldn't be=20 better off adapting one of them than fixing the current implementation. JJ >