mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Damien Le Moal <dlemoal@kernel.org>
To: Ding Feng <dingf3ng@gmail.com>,
	viro@zeniv.linux.org.uk, brauner@kernel.org
Cc: jack@suse.cz, linux-fsdevel@vger.kernel.org,
	linux-kernel@vger.kernel.org, naohiro.aota@wdc.com,
	jth@kernel.org, stable@vger.kernel.org
Subject: Re: [PATCH 2/2] zonefs: ignore RLIMIT_FSIZE above LLONG_MAX in zonefs_write_check_limits()
Date: Wed, 18 Nov 2026 16:44:19 -0800	[thread overview]
Message-ID: <88ec005a-db15-4710-a527-0a270b138aa6@kernel.org> (raw)
In-Reply-To: <20261117173129.61028-3-dingf3ng@gmail.com>

On 2026/11/17 9:31, Ding Feng wrote:
> 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>
> ---
>  fs/zonefs/file.c | 9 +++++----
>  1 file changed, 5 insertions(+), 4 deletions(-)
> 
> diff --git a/fs/zonefs/file.c b/fs/zonefs/file.c
> index 319d950..ea9582e 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);
> +	unsigned long 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) {

As the kernel test robot pointed out, limit <= LLONG_MAX is always true on
32-bits arch because limit is an unsigned long. So we need limit to be an
unsigned long long I think. Same thing on patch 1.

I am pulling this patch until this is fixed.

> +		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))


-- 
Damien Le Moal
Western Digital Research

      parent reply	other threads:[~2026-11-19  0:44 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-17 17:31 [PATCH 0/2] fs, zonefs: ignore RLIMIT_FSIZE values above LLONG_MAX Ding Feng
2026-11-17 17:31 ` [PATCH 1/2] fs: ignore RLIMIT_FSIZE above LLONG_MAX in generic_write_check_limits() Ding Feng
2026-11-18 13:53   ` (subset) " Christian Brauner
2026-11-18 14:18   ` Jan Kara
2026-11-17 17:31 ` [PATCH 2/2] zonefs: ignore RLIMIT_FSIZE above LLONG_MAX in zonefs_write_check_limits() Ding Feng
2026-11-18 19:30   ` Damien Le Moal
2026-11-19  0:44   ` Damien Le Moal [this message]

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=88ec005a-db15-4710-a527-0a270b138aa6@kernel.org \
    --to=dlemoal@kernel.org \
    --cc=brauner@kernel.org \
    --cc=dingf3ng@gmail.com \
    --cc=jack@suse.cz \
    --cc=jth@kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=naohiro.aota@wdc.com \
    --cc=stable@vger.kernel.org \
    --cc=viro@zeniv.linux.org.uk \
    /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®