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] [day] [month] [year] [list]
Message-Id: <1204896274.1397.403.camel@moss-spartans.epoch.ncsc.mil>
Date:	Fri, 07 Mar 2008 08:24:34 -0500
From:	Stephen Smalley <sds@...ho.nsa.gov>
To:	Pavel Emelyanov <xemul@...nvz.org>
Cc:	Andrew Morton <akpm@...ux-foundation.org>,
	David Miller <davem@...emloft.net>,
	Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
	Linux Netdev List <netdev@...r.kernel.org>,
	"Eric W. Biederman" <ebiederm@...ssion.com>,
	"Paul E. McKenney" <paulmck@...ux.vnet.ibm.com>,
	James Morris <jmorris@...ei.org>,
	Eric Paris <eparis@...isplace.org>
Subject: Re: [PATCH] Make /proc/net a symlink on /proc/self/net (v2)


On Fri, 2008-03-07 at 15:03 +0300, Pavel Emelyanov wrote:
> [snip]
> 
> >>> Does this break SELinux labeling of /proc/net inodes and thus its access
> >>> controls on them?
> >> It should not, since the proc_dir_etries are still organized in
> >> a required hierarchy.
> > 
> > Unfortunately, it does break selinux labeling of /proc/net inodes.
> > Easily seen by running ls -ZR /proc/net before and after the patch is
> > applied and comparing the results.  
> > 
> > Also, as a separate issue, a "find /proc/self/net ..." will show that
> > the hard link count is wrong for it.
> 
> Oops... I've checked this thing explicitly before sending, but it looks
> like I used too old find version. I.e. 4.1.20 worked OK, but 4.2.23
> reported the nlink discrepancy.
> 
> Anyway, this is fixed now (see below). I override the getattr method for
> /proc/net directory and update one from the net->proc_net entry, which 
> is calculated correctly.
> 
> > Currently the inodes get labeled by selinux_proc_get_sid() by walking up
> > the proc_dir_entry tree to generate a name and prefix matching that name
> > in policy.  Before the patch, we'd get names like "//net/tcp", i.e.
> > relative to the root of proc (the extra leading slash is due to the
> > earlier proc net rewrite which also broke selinux until we adjusted it
> > to ignore it).  After the patch, we just get "//tcp", which is ambiguous
> > since we would also get that for a /proc/tcp inode if one existed.
> 
> OK, got it. Is it good if we used to get the //net/tcp, but will /net/tcp
> (without the double slash)? The patch below does exactly this. It initializes
> the name for the net->proc_net entry and makes its parent be proc_root.
> 
> Can you Ack this patch, so that I can merge it with the original one and 
> re-post the combined v3?

Thanks, ls -ZR /proc/net now yields the same output before and after the
patch.

Acked-by:  Stephen Smalley <sds@...ho.nsa.gov>

> 
> > Not trying to obstruct your proc net improvements, but just want to make
> > sure that selinux doesn't get broken in the process.
> 
> diff --git a/fs/proc/proc_net.c b/fs/proc/proc_net.c
> index 18d413c..4caa5f7 100644
> --- a/fs/proc/proc_net.c
> +++ b/fs/proc/proc_net.c
> @@ -96,8 +96,27 @@ static struct dentry *proc_tgid_net_lookup(struct inode *dir,
>  	return de;
>  }
>  
> +static int proc_tgid_net_getattr(struct vfsmount *mnt, struct dentry *dentry,
> +		struct kstat *stat)
> +{
> +	struct inode *inode = dentry->d_inode;
> +	struct net *net;
> +
> +	net = get_proc_task_net(inode);
> +
> +	generic_fillattr(inode, stat);
> +
> +	if (net != NULL) {
> +		stat->nlink = net->proc_net->nlink;
> +		put_net(net);
> +	}
> +
> +	return 0;
> +}
> +
>  const struct inode_operations proc_net_inode_operations = {
>  	.lookup		= proc_tgid_net_lookup,
> +	.getattr	= proc_tgid_net_getattr,
>  };
>  
>  static int proc_tgid_net_readdir(struct file *filp, void *dirent,
> @@ -162,6 +181,10 @@ static __net_init int proc_net_ns_init(struct net *net)
>  		goto out;
>  
>  	netd->data = net;
> +	netd->nlink = 2;
> +	netd->name = "net";
> +	netd->namelen = 3;
> +	netd->parent = &proc_root;
>  
>  	err = -EEXIST;
>  	net_statd = proc_net_mkdir(net, "stat", netd);
-- 
Stephen Smalley
National Security Agency

--
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