mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@linux-foundation.org>
To: "Luís Henriques" <lhenriques@suse.de>
Cc: "Luís Henriques via Ocfs2-devel" <ocfs2-devel@oss.oracle.com>,
	"Mark Fasheh" <mark@fasheh.com>,
	"Joel Becker" <jlbec@evilplan.org>,
	"Joseph Qi" <joseph.qi@linux.alibaba.com>,
	"Heming Zhao" <heming.zhao@suse.com>,
	linux-kernel@vger.kernel.org
Subject: Re: [Ocfs2-devel] [PATCH] ocfs2: check new file size on fallocate call
Date: Wed, 31 May 2023 15:11:47 -0700	[thread overview]
Message-ID: <20230531151147.3d98aa2fb1d7f659bccef37b@linux-foundation.org> (raw)
In-Reply-To: <20230529152645.32680-1-lhenriques@suse.de>

On Mon, 29 May 2023 16:26:45 +0100 Luís Henriques via Ocfs2-devel <ocfs2-devel@oss.oracle.com> wrote:

> When changing a file size with fallocate() the new size isn't being
> checked.  In particular, the FSIZE ulimit isn't being checked, which makes
> fstest generic/228 fail.  Simply adding a call to inode_newsize_ok() fixes
> this issue.
> 
> ...
>
> --- a/fs/ocfs2/file.c
> +++ b/fs/ocfs2/file.c
> @@ -2100,14 +2100,20 @@ static long ocfs2_fallocate(struct file *file, int mode, loff_t offset,
>  	struct ocfs2_space_resv sr;
>  	int change_size = 1;
>  	int cmd = OCFS2_IOC_RESVSP64;
> +	int ret = 0;
>  
>  	if (mode & ~(FALLOC_FL_KEEP_SIZE | FALLOC_FL_PUNCH_HOLE))
>  		return -EOPNOTSUPP;
>  	if (!ocfs2_writes_unwritten_extents(osb))
>  		return -EOPNOTSUPP;
>  
> -	if (mode & FALLOC_FL_KEEP_SIZE)
> +	if (mode & FALLOC_FL_KEEP_SIZE) {
>  		change_size = 0;
> +	} else {
> +		ret = inode_newsize_ok(inode, offset + len);
> +		if (ret)
> +			return ret;
> +	}
>  

So userspace can exceed rlimit(RLIMIT_FSIZE).

Do we think this flaw is serious enough to justify backporting the fix
into earlier -stable kernels?


  parent reply	other threads:[~2023-05-31 22:12 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-29 15:26 Luís Henriques
2023-05-31  3:32 ` Mark Fasheh
2023-05-31  6:00 ` Joseph Qi
2023-05-31  8:29   ` Luís Henriques
2023-05-31  8:31     ` Joseph Qi
2023-05-31  8:32 ` Joseph Qi
2023-05-31 22:11 ` Andrew Morton [this message]
2023-06-01  1:23   ` [Ocfs2-devel] " Joseph Qi

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=20230531151147.3d98aa2fb1d7f659bccef37b@linux-foundation.org \
    --to=akpm@linux-foundation.org \
    --cc=heming.zhao@suse.com \
    --cc=jlbec@evilplan.org \
    --cc=joseph.qi@linux.alibaba.com \
    --cc=lhenriques@suse.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mark@fasheh.com \
    --cc=ocfs2-devel@oss.oracle.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®