linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jan Kara <jack@suse.cz>
To: Al Viro <viro@ZenIV.linux.org.uk>
Cc: linux-fsdevel@vger.kernel.org,
	Andreas Gruenbacher <agruenba@redhat.com>,
	Jan Kara <jack@suse.cz>
Subject: [PATCH 2/2] posix_acl: Clear SGID bit when modifying file permissions
Date: Thu, 26 May 2016 17:02:48 +0200	[thread overview]
Message-ID: <1464274968-31182-2-git-send-email-jack@suse.cz> (raw)
In-Reply-To: <1464274968-31182-1-git-send-email-jack@suse.cz>

When file permissions are modified via chmod(2) and the user modifying the
permissions is not capable of setting SGID bit for the file, the bit gets
cleared in inode_change_ok(). However this is not the case when file
permissions get modified via setfacl(1). Add clearing of SGID bit to
posix_acl_equiv_mode().

Signed-off-by: Jan Kara <jack@suse.cz>
---
 fs/posix_acl.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/fs/posix_acl.c b/fs/posix_acl.c
index 0a7c5119ed8d..d714b9216418 100644
--- a/fs/posix_acl.c
+++ b/fs/posix_acl.c
@@ -311,8 +311,12 @@ posix_acl_equiv_mode(struct inode *inode, const struct posix_acl *acl,
 				return -EINVAL;
 		}
 	}
-        if (mode_p)
+        if (mode_p) {
+		if (!in_group_p(inode->i_gid) &&
+		    !capable_wrt_inode_uidgid(inode, CAP_FSETID))
+			*mode_p &= ~S_ISGID;
                 *mode_p = (*mode_p & ~S_IRWXUGO) | mode;
+	}
         return not_equiv;
 }
 EXPORT_SYMBOL(posix_acl_equiv_mode);
-- 
2.6.6


  reply	other threads:[~2016-05-26 15:02 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-05-26 15:02 [PATCH 1/2] posix_acl: Add inode parameter to posix_acl_equiv_mode() Jan Kara
2016-05-26 15:02 ` Jan Kara [this message]
2016-05-26 21:53   ` [PATCH 2/2] posix_acl: Clear SGID bit when modifying file permissions Andreas Grünbacher

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=1464274968-31182-2-git-send-email-jack@suse.cz \
    --to=jack@suse.cz \
    --cc=agruenba@redhat.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=viro@ZenIV.linux.org.uk \
    /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).