* [PATCH] debugfs: byteswap dirsearch dirent buf on big endian systems
@ 2025-01-23 13:52 Brian Foster
2025-03-03 19:09 ` Brian Foster
2025-05-21 14:51 ` Theodore Ts'o
0 siblings, 2 replies; 4+ messages in thread
From: Brian Foster @ 2025-01-23 13:52 UTC (permalink / raw)
To: linux-ext4
fstests test ext4/048 fails on big endian systems due to broken
debugfs dirsearch functionality. On an s390x system and 4k block
size, the dirsearch command seems to hang indefinitely. On the same
system with a 1k block size, the command fails to locate an existing
entry and causes the test to fail due to unexpected results.
The cause of the dirsearch failure is lack of byte swapping of the
on-disk (little endian) dirent buffer before attempting to iterate
entries in the given block. This leads to garbage record and name
length values, for example. To resolve this problem, byte swap the
directory buffer on big endian systems.
Signed-off-by: Brian Foster <bfoster@redhat.com>
---
Hi all,
I'm not terribly familiar with this code, but this fixes the test and
doesn't show any regressions from fstests runs on big or little endian
systems. Thanks.
Brian
debugfs/htree.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/debugfs/htree.c b/debugfs/htree.c
index a1008150..4ea8f30b 100644
--- a/debugfs/htree.c
+++ b/debugfs/htree.c
@@ -482,6 +482,12 @@ static int search_dir_block(ext2_filsys fs, blk64_t *blocknr,
return BLOCK_ABORT;
}
+#ifdef WORDS_BIGENDIAN
+ errcode = ext2fs_dirent_swab_in(fs, p->buf, 0);
+ if (errcode)
+ return BLOCK_ABORT;
+#endif
+
while (offset < fs->blocksize) {
dirent = (struct ext2_dir_entry *) (p->buf + offset);
errcode = ext2fs_get_rec_len(fs, dirent, &rec_len);
--
2.47.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] debugfs: byteswap dirsearch dirent buf on big endian systems
2025-01-23 13:52 [PATCH] debugfs: byteswap dirsearch dirent buf on big endian systems Brian Foster
@ 2025-03-03 19:09 ` Brian Foster
2025-03-04 19:34 ` Darrick J. Wong
2025-05-21 14:51 ` Theodore Ts'o
1 sibling, 1 reply; 4+ messages in thread
From: Brian Foster @ 2025-03-03 19:09 UTC (permalink / raw)
To: linux-ext4
On Thu, Jan 23, 2025 at 08:52:11AM -0500, Brian Foster wrote:
> fstests test ext4/048 fails on big endian systems due to broken
> debugfs dirsearch functionality. On an s390x system and 4k block
> size, the dirsearch command seems to hang indefinitely. On the same
> system with a 1k block size, the command fails to locate an existing
> entry and causes the test to fail due to unexpected results.
>
> The cause of the dirsearch failure is lack of byte swapping of the
> on-disk (little endian) dirent buffer before attempting to iterate
> entries in the given block. This leads to garbage record and name
> length values, for example. To resolve this problem, byte swap the
> directory buffer on big endian systems.
>
> Signed-off-by: Brian Foster <bfoster@redhat.com>
> ---
>
> Hi all,
>
> I'm not terribly familiar with this code, but this fixes the test and
> doesn't show any regressions from fstests runs on big or little endian
> systems. Thanks.
>
Ping... curious if anybody has thoughts on this for dirsearch on big
endian? Thanks!
Brian
> Brian
>
> debugfs/htree.c | 6 ++++++
> 1 file changed, 6 insertions(+)
>
> diff --git a/debugfs/htree.c b/debugfs/htree.c
> index a1008150..4ea8f30b 100644
> --- a/debugfs/htree.c
> +++ b/debugfs/htree.c
> @@ -482,6 +482,12 @@ static int search_dir_block(ext2_filsys fs, blk64_t *blocknr,
> return BLOCK_ABORT;
> }
>
> +#ifdef WORDS_BIGENDIAN
> + errcode = ext2fs_dirent_swab_in(fs, p->buf, 0);
> + if (errcode)
> + return BLOCK_ABORT;
> +#endif
> +
> while (offset < fs->blocksize) {
> dirent = (struct ext2_dir_entry *) (p->buf + offset);
> errcode = ext2fs_get_rec_len(fs, dirent, &rec_len);
> --
> 2.47.1
>
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] debugfs: byteswap dirsearch dirent buf on big endian systems
2025-03-03 19:09 ` Brian Foster
@ 2025-03-04 19:34 ` Darrick J. Wong
0 siblings, 0 replies; 4+ messages in thread
From: Darrick J. Wong @ 2025-03-04 19:34 UTC (permalink / raw)
To: Brian Foster; +Cc: linux-ext4
On Mon, Mar 03, 2025 at 02:09:05PM -0500, Brian Foster wrote:
> On Thu, Jan 23, 2025 at 08:52:11AM -0500, Brian Foster wrote:
> > fstests test ext4/048 fails on big endian systems due to broken
> > debugfs dirsearch functionality. On an s390x system and 4k block
> > size, the dirsearch command seems to hang indefinitely. On the same
> > system with a 1k block size, the command fails to locate an existing
> > entry and causes the test to fail due to unexpected results.
> >
> > The cause of the dirsearch failure is lack of byte swapping of the
> > on-disk (little endian) dirent buffer before attempting to iterate
> > entries in the given block. This leads to garbage record and name
> > length values, for example. To resolve this problem, byte swap the
> > directory buffer on big endian systems.
> >
> > Signed-off-by: Brian Foster <bfoster@redhat.com>
> > ---
> >
> > Hi all,
> >
> > I'm not terribly familiar with this code, but this fixes the test and
> > doesn't show any regressions from fstests runs on big or little endian
> > systems. Thanks.
> >
>
> Ping... curious if anybody has thoughts on this for dirsearch on big
> endian? Thanks!
It looks correct to /me/... horrors of debugfs, etc. :(
Reviewed-by: "Darrick J. Wong" <djwong@kernel.org>
--D
>
> Brian
>
> > Brian
> >
> > debugfs/htree.c | 6 ++++++
> > 1 file changed, 6 insertions(+)
> >
> > diff --git a/debugfs/htree.c b/debugfs/htree.c
> > index a1008150..4ea8f30b 100644
> > --- a/debugfs/htree.c
> > +++ b/debugfs/htree.c
> > @@ -482,6 +482,12 @@ static int search_dir_block(ext2_filsys fs, blk64_t *blocknr,
> > return BLOCK_ABORT;
> > }
> >
> > +#ifdef WORDS_BIGENDIAN
> > + errcode = ext2fs_dirent_swab_in(fs, p->buf, 0);
> > + if (errcode)
> > + return BLOCK_ABORT;
> > +#endif
> > +
> > while (offset < fs->blocksize) {
> > dirent = (struct ext2_dir_entry *) (p->buf + offset);
> > errcode = ext2fs_get_rec_len(fs, dirent, &rec_len);
> > --
> > 2.47.1
> >
> >
>
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] debugfs: byteswap dirsearch dirent buf on big endian systems
2025-01-23 13:52 [PATCH] debugfs: byteswap dirsearch dirent buf on big endian systems Brian Foster
2025-03-03 19:09 ` Brian Foster
@ 2025-05-21 14:51 ` Theodore Ts'o
1 sibling, 0 replies; 4+ messages in thread
From: Theodore Ts'o @ 2025-05-21 14:51 UTC (permalink / raw)
To: linux-ext4, Brian Foster; +Cc: Theodore Ts'o
On Thu, 23 Jan 2025 08:52:11 -0500, Brian Foster wrote:
> fstests test ext4/048 fails on big endian systems due to broken
> debugfs dirsearch functionality. On an s390x system and 4k block
> size, the dirsearch command seems to hang indefinitely. On the same
> system with a 1k block size, the command fails to locate an existing
> entry and causes the test to fail due to unexpected results.
>
> The cause of the dirsearch failure is lack of byte swapping of the
> on-disk (little endian) dirent buffer before attempting to iterate
> entries in the given block. This leads to garbage record and name
> length values, for example. To resolve this problem, byte swap the
> directory buffer on big endian systems.
>
> [...]
Applied, thanks!
[1/1] debugfs: byteswap dirsearch dirent buf on big endian systems
commit: 4be42019388d76c933e3b2ea80284aaf5b8eaecb
Best regards,
--
Theodore Ts'o <tytso@mit.edu>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2025-05-21 14:51 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-01-23 13:52 [PATCH] debugfs: byteswap dirsearch dirent buf on big endian systems Brian Foster
2025-03-03 19:09 ` Brian Foster
2025-03-04 19:34 ` Darrick J. Wong
2025-05-21 14:51 ` Theodore Ts'o
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox