Skip to contentSkip to conversation

xfs_quota: avoid segfault when report -h on non-existent path

PATCH In review Eryu Guan 3 participants 3 messages Mar 18, 2014 – Mar 19, 2014

lore
Share & tools
lore

Eryu Guan

author
#0 lore raw

PATCH 1/1 xfs_quota: avoid segfault when report -h on non-existent path

Command xfs_quota -xc "report -h" /nosuchdir would get segfault, fix that by checking fs_path first before dereferencing it.

Cc Eric Sandeen <[email protected]>
---
 quota/report.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
quota/report.c +1 -1
index 70894a2..d486524 100644
@@ -624,7 +624,7 @@ report_f(
 		if (flags & ALL_MOUNTS_FLAG)
 			report_any_type(fp, form, type, NULL,
 					lower, upper, flags);
-		else if (fs_path->fs_flags & FS_MOUNT_POINT)
+		else if (fs_path && fs_path->fs_flags & FS_MOUNT_POINT)
 			report_any_type(fp, form, type, fs_path->fs_dir,
 					lower, upper, flags);
 	} else while (argc > optind) {
Signature · 6 lines
1.8.5.3

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
#1 lore raw
Quoted 15 lines · Eryu Guan

Command xfs_quota -xc "report -h" /nosuchdir would get segfault, fix that by checking fs_path first before dereferencing it.

Cc Eric Sandeen <[email protected]>
---
 quota/report.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
quota/report.c +0 -0
index 70894a2..d486524 100644

quota/report.c report_f( · line 630

Quoted 8 lines
quota/report.c +1 -1
@@ -624,7 +624,7 @@ report_f(
 		if (flags & ALL_MOUNTS_FLAG)
 			report_any_type(fp, form, type, NULL,
 					lower, upper, flags);
-		else if (fs_path->fs_flags & FS_MOUNT_POINT)
+		else if (fs_path && fs_path->fs_flags & FS_MOUNT_POINT)
 			report_any_type(fp, form, type, fs_path->fs_dir,
 					lower, upper, flags);
 	} else while (argc > optind) {

I think this is ok; state_f does the same thing.

but others don't; enable_f, disable_f, off_f etc.

Also this seems to be a slight regression since v3.1.8 or so, let me double check that and see if we need to fix something more general.

Thanks!
-Eric

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs

#2 lore raw
Quoted 27 lines · Eric Sandeen
Quoted 15 lines · Eryu Guan

Command xfs_quota -xc "report -h" /nosuchdir would get segfault, fix that by checking fs_path first before dereferencing it.

Cc Eric Sandeen <[email protected]>
---
 quota/report.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
quota/report.c +0 -0
index 70894a2..d486524 100644

quota/report.c report_f( · line 630

Quoted 8 lines
quota/report.c +1 -1
@@ -624,7 +624,7 @@ report_f(
 		if (flags & ALL_MOUNTS_FLAG)
 			report_any_type(fp, form, type, NULL,
 					lower, upper, flags);
-		else if (fs_path->fs_flags & FS_MOUNT_POINT)
+		else if (fs_path && fs_path->fs_flags & FS_MOUNT_POINT)
 			report_any_type(fp, form, type, fs_path->fs_dir,
 					lower, upper, flags);
 	} else while (argc > optind) {

I think this is ok; state_f does the same thing.

Quoted 4 lines

but others don't; enable_f, disable_f, off_f etc.

Also this seems to be a slight regression since v3.1.8 or so, let me double check that and see if we need to fix something more general.

I once posted a same patch a few months ago, Christoph pointed out a general solution at below link:
http://www.spinics.net/lists/xfs/msg23777.html

Thanks,
-Jeff

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs