linux-xfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Amir Goldstein <amir73il@gmail.com>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Sasha Levin <sashal@kernel.org>,
	"Darrick J . Wong" <djwong@kernel.org>,
	Leah Rumancik <leah.rumancik@gmail.com>,
	Chandan Babu R <chandan.babu@oracle.com>,
	Christian Brauner <brauner@kernel.org>,
	linux-fsdevel@vger.kernel.org, linux-xfs@vger.kernel.org,
	stable@vger.kernel.org, Dave Chinner <dchinner@redhat.com>
Subject: [PATCH 5.10 05/15] xfs: fallocate() should call file_modified()
Date: Sat, 18 Mar 2023 12:15:19 +0200	[thread overview]
Message-ID: <20230318101529.1361673-6-amir73il@gmail.com> (raw)
In-Reply-To: <20230318101529.1361673-1-amir73il@gmail.com>

From: Dave Chinner <dchinner@redhat.com>

commit fbe7e520036583a783b13ff9744e35c2a329d9a4 upstream.

In XFS, we always update the inode change and modification time when
any fallocate() operation succeeds.  Furthermore, as various
fallocate modes can change the file contents (extending EOF,
punching holes, zeroing things, shifting extents), we should drop
file privileges like suid just like we do for a regular write().
There's already a VFS helper that figures all this out for us, so
use that.

The net effect of this is that we no longer drop suid/sgid if the
caller is root, but we also now drop file capabilities.

We also move the xfs_update_prealloc_flags() function so that it now
is only called by the scope that needs to set the the prealloc flag.

Based on a patch from Darrick Wong.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Amir Goldstein <amir73il@gmail.com>
---
 fs/xfs/xfs_file.c | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/fs/xfs/xfs_file.c b/fs/xfs/xfs_file.c
index 630525b1da77..a95af57a59a7 100644
--- a/fs/xfs/xfs_file.c
+++ b/fs/xfs/xfs_file.c
@@ -895,6 +895,10 @@ xfs_file_fallocate(
 			goto out_unlock;
 	}
 
+	error = file_modified(file);
+	if (error)
+		goto out_unlock;
+
 	if (mode & FALLOC_FL_PUNCH_HOLE) {
 		error = xfs_free_file_space(ip, offset, len);
 		if (error)
@@ -996,11 +1000,12 @@ xfs_file_fallocate(
 			if (error)
 				goto out_unlock;
 		}
-	}
 
-	error = xfs_update_prealloc_flags(ip, flags);
-	if (error)
-		goto out_unlock;
+		error = xfs_update_prealloc_flags(ip, XFS_PREALLOC_SET);
+		if (error)
+			goto out_unlock;
+
+	}
 
 	/* Change file size if needed */
 	if (new_size) {
-- 
2.34.1


  parent reply	other threads:[~2023-03-18 10:15 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-18 10:15 [PATCH 5.10 00/15] xfs backports for 5.10.y (from v5.15.103) Amir Goldstein
2023-03-18 10:15 ` [PATCH 5.10 01/15] xfs: don't assert fail on perag references on teardown Amir Goldstein
2023-03-18 10:15 ` [PATCH 5.10 02/15] xfs: purge dquots after inode walk fails during quotacheck Amir Goldstein
2023-03-18 10:15 ` [PATCH 5.10 03/15] xfs: don't leak btree cursor when insrec fails after a split Amir Goldstein
2023-03-18 10:15 ` [PATCH 5.10 04/15] xfs: remove XFS_PREALLOC_SYNC Amir Goldstein
2023-03-18 10:15 ` Amir Goldstein [this message]
2023-03-18 10:15 ` [PATCH 5.10 06/15] xfs: set prealloc flag in xfs_alloc_file_space() Amir Goldstein
2023-03-18 10:15 ` [PATCH 5.10 07/15] xfs: use setattr_copy to set vfs inode attributes Amir Goldstein
2023-03-18 10:15 ` [PATCH 5.10 08/15] fs: add mode_strip_sgid() helper Amir Goldstein
2023-03-18 10:15 ` [PATCH 5.10 09/15] fs: move S_ISGID stripping into the vfs_*() helpers Amir Goldstein
2023-03-18 10:15 ` [PATCH 5.10 10/15] attr: add in_group_or_capable() Amir Goldstein
2023-03-18 10:15 ` [PATCH 5.10 11/15] fs: move should_remove_suid() Amir Goldstein
2023-03-18 10:15 ` [PATCH 5.10 12/15] attr: add setattr_should_drop_sgid() Amir Goldstein
2023-03-18 10:15 ` [PATCH 5.10 13/15] attr: use consistent sgid stripping checks Amir Goldstein
2023-03-18 10:15 ` [PATCH 5.10 14/15] fs: use consistent setgid checks in is_sxid() Amir Goldstein
2023-03-18 10:15 ` [PATCH 5.10 15/15] xfs: remove xfs_setattr_time() declaration Amir Goldstein
2023-03-20 14:13 ` [PATCH 5.10 00/15] xfs backports for 5.10.y (from v5.15.103) Greg Kroah-Hartman

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=20230318101529.1361673-6-amir73il@gmail.com \
    --to=amir73il@gmail.com \
    --cc=brauner@kernel.org \
    --cc=chandan.babu@oracle.com \
    --cc=dchinner@redhat.com \
    --cc=djwong@kernel.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=leah.rumancik@gmail.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-xfs@vger.kernel.org \
    --cc=sashal@kernel.org \
    --cc=stable@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).