From: Hungyu Lin <dennylin0707@gmail.com>
To: Namjae Jeon <linkinjeon@kernel.org>
Cc: Sungjong Seo <sj1557.seo@samsung.com>,
Yuezhang Mo <yuezhang.mo@sony.com>,
exfat@lists.linux.dev, linux-fsdevel@vger.kernel.org,
linux-kernel@vger.kernel.org, stable@vger.kernel.org,
Hungyu Lin <dennylin0707@gmail.com>
Subject: [PATCH] exfat: preserve the 64-bit FITRIM minimum length
Date: Sat, 31 Oct 2026 22:28:23 +0000 [thread overview]
Message-ID: <20261031222823.223-1-dennylin0707@gmail.com> (raw)
The FITRIM minimum length is a 64-bit value, but exfat_ioctl_fitrim()
uses max_t(unsigned int, ...) to compare it with the discard granularity.
This truncates the requested minimum on both 32-bit and 64-bit kernels.
For example, fstrim --minimum 4GiB can trim smaller free extents because
the minimum wraps to zero before being raised to the device granularity.
Use a u64 comparison to preserve the userspace value. exfat_trim_fs()
already stores the minimum cluster count in a u64.
Fixes: 654762df2ec7 ("exfat: add support ioctl and FITRIM function")
Cc: stable@vger.kernel.org
Signed-off-by: Hungyu Lin <dennylin0707@gmail.com>
---
fs/exfat/file.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/fs/exfat/file.c b/fs/exfat/file.c
index 1386149916bb..4e7a2fb30279 100644
--- a/fs/exfat/file.c
+++ b/fs/exfat/file.c
@@ -586,8 +586,8 @@ static int exfat_ioctl_fitrim(struct inode *inode, unsigned long arg)
if (copy_from_user(&range, (struct fstrim_range __user *)arg, sizeof(range)))
return -EFAULT;
- range.minlen = max_t(unsigned int, range.minlen,
- bdev_discard_granularity(inode->i_sb->s_bdev));
+ range.minlen = max_t(u64, range.minlen,
+ bdev_discard_granularity(inode->i_sb->s_bdev));
ret = exfat_trim_fs(inode, &range);
if (ret < 0)
--
2.43.0
next reply other threads:[~2026-10-31 22:28 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-31 22:28 Hungyu Lin [this message]
2026-11-01 2:14 ` Namjae Jeon
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=20261031222823.223-1-dennylin0707@gmail.com \
--to=dennylin0707@gmail.com \
--cc=exfat@lists.linux.dev \
--cc=linkinjeon@kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=sj1557.seo@samsung.com \
--cc=stable@vger.kernel.org \
--cc=yuezhang.mo@sony.com \
/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
all inboxes | Powered by JetHome®