From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jan Kara Subject: [PATCH 1/5] fs: Fix S_NOSEC handling Date: Thu, 18 Dec 2014 13:49:02 +0100 Message-ID: <1418906946-30695-2-git-send-email-jack@suse.cz> References: <1418906946-30695-1-git-send-email-jack@suse.cz> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Cc: linux-fsdevel@vger.kernel.org, linux-security-module@vger.kernel.org, Jan Kara , stable@vger.kernel.org, xfs@oss.sgi.com To: Al Viro Return-path: In-Reply-To: <1418906946-30695-1-git-send-email-jack@suse.cz> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: xfs-bounces@oss.sgi.com Sender: xfs-bounces@oss.sgi.com List-Id: linux-fsdevel.vger.kernel.org file_remove_suid() could mistakenly set S_NOSEC inode bit when root was modifying the file. As a result following writes to the file by ordinary user would avoid clearing suid or sgid bits. Fix the bug by checking actual mode bits before setting S_NOSEC. CC: stable@vger.kernel.org Signed-off-by: Jan Kara --- fs/inode.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/fs/inode.c b/fs/inode.c index 26753ba7b6d6..f5e01704a5c8 100644 --- a/fs/inode.c +++ b/fs/inode.c @@ -1631,7 +1631,8 @@ int file_remove_suid(struct file *file) error = security_inode_killpriv(dentry); if (!error && killsuid) error = __remove_suid(dentry, killsuid); - if (!error && (inode->i_sb->s_flags & MS_NOSEC)) + if (!error && (inode->i_sb->s_flags & MS_NOSEC) && + !is_sxid(inode->i_mode)) inode->i_flags |= S_NOSEC; return error; -- 1.8.4.5 _______________________________________________ xfs mailing list xfs@oss.sgi.com http://oss.sgi.com/mailman/listinfo/xfs