public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Jay Miller <jnmiller@colorado.edu>
To: linux-kernel <linux-kernel@vger.kernel.org>
Subject: [PATCH] inode_change_ok() grpid bug?
Date: Wed, 7 Feb 2001 13:19:08 -0700	[thread overview]
Message-ID: <20010207131908.A26338@cryptofreak.org> (raw)

I think I found a reælly minor problem..

* 'chmod g+s foo' when I am not in foo's group does nothing. (no error)
* 'chmod g-s foo' when I am not in foo's group turns off the GID bit.

This seems like inconsistent/wrong behavior.  It apparently stems from the
fact that if there is a group mismatch between the current process and the
inode, inode_change_ok() and inode_setattr() just turn S_ISGID off, as they
have no way of knowing the original state of the bit.

My lame suggestions (to 2.4.1) are below - I apologize if this is old news
or in fact correct behavior.

-- 
Jay Miller

diff -urN linux/fs/attr.c linux-j/fs/attr.c
--- linux/fs/attr.c     Mon Oct 16 14:00:53 2000
+++ linux-j/fs/attr.c   Wed Feb  7 13:10:06 2001
@@ -43,7 +43,7 @@
                /* Also check the setgid bit! */
                if (!in_group_p((ia_valid & ATTR_GID) ? attr->ia_gid :
                                inode->i_gid) && !capable(CAP_FSETID))
-                       attr->ia_mode &= ~S_ISGID;
+                       goto error;
        }
 
        /* Check for setting the inode time. */
@@ -73,11 +73,8 @@
                inode->i_mtime = attr->ia_mtime;
        if (ia_valid & ATTR_CTIME)
                inode->i_ctime = attr->ia_ctime;
-       if (ia_valid & ATTR_MODE) {
+       if (ia_valid & ATTR_MODE)
                inode->i_mode = attr->ia_mode;
-               if (!in_group_p(inode->i_gid) && !capable(CAP_FSETID))
-                       inode->i_mode &= ~S_ISGID;
-       }
        mark_inode_dirty(inode);
 }

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
Please read the FAQ at http://www.tux.org/lkml/

                 reply	other threads:[~2001-02-07 20:19 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20010207131908.A26338@cryptofreak.org \
    --to=jnmiller@colorado.edu \
    --cc=linux-kernel@vger.kernel.org \
    /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