2020-01-10 08:59:44

by Anatoly Pugachev

[permalink] [raw]
Subject: [PATCH] libext2fs: Extends commit c9a8c53b, with the same fix for ext2fs_flush2() and ext2fs_image_super_write() on a Big Endian systems.


libext2fs: extends commit c9a8c53b, with the same fix for ext2fs_flush2() and
ext2fs_image_super_write() on a Big Endian systems.

As follow-up to previous discussion 'dumpe2fs / mke2fs sigserv on sparc64'

Used find for files which refer to:

e2fsprogs.git$ find . -name \*.c | xargs grep -cl 'gdp = ext2fs_group_desc'
./lib/ext2fs/closefs.c
./lib/ext2fs/openfs.c
./lib/ext2fs/imager.c

And applied the same check for a null pointer.

Tested on a debian linux with sparc64 LDOM and ppc64 LPAR.

Fixes sigserv with test suite in "i_bitmaps" test.

Signed-off-by: Anatoly Pugachev <[email protected]>
Signed-off-by: Theodore Ts'o <[email protected]>
---
lib/ext2fs/closefs.c | 3 ++-
lib/ext2fs/imager.c | 6 ++++--
2 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/lib/ext2fs/closefs.c b/lib/ext2fs/closefs.c
index 1d4d5b7f..58fdd5c6 100644
--- a/lib/ext2fs/closefs.c
+++ b/lib/ext2fs/closefs.c
@@ -339,7 +339,8 @@ errcode_t ext2fs_flush2(ext2_filsys fs, int flags)
ext2fs_swap_super(super_shadow);
for (j = 0; j < fs->group_desc_count; j++) {
gdp = ext2fs_group_desc(fs, group_shadow, j);
- ext2fs_swap_group_desc2(fs, gdp);
+ if (gdp)
+ ext2fs_swap_group_desc2(fs, gdp);
}
#else
super_shadow = fs->super;
diff --git a/lib/ext2fs/imager.c b/lib/ext2fs/imager.c
index 7fd06f74..b40fd826 100644
--- a/lib/ext2fs/imager.c
+++ b/lib/ext2fs/imager.c
@@ -245,7 +245,8 @@ errcode_t ext2fs_image_super_write(ext2_filsys fs, int fd,
gdp = (struct ext2_group_desc *) cp;
for (j=0; j < groups_per_block*fs->desc_blocks; j++) {
gdp = ext2fs_group_desc(fs, fs->group_desc, j);
- ext2fs_swap_group_desc2(fs, gdp);
+ if (gdp)
+ ext2fs_swap_group_desc2(fs, gdp);
}
#endif

@@ -257,7 +258,8 @@ errcode_t ext2fs_image_super_write(ext2_filsys fs, int fd,
gdp = (struct ext2_group_desc *) cp;
for (j=0; j < groups_per_block*fs->desc_blocks; j++) {
gdp = ext2fs_group_desc(fs, fs->group_desc, j);
- ext2fs_swap_group_desc2(fs, gdp);
+ if (gdp)
+ ext2fs_swap_group_desc2(fs, gdp);
}
#endif

--
2.25.0.rc1


2020-01-10 17:34:57

by Theodore Ts'o

[permalink] [raw]
Subject: Re: [PATCH] libext2fs: Extends commit c9a8c53b, with the same fix for ext2fs_flush2() and ext2fs_image_super_write() on a Big Endian systems.

On Fri, Jan 10, 2020 at 11:52:17AM +0300, Anatoly Pugachev wrote:
>
> libext2fs: extends commit c9a8c53b, with the same fix for ext2fs_flush2() and
> ext2fs_image_super_write() on a Big Endian systems.
>
> As follow-up to previous discussion 'dumpe2fs / mke2fs sigserv on sparc64'
>
> Used find for files which refer to:
>
> e2fsprogs.git$ find . -name \*.c | xargs grep -cl 'gdp = ext2fs_group_desc'
> ./lib/ext2fs/closefs.c
> ./lib/ext2fs/openfs.c
> ./lib/ext2fs/imager.c
>
> And applied the same check for a null pointer.
>
> Tested on a debian linux with sparc64 LDOM and ppc64 LPAR.
>
> Fixes sigserv with test suite in "i_bitmaps" test.

As far as I know, the i_bitmaps test is passing on on sparc64 and
ppc64. Search for i_bitmaps in:

https://buildd.debian.org/status/fetch.php?pkg=e2fsprogs&arch=sparc64&ver=1.45.5-2&stamp=1578527938&raw=0
and
https://buildd.debian.org/status/fetch.php?pkg=e2fsprogs&arch=ppc64&ver=1.45.5-2&stamp=1578526270&raw=0

The bug in c9a8c53b was caused by SPARSE_SUPER being passed to
ext2fs_open(). But that doesn't happen in misc/e2image.

I can see optimizing ext2fs_flush() to skip byte-swapping the group
descriptors if the SUPER_ONLY flag is enabled. And I can see
ext2fs_image_super_write() checking to see if the SUPER_ONLY flag is
set, and returning an error in that case.

But I don't think any of the current e2fsprogs are crashing at the
moment. Am I missing something?

Regards,

- Ted

2020-01-11 00:14:16

by Anatoly Pugachev

[permalink] [raw]
Subject: Re: [PATCH] libext2fs: Extends commit c9a8c53b, with the same fix for ext2fs_flush2() and ext2fs_image_super_write() on a Big Endian systems.

On Fri, Jan 10, 2020 at 8:34 PM Theodore Y. Ts'o <[email protected]> wrote:
>
> On Fri, Jan 10, 2020 at 11:52:17AM +0300, Anatoly Pugachev wrote:
> >
> > libext2fs: extends commit c9a8c53b, with the same fix for ext2fs_flush2() and
> > ext2fs_image_super_write() on a Big Endian systems.
> >
> > As follow-up to previous discussion 'dumpe2fs / mke2fs sigserv on sparc64'
> >
> > Used find for files which refer to:
> >
> > e2fsprogs.git$ find . -name \*.c | xargs grep -cl 'gdp = ext2fs_group_desc'
> > ./lib/ext2fs/closefs.c
> > ./lib/ext2fs/openfs.c
> > ./lib/ext2fs/imager.c
> >
> > And applied the same check for a null pointer.
> >
> > Tested on a debian linux with sparc64 LDOM and ppc64 LPAR.
> >
> > Fixes sigserv with test suite in "i_bitmaps" test.
>
> As far as I know, the i_bitmaps test is passing on on sparc64 and
> ppc64. Search for i_bitmaps in:
>
> https://buildd.debian.org/status/fetch.php?pkg=e2fsprogs&arch=sparc64&ver=1.45.5-2&stamp=1578527938&raw=0
> and
> https://buildd.debian.org/status/fetch.php?pkg=e2fsprogs&arch=ppc64&ver=1.45.5-2&stamp=1578526270&raw=0
>
> The bug in c9a8c53b was caused by SPARSE_SUPER being passed to
> ext2fs_open(). But that doesn't happen in misc/e2image.
>
> I can see optimizing ext2fs_flush() to skip byte-swapping the group
> descriptors if the SUPER_ONLY flag is enabled. And I can see
> ext2fs_image_super_write() checking to see if the SUPER_ONLY flag is
> set, and returning an error in that case.
>
> But I don't think any of the current e2fsprogs are crashing at the
> moment. Am I missing something?

Ted,

I'm using "master" branch for my tests, and debian probably using
"debian/master" .
Even test count is differ. In master branch 366 tests and in
"debian/master" 356 tests.

$ git br -vvv
debian/master 0ba96395 [origin/debian/master] debian/patches: update
for 1.45.5-2 release
* master 32d33132 [origin/master] Merge branch 'maint' into next

Can you please try master branch on any (sparc64 or ppc64) debian
porter boxes? (There's new ppc64 porter box coming soon)
Or on ppc64/sparc64 "gcc compile test" farm machines?

And it's actually up to you, maybe my patch is irrelevant (and sorry
for the noise then), since i don't know internals for e2fsprogs.

Thanks.