mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 1/1] overlayfs: apply device cgroup and security permissions to overlay files
@ 2012-02-17 15:10 Andy Whitcroft
  2012-03-05 17:18 ` Miklos Szeredi
  0 siblings, 1 reply; 7+ messages in thread
From: Andy Whitcroft @ 2012-02-17 15:10 UTC (permalink / raw)
  To: Miklos Szeredi; +Cc: Andy Whitcroft, linux-fsdevel, linux-kernel, mszeredi

When checking permissions on an overlayfs inode we do not take into
account either device cgroup restrictions nor security permissions.
This allows a user to mount an overlayfs layer over a restricted device
directory and by pass those permissions to open otherwise restricted
files.

Use devcgroup_inode_permission() and security_inode_permission() against
the underlying inodes when calculating ovl_permission().

Signed-off-by: Andy Whitcroft <apw@canonical.com>
---
 fs/overlayfs/inode.c |    7 +++++++
 1 files changed, 7 insertions(+), 0 deletions(-)

	Not sure whether you saw this the first time round.  This was shown
	up in testing with containers, specifically with device cgroups.
	It seems we should be re-checking here else users can simply
	bypass the containers device permissions by mounting an overlayfs
	fs over them.

diff --git a/fs/overlayfs/inode.c b/fs/overlayfs/inode.c
index ba1a777..1145a76 100644
--- a/fs/overlayfs/inode.c
+++ b/fs/overlayfs/inode.c
@@ -10,6 +10,8 @@
 #include <linux/fs.h>
 #include <linux/slab.h>
 #include <linux/xattr.h>
+#include <linux/device_cgroup.h>
+#include <linux/security.h>
 #include "overlayfs.h"
 
 int ovl_setattr(struct dentry *dentry, struct iattr *attr)
@@ -118,6 +120,11 @@ int ovl_permission(struct inode *inode, int mask)
 		err = realinode->i_op->permission(realinode, mask);
 	else
 		err = generic_permission(realinode, mask);
+
+	if (!err)
+		err = devcgroup_inode_permission(realinode, mask);
+	if (!err)
+		err = security_inode_permission(realinode, mask);
 out_dput:
 	dput(alias);
 	return err;
-- 
1.7.9


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2012-04-29 15:03 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-02-17 15:10 [PATCH 1/1] overlayfs: apply device cgroup and security permissions to overlay files Andy Whitcroft
2012-03-05 17:18 ` Miklos Szeredi
2012-03-06 16:12   ` Andy Whitcroft
2012-03-06 16:18     ` [PATCH 1/2] inode_only_permission: export inode level permissions checks Andy Whitcroft
2012-03-06 16:18       ` [PATCH 2/2] overlayfs: switch to use inode_only_permissions Andy Whitcroft
2012-03-06 16:37       ` [PATCH 1/2] inode_only_permission: export inode level permissions checks Miklos Szeredi
2012-04-29 15:03     ` [PATCH 1/1] overlayfs: apply device cgroup and security permissions to overlay files Sedat Dilek

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome