Return-Path: Received: from mail-wi0-f175.google.com ([209.85.212.175]:33891 "EHLO mail-wi0-f175.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752816AbbG0IWR (ORCPT ); Mon, 27 Jul 2015 04:22:17 -0400 Received: by wibud3 with SMTP id ud3so129352689wib.1 for ; Mon, 27 Jul 2015 01:22:16 -0700 (PDT) Received: from ?IPv6:2a01:4240:53f0:43fb::cbb? (b.b.c.0.0.0.0.0.0.0.0.0.0.0.0.0.b.f.3.4.0.f.3.5.0.4.2.4.1.0.a.2.v6.cust.nbox.cz. [2a01:4240:53f0:43fb::cbb]) by smtp.gmail.com with ESMTPSA id dl10sm26519721wjb.42.2015.07.27.01.22.15 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 27 Jul 2015 01:22:16 -0700 (PDT) From: "Jiri Slaby" To: Cc: "Jan Kara" , "Al Viro" Subject: [patch added to the 3.12 stable tree] fs: Fix S_NOSEC handling Date: Mon, 27 Jul 2015 10:02:09 +0200 Message-Id: <1437984150-15702-28-git-send-email-jslaby@suse.com> In-Reply-To: <1437984150-15702-1-git-send-email-jslaby@suse.com> References: <1437984150-15702-1-git-send-email-jslaby@suse.com> Sender: stable-owner@vger.kernel.org List-ID: From: Jan Kara This patch has been added to the 3.12 stable tree. If you have any objections, please let us know. =============== commit 2426f3910069ed47c0cc58559a6d088af7920201 upstream. 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. Signed-off-by: Jan Kara Signed-off-by: Al Viro Signed-off-by: Jiri Slaby --- fs/inode.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fs/inode.c b/fs/inode.c index d9134a0f5dd9..9ec57cb0aacd 100644 --- a/fs/inode.c +++ b/fs/inode.c @@ -1599,8 +1599,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)) - inode->i_flags |= S_NOSEC; + if (!error) + inode_has_no_xattr(inode); return error; } -- 2.4.6