Linux Test Project
 help / color / mirror / Atom feed
From: Jinseok Kim <always.starving0@gmail.com>
To: ltp@lists.linux.it
Subject: [LTP] [PATCH v1 2/2] fsx-linux: Fix op_max_size handling in op_file_position()
Date: Tue, 18 Aug 2026 00:40:45 +0900	[thread overview]
Message-ID: <20260817154048.3854-2-always.starving0@gmail.com> (raw)
In-Reply-To: <20260817154048.3854-1-always.starving0@gmail.com>

op_file_position() ignored op_max_size (-o option), causing operation
sizes to span up to the entire file size. Cap max_len with op_max_size
to honor the user option.

Signed-off-by: Jinseok Kim <always.starving0@gmail.com>
---
 testcases/kernel/fs/fsx-linux/fsx-linux.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/testcases/kernel/fs/fsx-linux/fsx-linux.c b/testcases/kernel/fs/fsx-linux/fsx-linux.c
index 21390c58c..81aca5dab 100644
--- a/testcases/kernel/fs/fsx-linux/fsx-linux.c
+++ b/testcases/kernel/fs/fsx-linux/fsx-linux.c
@@ -77,9 +77,15 @@ static void op_file_position(
 	struct file_pos_t *pos)
 {
 	long long diff;
+	long long max_len;

 	pos->offset = random() % fsize;
-	pos->size = random() % (fsize - pos->offset);
+
+	max_len = fsize - pos->offset;
+	if (max_len > op_max_size)
+		max_len = op_max_size;
+
+	pos->size = random() % max_len;

 	diff = pos->offset % align;

--
2.43.0

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

  reply	other threads:[~2026-08-17 15:41 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-17 15:40 [LTP] [PATCH v1 1/2] fsx-linux: Fix reference buffer corruption in op_map_read() Jinseok Kim
2026-08-17 15:40 ` Jinseok Kim [this message]
2026-08-17 16:29 ` [LTP] " linuxtestproject.agent

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260817154048.3854-2-always.starving0@gmail.com \
    --to=always.starving0@gmail.com \
    --cc=ltp@lists.linux.it \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox