]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commit
xfs_db: fix multiple dblock commands
authorDarrick J. Wong <djwong@kernel.org>
Thu, 16 Jan 2025 21:22:03 +0000 (13:22 -0800)
committerDarrick J. Wong <djwong@kernel.org>
Thu, 16 Jan 2025 21:27:27 +0000 (13:27 -0800)
commit741eb9b6f9a88aee5103600e32b01207545c7af0
tree73b1bc8b5aeb58a6677cf4ecb85a02b5992abdf7
parent773c4c6f33cfd0a909fb742f149bd6f59cfa62b6
xfs_db: fix multiple dblock commands

Tom Samstag reported that running the following sequence of commands no
longer works quite right:

> inode [inodenum]
> dblock 0
> p
> dblock 1
> p
> dblock 2
> p
> [etc]

Mr. Samstag looked into the source code and discovered that the
dblock_f is incorrectly accessing iocur_top->data outside of the
push_cur -> set_cur_inode -> pop_cur sequence that this function uses to
compute the type of the file data.  In other words, it's using
whatever's on top of the stack at the start of the function.  For the
"dblock 0" case above this is the inode, but for the "dblock 1" case
this is the contents of file data block 0, not an inode.

Fix this by relocating the check to the correct place.

Reported-by: tom.samstag@netrise.io
Tested-by: Tom Samstag <tom.samstag@netrise.io>
Cc: <linux-xfs@vger.kernel.org> # v6.12.0
Fixes: b05a31722f5d4c ("xfs_db: access realtime file blocks")
Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
db/block.c