Commit fb5289b697c9 for kernel

commit fb5289b697c965581104bafdd875b969a1db3e79
Author: Ding Feng <dingf3ng@gmail.com>
Date:   Thu Nov 19 11:10:26 2026 +0800

    zonefs: ignore RLIMIT_FSIZE above LLONG_MAX in zonefs_write_check_limits()

    zonefs_write_check_limits() follows generic_write_check_limits() and
    has the same problem: it stores rlimit(RLIMIT_FSIZE), an unsigned long,
    in a loff_t, so a soft limit between 2^63 and RLIM_INFINITY is negative
    and every write fails with -EFBIG and raises SIGXFSZ.

    Keep the limit unsigned and apply it only when it is at most LLONG_MAX,
    as the generic helper now does.

    Fixes: ebfd68cd0c1e ("zonefs: Fix O_APPEND async write handling")
    Cc: stable@vger.kernel.org
    Assisted-by: Claude:claude-opus-5-5 Frama-C
    Signed-off-by: Ding Feng <dingf3ng@gmail.com>
    Signed-off-by: Damien Le Moal <dlemoal@kernel.org>

diff --git a/fs/zonefs/file.c b/fs/zonefs/file.c
index 319d9502ba56..c9293e35d690 100644
--- a/fs/zonefs/file.c
+++ b/fs/zonefs/file.c
@@ -399,15 +399,16 @@ static loff_t zonefs_write_check_limits(struct file *file, loff_t pos,
 {
 	struct inode *inode = file_inode(file);
 	struct zonefs_zone *z = zonefs_inode_zone(inode);
-	loff_t limit = rlimit(RLIMIT_FSIZE);
+	u64 limit = rlimit(RLIMIT_FSIZE);
 	loff_t max_size = z->z_capacity;

-	if (limit != RLIM_INFINITY) {
-		if (pos >= limit) {
+	/* No file position reaches a limit above LLONG_MAX. */
+	if (limit != RLIM_INFINITY && limit <= LLONG_MAX) {
+		if (pos >= (loff_t)limit) {
 			send_sig(SIGXFSZ, current, 0);
 			return -EFBIG;
 		}
-		count = min(count, limit - pos);
+		count = min(count, (loff_t)limit - pos);
 	}

 	if (!(file->f_flags & O_LARGEFILE))