From: Jan Kara <jack@suse.cz>
To: xfs@oss.sgi.com
Cc: Jan Kara <jack@suse.cz>
Subject: [PATCH] xfs: Correctly lock inode when removing suid and security marks
Date: Tue, 2 Dec 2014 16:01:29 +0100 [thread overview]
Message-ID: <1417532489-26580-1-git-send-email-jack@suse.cz> (raw)
Currently XFS calls file_remove_suid() without holding i_mutex. This is
wrong because that function can end up messing with file permissions and
security xattrs for which we need i_mutex held.
Fix the problem by grabbing iolock exclusively when we will need to
change anything in permissions / xattrs.
Signed-off-by: Jan Kara <jack@suse.cz>
---
fs/xfs/xfs_file.c | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/fs/xfs/xfs_file.c b/fs/xfs/xfs_file.c
index eb596b419942..ad6636ac4943 100644
--- a/fs/xfs/xfs_file.c
+++ b/fs/xfs/xfs_file.c
@@ -521,6 +521,18 @@ restart:
if (error)
return error;
+ /* For changing security info in file_remove_suid() we need i_mutex */
+ if (!IS_NOSEC(inode) && *iolock == XFS_IOLOCK_SHARED) {
+ struct dentry *dentry = file->f_path.dentry;
+
+ if (should_remove_suid(dentry) ||
+ security_inode_need_killpriv(dentry)) {
+ xfs_rw_iunlock(ip, *iolock);
+ *iolock = XFS_IOLOCK_EXCL;
+ xfs_rw_ilock(ip, *iolock);
+ goto restart;
+ }
+ }
/*
* If the offset is beyond the size of the file, we need to zero any
* blocks that fall between the existing EOF and the start of this
--
1.8.1.4
_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs
next reply other threads:[~2014-12-02 15:01 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-12-02 15:01 Jan Kara [this message]
2014-12-02 16:35 ` [PATCH] xfs: Correctly lock inode when removing suid and security marks Brian Foster
2014-12-02 20:47 ` Jan Kara
2014-12-02 21:59 ` Dave Chinner
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=1417532489-26580-1-git-send-email-jack@suse.cz \
--to=jack@suse.cz \
--cc=xfs@oss.sgi.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