2005-02-04 18:20:30

by Stephen Smalley

[permalink] [raw]
Subject: [PATCH][SELINUX] Fix selinux_inode_setattr hook

This patch against 2.6.11-rc3 fixes the selinux_inode_setattr hook
function to honor the ATTR_FORCE flag, skipping any permission checking
in that case. Otherwise, it is possible though unlikely for a denial
from the hook to prevent proper updating, e.g. for remove_suid upon
writing to a file. This would only occur if the process had write
permission to a suid file but lacked setattr permission to it. Please
apply.

Signed-off-by: Stephen Smalley <[email protected]>
Signed-off-by: James Morris <[email protected]>

security/selinux/hooks.c | 3 +++
1 files changed, 3 insertions(+)

Index: linux-2.6/security/selinux/hooks.c
===================================================================
RCS file: /nfshome/pal/CVS/linux-2.6/security/selinux/hooks.c,v
retrieving revision 1.150
diff -u -p -r1.150 hooks.c
--- linux-2.6/security/selinux/hooks.c 26 Jan 2005 21:20:59 -0000 1.150
+++ linux-2.6/security/selinux/hooks.c 4 Feb 2005 16:39:23 -0000
@@ -2142,6 +2142,9 @@ static int selinux_inode_setattr(struct
if (rc)
return rc;

+ if (iattr->ia_valid & ATTR_FORCE)
+ return 0;
+
if (iattr->ia_valid & (ATTR_MODE | ATTR_UID | ATTR_GID |
ATTR_ATIME_SET | ATTR_MTIME_SET))
return dentry_has_perm(current, NULL, dentry, FILE__SETATTR);


--
Stephen Smalley <[email protected]>
National Security Agency


2005-02-04 18:30:26

by Chris Wright

[permalink] [raw]
Subject: Re: [PATCH][SELINUX] Fix selinux_inode_setattr hook

* Stephen Smalley ([email protected]) wrote:
> On Fri, 2005-02-04 at 13:14, Chris Wright wrote:
> > * Stephen Smalley ([email protected]) wrote:
> > > This patch against 2.6.11-rc3 fixes the selinux_inode_setattr hook
> > > function to honor the ATTR_FORCE flag, skipping any permission checking
> > > in that case. Otherwise, it is possible though unlikely for a denial
> > > from the hook to prevent proper updating, e.g. for remove_suid upon
> > > writing to a file. This would only occur if the process had write
> > > permission to a suid file but lacked setattr permission to it. Please
> > > apply.
> >
> > Is there any reason not to promote this to the framework?
>
> I wasn't sure if a security module might still want to be notified of
> forced changes (e.g. to adjust some state in its own security
> structure), even if it skips permission checking on such changes.

OK, let's go with your patch for now.

thanks,
-chris
--
Linux Security Modules http://lsm.immunix.org http://lsm.bkbits.net

2005-02-04 18:24:34

by Stephen Smalley

[permalink] [raw]
Subject: Re: [PATCH][SELINUX] Fix selinux_inode_setattr hook

On Fri, 2005-02-04 at 13:14, Chris Wright wrote:
> * Stephen Smalley ([email protected]) wrote:
> > This patch against 2.6.11-rc3 fixes the selinux_inode_setattr hook
> > function to honor the ATTR_FORCE flag, skipping any permission checking
> > in that case. Otherwise, it is possible though unlikely for a denial
> > from the hook to prevent proper updating, e.g. for remove_suid upon
> > writing to a file. This would only occur if the process had write
> > permission to a suid file but lacked setattr permission to it. Please
> > apply.
>
> Is there any reason not to promote this to the framework?

I wasn't sure if a security module might still want to be notified of
forced changes (e.g. to adjust some state in its own security
structure), even if it skips permission checking on such changes.

--
Stephen Smalley <[email protected]>
National Security Agency

2005-02-04 19:04:51

by Chris Wright

[permalink] [raw]
Subject: Re: [PATCH][SELINUX] Fix selinux_inode_setattr hook

* Stephen Smalley ([email protected]) wrote:
> This patch against 2.6.11-rc3 fixes the selinux_inode_setattr hook
> function to honor the ATTR_FORCE flag, skipping any permission checking
> in that case. Otherwise, it is possible though unlikely for a denial
> from the hook to prevent proper updating, e.g. for remove_suid upon
> writing to a file. This would only occur if the process had write
> permission to a suid file but lacked setattr permission to it. Please
> apply.

Is there any reason not to promote this to the framework?

thanks,
-chris
--
Linux Security Modules http://lsm.immunix.org http://lsm.bkbits.net