diff mbox series

[02/40] lustre: lov: fiemap improperly handles fm_extent_count=0

Message ID 1681042400-15491-3-git-send-email-jsimmons@infradead.org (mailing list archive)
State New, archived
Headers show
Series lustre: backport OpenSFS changes from March XX, 2023 | expand

Commit Message

James Simmons April 9, 2023, 12:12 p.m. UTC
From: Andrew Perepechko <andrew.perepechko@hpe.com>

FIEMAP calls with fm_extent_count=0 are supposed only to
return the number of extents.

lov_object_fiemap() attempts to initialize stripe_last
based on fiemap->fm_extents[0] which is not initialized
in userspace and not even allocated in kernelspace.

Eventually, the call exits with -EINVAL and "FIEMAP does
not init start entry" kernel log message.

Fixes: f39704f6e1 ("lustre: lov: FIEMAP support for PFL and FLR file")
HPE-bug-id: LUS-11443
WC-bug-id: https://jira.whamcloud.com/browse/LU-16480
Lustre-commit: 829af7b029d8e4e39 ("LU-16480 lov: fiemap improperly handles fm_extent_count=0")
Signed-off-by: Andrew Perepechko <andrew.perepechko@hpe.com>
Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/49645
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: Alexander Boyko <alexander.boyko@hpe.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
Signed-off-by: James Simmons <jsimmons@infradead.org>
---
 fs/lustre/lov/lov_object.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
diff mbox series

Patch

diff --git a/fs/lustre/lov/lov_object.c b/fs/lustre/lov/lov_object.c
index 34cb6a0..5d65aab 100644
--- a/fs/lustre/lov/lov_object.c
+++ b/fs/lustre/lov/lov_object.c
@@ -1896,7 +1896,7 @@  static int lov_object_fiemap(const struct lu_env *env, struct cl_object *obj,
 	struct fiemap_state fs = { NULL };
 	struct lu_extent range;
 	int cur_ext;
-	int stripe_last;
+	int stripe_last = 0;
 	int start_stripe = 0;
 	bool resume = false;
 
@@ -1992,9 +1992,10 @@  static int lov_object_fiemap(const struct lu_env *env, struct cl_object *obj,
 	 * the high 16bits of fe_device remember which stripe the last
 	 * call has been arrived, we'd continue from there in this call.
 	 */
-	if (fiemap->fm_extent_count && fiemap->fm_extents[0].fe_logical)
+	if (fiemap->fm_extent_count && fiemap->fm_extents[0].fe_logical) {
 		resume = true;
-	stripe_last = get_fe_stripenr(&fiemap->fm_extents[0]);
+		stripe_last = get_fe_stripenr(&fiemap->fm_extents[0]);
+	}
 	/**
 	 * stripe_last records stripe number we've been processed in the last
 	 * call