linux-xfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Christoph Hellwig <hch@infradead.org>
To: Eryu Guan <eguan@redhat.com>
Cc: linux-xfs@vger.kernel.org
Subject: Re: [PATCH] xfs: use xfs_vn_setattr_size to check on new size
Date: Thu, 1 Dec 2016 02:26:35 -0800	[thread overview]
Message-ID: <20161201102635.GA23215@infradead.org> (raw)
In-Reply-To: <20161201101800.11419-1-eguan@redhat.com>

On Thu, Dec 01, 2016 at 06:18:00PM +0800, Eryu Guan wrote:
> Commit 6552321831dc ("xfs: remove i_iolock and use i_rwsem in the
> VFS inode instead") introduced a regression that truncate(2) doesn't
> check on new size, so it succeeds even if the new size exceeds the
> current resource limit. Because xfs_setattr_size() was used instead
> of xfs_vn_setattr_size(), and the latter calls xfs_vn_change_ok()
> first to do sanity check on permission and new size.

Oops, looks like this was a merge error..

> 
> This is found by truncate03 test from ltp, and the following is a
> simplified reproducer:
> 
>   #!/bin/bash
>   dev=/dev/sda5
>   mnt=/mnt/xfs
> 
>   mkfs -t xfs -f $dev
>   mount $dev $mnt
> 
>   # set max file size to 16k
>   ulimit -f 16
>   truncate -s $((16 * 1024 + 1)) /mnt/xfs/testfile
>   [ $? -eq 0 ] && echo "FAIL: truncate exceeded max file size"
>   ulimit -f unlimited
>   umount $mnt

Can you add this to xfstests?

The patch looks good:

Reviewed-by: Christoph Hellwig <hch@lst.de>

  reply	other threads:[~2016-12-01 10:26 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-12-01 10:18 [PATCH] xfs: use xfs_vn_setattr_size to check on new size Eryu Guan
2016-12-01 10:26 ` Christoph Hellwig [this message]
2016-12-01 10:29   ` Eryu Guan

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=20161201102635.GA23215@infradead.org \
    --to=hch@infradead.org \
    --cc=eguan@redhat.com \
    --cc=linux-xfs@vger.kernel.org \
    /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;
as well as URLs for NNTP newsgroup(s).