From patchwork Tue May 19 09:46:39 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Kara X-Patchwork-Id: 6435571 Return-Path: X-Original-To: patchwork-linux-fsdevel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 294B9C0432 for ; Tue, 19 May 2015 09:47:29 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 5AA952047C for ; Tue, 19 May 2015 09:47:28 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 75CE32021A for ; Tue, 19 May 2015 09:47:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932520AbbESJrO (ORCPT ); Tue, 19 May 2015 05:47:14 -0400 Received: from cantor2.suse.de ([195.135.220.15]:55827 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932447AbbESJrA (ORCPT ); Tue, 19 May 2015 05:47:00 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 4283FAD24; Tue, 19 May 2015 09:46:58 +0000 (UTC) Received: by quack.suse.cz (Postfix, from userid 1000) id 78E808281D; Tue, 19 May 2015 11:46:54 +0200 (CEST) From: Jan Kara To: Al Viro Cc: Linus Torvalds , linux-fsdevel@vger.kernel.org, dchinner@redhat.com, Serge Hallyn , linux-security-module@vger.kernel.org, Jan Kara , stable@vger.kernel.org Subject: [PATCH 1/5] fs: Fix S_NOSEC handling Date: Tue, 19 May 2015 11:46:39 +0200 Message-Id: <1432028803-32296-2-git-send-email-jack@suse.cz> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1432028803-32296-1-git-send-email-jack@suse.cz> References: <1432028803-32296-1-git-send-email-jack@suse.cz> Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fs/inode.c b/fs/inode.c index ea37cd17b53f..6e342cadef81 100644 --- a/fs/inode.c +++ b/fs/inode.c @@ -1693,8 +1693,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; }