Skip to contentSkip to conversation

xfs_db: fix crc invalidation segfault

PATCH In review Anthony Iliopoulos 3 participants 4 messages Apr 20, 2020 – Apr 21, 2020

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 xfs_db: fix crc invalidation segfault

The nowrite_ops var is declared within nested block scope but used outside that scope, causing xfs_db to crash while trying to defererence the verify_write pointer. Fix it by lifting the declaration to the outer scope, where it is accessed.

---
 db/crc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
db/crc.c +1 -1
index 95161c6df..b23417a11 100644
@@ -53,6 +53,7 @@ crc_f(
 	char		**argv)
 {
 	const struct xfs_buf_ops *stashed_ops = NULL;
+	struct xfs_buf_ops nowrite_ops;
 	extern char	*progname;
 	const field_t	*fields;
 	const ftattr_t	*fa;
@@ -127,7 +128,6 @@ crc_f(
 	}
 
 	if (invalidate) {
-		struct xfs_buf_ops nowrite_ops;
 		flist_t		*sfl;
 		int		bit_length;
 		int		parentoffset;
Signature · 1 line
2.26.1
#1 lore raw
Quoted 6 lines · Anthony Iliopoulos

The nowrite_ops var is declared within nested block scope but used outside that scope, causing xfs_db to crash while trying to defererence the verify_write pointer. Fix it by lifting the declaration to the outer scope, where it is accessed.

Yup, thanks for spotting & fixing this.

Fixes b64af2c "xfs_db: add crc manipulation commands"
Quoted 25 lines
---
 db/crc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
db/crc.c +1 -1
index 95161c6df..b23417a11 100644
@@ -53,6 +53,7 @@ crc_f(
 	char		**argv)
 {
 	const struct xfs_buf_ops *stashed_ops = NULL;
+	struct xfs_buf_ops nowrite_ops;
 	extern char	*progname;
 	const field_t	*fields;
 	const ftattr_t	*fa;
@@ -127,7 +128,6 @@ crc_f(
 	}
 
 	if (invalidate) {
-		struct xfs_buf_ops nowrite_ops;
 		flist_t		*sfl;
 		int		bit_length;
 		int		parentoffset;
#2 lore raw
Quoted 11 lines · Eric Sandeen
Quoted 6 lines · Anthony Iliopoulos

The nowrite_ops var is declared within nested block scope but used outside that scope, causing xfs_db to crash while trying to defererence the verify_write pointer. Fix it by lifting the declaration to the outer scope, where it is accessed.

Yup, thanks for spotting & fixing this.

Fixes b64af2c "xfs_db: add crc manipulation commands"

<nitpick> commit ids should be 14(?) digits long these days.

Quoted 1 line

"Pat, I'd like to buy a vowel..." :D

--D

Quoted 26 lines
Quoted 26 lines
---
 db/crc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
db/crc.c +1 -1
index 95161c6df..b23417a11 100644
@@ -53,6 +53,7 @@ crc_f(
 	char		**argv)
 {
 	const struct xfs_buf_ops *stashed_ops = NULL;
+	struct xfs_buf_ops nowrite_ops;
 	extern char	*progname;
 	const field_t	*fields;
 	const ftattr_t	*fa;
@@ -127,7 +128,6 @@ crc_f(
 	}
 
 	if (invalidate) {
-		struct xfs_buf_ops nowrite_ops;
 		flist_t		*sfl;
 		int		bit_length;
 		int		parentoffset;
#3 lore raw
Quoted 7 lines · Darrick J. Wong
Quoted 6 lines · Eric Sandeen
Quoted 5 lines · Anthony Iliopoulos

The nowrite_ops var is declared within nested block scope but used outside that scope, causing xfs_db to crash while trying to defererence the verify_write pointer. Fix it by lifting the declaration to the outer scope, where it is accessed.

Quoted 7 lines
Quoted 5 lines
Quoted 1 line

Yup, thanks for spotting & fixing this.

Fixes b64af2c "xfs_db: add crc manipulation commands"

<nitpick> commit ids should be 14(?) digits long these days.

hm yeah I should fix that. (tho in xfsprogs probably less necessary)

Quoted 3 lines
Quoted 1 line

"Pat, I'd like to buy a vowel..." :D

sigh, you'd think I'd have hotkeys by now?