Skip to contentSkip to conversation

2.6.31: access permission filesystem 0.23

PATCH New Olaf Dietsche 1 participant 1 message Oct 4, 2009

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 2.6.31: access permission filesystem 0.23

This *untested* patch adds a new permission managing file system. Furthermore, it adds two modules, which make use of this file system.

One module allows granting capabilities based on user-/groupid. The second module allows to grant access to lower numbered ports based on user-/groupid, too.

Changes:
- updated to 2.6.31

This patch is available at:
<http://www.olafdietsche.de/linux/accessfs/>

and attached inline below.

Regards, Olaf.

 Documentation/filesystems/accessfs.txt |   41 +++
 fs/Kconfig                             |    1 
 fs/Makefile                            |    1 
 fs/accessfs/Kconfig                    |   64 ++++
 fs/accessfs/Makefile                   |   11 
 fs/accessfs/capabilities.c             |  107 ++++++++
 fs/accessfs/inode.c                    |  434 +++++++++++++++++++++++++++++++++
 fs/accessfs/ip.c                       |  101 +++++++
 include/linux/accessfs_fs.h            |   42 +++
 include/net/sock.h                     |   43 +++
 net/Kconfig                            |   12 
 net/Makefile                           |    1 
 net/hooks.c                            |   55 ++++
 net/ipv4/af_inet.c                     |    2 
 net/ipv6/af_inet6.c                    |    2 
 15 files changed, 915 insertions(+), 2 deletions(-)
Documentation/filesystems/accessfs.txt new file +41 -0
new file mode 100644
index 0000000..bf135b5
@@ -0,0 +1,41 @@
+Accessfs is a permission managing filesystem. It allows to control access to
+system resources, based on file permissions. The recommended mount point for
+this file-system is /proc/access, which will appear automatically in the
+/proc filesystem.
+
+Currently there are two modules using accessfs, userports and usercaps.
+
+With userports, you will be able to control access to IP ports based
+on user-/groupid.
+
+There's no need anymore to run internet daemons as root. You can
+individually configure which user/program can bind to protected ports
+(by default, below 1024).
+
+For example, you can say, user www is allowed to bind to port 80 or
+user mail is allowed to bind to port 25. Then, you can run apache as
+user www and sendmail as user mail. Now, you don't have to rely on
+apache or sendmail giving up superuser rights to enhance security.
+
+To use this option, you need to mount the access file system
+and do a chown on the appropriate ports:
+
+# mount -t accessfs none /proc/access
+# chown www /proc/access/net/ip/bind/80
+# chown mail /proc/access/net/ip/bind/25
+
+You can grant access to a group for individual ports as well. Just say:
+
+# chgrp lp /proc/access/net/ip/bind/515
+# chown g+x /proc/access/net/ip/bind/515
+
+With usercaps, you will be able to grant capabilities based on
+user-/groupid (root by default).
+
+For example you can create a group raw and change the capability
+net_raw to this group:
+
+# chgrp raw /proc/access/capabilities/net_raw
+# chmod ug+x /proc/access/capabilities/net_raw
+# chgrp raw /sbin/ping
+# chmod u-s /sbin/ping; chmod g+s /sbin/ping
fs/Kconfig +1 -0
index 0e7da7b..8373ff6 100644
@@ -187,6 +187,7 @@ source "fs/sysv/Kconfig"
 source "fs/ufs/Kconfig"
 source "fs/exofs/Kconfig"
 source "fs/nilfs2/Kconfig"
+source "fs/accessfs/Kconfig"
 
 endif # MISC_FILESYSTEMS
 
fs/Makefile +1 -0
index af6d047..072a880 100644
@@ -124,3 +124,4 @@ obj-$(CONFIG_OCFS2_FS)		+= ocfs2/
 obj-$(CONFIG_BTRFS_FS)		+= btrfs/
 obj-$(CONFIG_GFS2_FS)           += gfs2/
 obj-$(CONFIG_EXOFS_FS)          += exofs/
+obj-$(CONFIG_ACCESS_FS)		+= accessfs/
fs/accessfs/Kconfig new file +64 -0

64 lines not on this page · raw message

fs/accessfs/Makefile new file +11 -0
new file mode 100644
index 0000000..63a5647
@@ -0,0 +1,11 @@
+#
+# Makefile for the linux accessfs routines.
+#
+
+obj-$(CONFIG_ACCESS_FS) += accessfs.o
+obj-$(CONFIG_ACCESSFS_USER_CAPABILITIES) += usercaps.o
+obj-$(CONFIG_ACCESSFS_USER_PORTS) += userports.o
+
+accessfs-objs := inode.o
+usercaps-objs := capabilities.o
+userports-objs := ip.o
fs/accessfs/capabilities.c new file +107 -0

107 lines not on this page · raw message

fs/accessfs/inode.c new file +434 -0

434 lines not on this page · raw message

fs/accessfs/ip.c new file +101 -0

101 lines not on this page · raw message

include/linux/accessfs_fs.h new file +42 -0

42 lines not on this page · raw message

include/net/sock.h +43 -0

47 lines not on this page · raw message

net/Kconfig +12 -0
index 7051b97..ad16a5b 100644
@@ -55,6 +55,18 @@ config INET
 if INET
 source "net/ipv4/Kconfig"
 source "net/ipv6/Kconfig"
+
+config NET_HOOKS
+	bool "IP: Networking hooks (Experimental)"
+	depends on INET && EXPERIMENTAL
+	default n
+	help
+	  This option enables other kernel parts or modules to hook into the
+	  networking area and provide fine grained control over the access to
+	  IP ports.
+
+	  If you're unsure, say N.
+
 source "net/netlabel/Kconfig"
 
 endif # if INET
net/Makefile +1 -0
index ba324ae..3c34bd9 100644
@@ -61,6 +61,7 @@ ifneq ($(CONFIG_DCB),)
 obj-y				+= dcb/
 endif
 obj-y				+= ieee802154/
+obj-$(CONFIG_NET_HOOKS)		+= hooks.o
 
 ifeq ($(CONFIG_NET),y)
 obj-$(CONFIG_SYSCTL)		+= sysctl_net.o
net/hooks.c new file +55 -0

55 lines not on this page · raw message

net/ipv4/af_inet.c +1 -1
index 566ea6c..ca3721f 100644
@@ -477,7 +477,7 @@ int inet_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len)
 
 	snum = ntohs(addr->sin_port);
 	err = -EACCES;
-	if (snum && snum < PROT_SOCK && !capable(CAP_NET_BIND_SERVICE))
+	if (ip_prot_sock(sock, uaddr, addr_len))
 		goto out;
 
 	/*      We keep a pair of addresses. rcv_saddr is the one
net/ipv6/af_inet6.c +1 -1
index 45f9a2a..4d4d6dd 100644
@@ -275,7 +275,7 @@ int inet6_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len)
 		return -EINVAL;
 
 	snum = ntohs(addr->sin6_port);
-	if (snum && snum < PROT_SOCK && !capable(CAP_NET_BIND_SERVICE))
+	if (ip6_prot_sock(sock, uaddr, addr_len))
 		return -EACCES;
 
 	lock_sock(sk);