lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Thu, 5 Mar 2015 11:13:26 -0600
From:	"Serge E. Hallyn" <serge@...lyn.com>
To:	Christoph Lameter <cl@...ux.com>
Cc:	"Serge E. Hallyn" <serge@...lyn.com>,
	Serge Hallyn <serge.hallyn@...onical.com>,
	Andy Lutomirski <luto@...capital.net>,
	Jonathan Corbet <corbet@....net>,
	Aaron Jones <aaronmdjones@...il.com>,
	linux-security-module@...r.kernel.org,
	linux-kernel@...r.kernel.org, akpm@...uxfoundation.org,
	"Andrew G. Morgan" <morgan@...nel.org>,
	Mimi Zohar <zohar@...ux.vnet.ibm.com>,
	Austin S Hemmelgarn <ahferroin7@...il.com>,
	Markku Savela <msa@...h.iki.fi>,
	Jarkko Sakkinen <jarkko.sakkinen@...ux.intel.com>,
	linux-api@...r.kernel.org, Michael Kerrisk <mtk.manpages@...il.com>
Subject: Re: [PATCH] capabilities: Ambient capability set V2

On Thu, Mar 05, 2015 at 09:26:24AM -0600, Christoph Lameter wrote:
> On Sun, 1 Mar 2015, Serge E. Hallyn wrote:
> 
> > > +++ linux/security/commoncap.c	2015-02-26 16:10:02.347913397 -0600
> > > @@ -347,15 +347,17 @@ static inline int bprm_caps_from_vfs_cap
> > >  		*has_cap = true;
> > >
> > >  	CAP_FOR_EACH_U32(i) {
> > > +		__u32 ambient = current_cred()->cap_ambient.cap[i];
> > >  		__u32 permitted = caps->permitted.cap[i];
> > >  		__u32 inheritable = caps->inheritable.cap[i];
> > >
> > >  		/*
> > > -		 * pP' = (X & fP) | (pI & fI)
> > > +		 * pP' = (X & fP) | (pI & (fI | pA))
> > >  		 */
> > >  		new->cap_permitted.cap[i] =
> > >  			(new->cap_bset.cap[i] & permitted) |
> > > -			(new->cap_inheritable.cap[i] & inheritable);
> > > +			(new->cap_inheritable.cap[i] &
> > > +					(inheritable | ambient));
> >
> > So I'd say drop this change ^
> 
> Then the ambient caps get ignored for a executables that have capabilities
> seton the file?

Yes.  Those are assumed to already know what they're doing.

> I think we need to keep this one.

Why?  Do you foresee cases where a file that has fP set needs capabilities
that aren't in its fP?

It seems more likely that they'll risk misbehaving due to an unexpected set 
of caps.

If you have a good use case I'm not entirely opposed, but it just seems
unneeded and a potentially bad idea.

> > > @@ -453,8 +455,18 @@ static int get_file_caps(struct linux_bi
> > >  		if (rc == -EINVAL)
> > >  			printk(KERN_NOTICE "%s: get_vfs_caps_from_disk returned %d for %s\n",
> > >  				__func__, rc, bprm->filename);
> > > -		else if (rc == -ENODATA)
> > > +		else if (rc == -ENODATA) {
> > >  			rc = 0;
> > > +			if (!cap_isclear(current_cred()->cap_ambient)) {
> > > +				/*
> > > +				 * The ambient caps are permitted for
> > > +				 * files that have no caps
> > > +				 */
> > > +				bprm->cred->cap_permitted =
> > > +					current_cred()->cap_ambient;
> >
> > and here set vcaps inheritable to current_cred()->ambient.
> 
> We do not call bprm_caps_from_vfs_cap() for files that have no caps so
> this would have no effect. But we could set cap_inheritable here?
> 
> Fixup patch:
> 
> 
> 
> Subject: ambient_caps: Set inheritable bits too
> 
> We were not setting the inheritable bits as they ought to be set.
> 
> Signed-off-by: Christoph Lameter <cl@...ux.com>
> 
> Index: linux/security/commoncap.c
> ===================================================================
> --- linux.orig/security/commoncap.c	2015-03-05 09:22:32.123047869 -0600
> +++ linux/security/commoncap.c	2015-03-05 09:22:32.119048001 -0600
> @@ -461,6 +461,8 @@ static int get_file_caps(struct linux_bi
>  				 */
>  				bprm->cred->cap_permitted =
>  					current_cred()->cap_ambient;
> +				bprm->cred->cap_inheritable =
> +					current_cred()->cap_ambient;
>  				*effective = true;
>  			}
>  		}
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ