2.6.15: access permission filesystem 0.17
Subsystems (4)
PATCH 1/1 2.6.15: access permission filesystem 0.17
This 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.15
This patch is available at:
<http://www.olafdietsche.de/linux/accessfs/>
Regards, Olaf.
fs/Kconfig +1 -0
@@ -1209,6 +1209,7 @@ It's currently broken, so for now: answer N. +source "fs/accessfs/Kconfig" config SYSV_FS
fs/Makefile +1 -0
@@ -101,3 +101,4 @@ obj-$(CONFIG_HOSTFS) += hostfs/ obj-$(CONFIG_HPPFS) += hppfs/ obj-$(CONFIG_DEBUG_FS) += debugfs/ +obj-$(CONFIG_ACCESS_FS) += accessfs/
fs/accessfs/Kconfig +82 -0
82 lines not on this page · raw message
fs/accessfs/Makefile +11 -0
@@ -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 +107 -0
107 lines not on this page · raw message
fs/accessfs/inode.c +418 -0
418 lines not on this page · raw message
fs/accessfs/ip.c +92 -0
92 lines not on this page · raw message
include/linux/accessfs_fs.h +49 -0
49 lines not on this page · raw message
include/net/sock.h +17 -0
@@ -1391,4 +1391,21 @@extern __u32 sysctl_wmem_default;extern __u32 sysctl_rmem_default; +/* Networking hooks */ +#ifdef CONFIG_NET_HOOKS +struct net_hook_operations { +int (*ip_prot_sock)(struct socket *sock, +struct sockaddr *uaddr,int addr_len); +int (*ip6_prot_sock)(struct socket *sock, +struct sockaddr *uaddr,int addr_len); +}; + +extern struct net_hook_operations *net_ops; + +extern int default_ip_prot_sock (struct socket *sock,struct sockaddr *uaddr,int addr_len); +extern int default_ip6_prot_sock (struct socket *sock,struct sockaddr *uaddr,int addr_len); +extern void net_hooks_register (struct net_hook_operations *ops); +extern void net_hooks_unregister (struct net_hook_operations *ops); +#endif +#endif /* _SOCK_H */
net/Kconfig +11 -0
@@ -56,6 +56,17 @@ 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. + endif # if INET
net/Makefile +1 -0
@@ -45,6 +45,7 @@ obj-$(CONFIG_IP_DCCP) += dccp/ obj-$(CONFIG_IP_SCTP) += sctp/ obj-$(CONFIG_IEEE80211) += ieee80211/ +obj-$(CONFIG_NET_HOOKS) += hooks.o ifeq ($(CONFIG_NET),y) obj-$(CONFIG_SYSCTL) += sysctl_net.o
net/hooks.c +56 -0
56 lines not on this page · raw message
net/ipv4/af_inet.c +4 -0
@@ -428,7 +428,11 @@ snum =ntohs (addr->sin_port); err = -EACCES ; +#ifdef CONFIG_NET_HOOKS +if (net_ops->ip_prot_sock (sock, uaddr, addr_len)) +#else if (snum && snum < PROT_SOCK && !capable(CAP_NET_BIND_SERVICE)) +#endif goto out;/* We keep a pair of addresses. rcv_saddr is the one
net/ipv6/af_inet6.c +4 -0
@@ -258,7 +258,11 @@return -EINVAL ; snum =ntohs (addr->sin6_port); +#ifdef CONFIG_NET_HOOKS +if (net_ops->ip6_prot_sock (sock, uaddr, addr_len)) +#else if (snum && snum < PROT_SOCK && !capable(CAP_NET_BIND_SERVICE)) +#endif return -EACCES ;lock_sock (sk);
Hi Olaf,
On Saturday 14 January 2006 22:06, Olaf Dietsche wrote:
[PATCH]
accessfs_readdir_aux() in fs/accessfs/inode.c
should set DT_REG, since accessfs supports just directories and regular files. The directory is already handled before in the sole caller of accessfs_readdir_aux().
This saves the superflous stat(2) call after readdir(2).
All in all I like the concept! It makes the life of admins much easier.
Regards
Ingo Oeser
Quoted 10 lines · Ingo Oeser
On Saturday 14 January 2006 22:06, Olaf Dietsche wrote:
[PATCH]
accessfs_readdir_aux()infs/accessfs/inode.cshould set
DT_REG, since accessfs supports just directories and regular files. The directory is already handled before in the sole caller ofaccessfs_readdir_aux().This saves the superflous stat(2) call after readdir(2).
Thanks for this hint, it is much appreciated.
Regards, Olaf.
Quoted 6 lines · Olaf Dietsche
This 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.
Any chance you will push this to Andrew and Linus in near future so we'll see it in mainline?
Eike
PATCH 1/1 accessfs: a permission managing filesystem
Hi Andrew,
Can you please include this patch in -mm, to give it wider testing?
Accessfs is a permission managing filesystem. It allows to control access to system resources, based on file permissions. It also includes two modules. One module allows granting capabilities based on user-/groupid. The second module allows to grant access to lower numbered IP ports based on user-/groupid.
Regards, Olaf.
--- fs/Kconfig | 1 fs/Makefile | 1 fs/accessfs/Kconfig | 82 ++++++++ fs/accessfs/Makefile | 11 + fs/accessfs/capabilities.c | 107 +++++++++++ fs/accessfs/inode.c | 418 ++++++++++++++++++++++++++++++++++++++++++++ fs/accessfs/ip.c | 92 +++++++++ include/linux/accessfs_fs.h | 49 +++++ include/net/sock.h | 17 + net/Kconfig | 11 + net/Makefile | 1 net/hooks.c | 56 +++++ net/ipv4/af_inet.c | 4 net/ipv6/af_inet6.c | 4 14 files changed, 854 insertions(+)
fs/Kconfig +1 -0
@@ -1253,6 +1253,7 @@ It's currently broken, so for now: answer N. +source "fs/accessfs/Kconfig" config SYSV_FS
fs/Makefile +1 -0
@@ -103,3 +103,4 @@ obj-$(CONFIG_DEBUG_FS) += debugfs/ obj-$(CONFIG_CONFIGFS_FS) += configfs/ obj-$(CONFIG_OCFS2_FS) += ocfs2/ +obj-$(CONFIG_ACCESS_FS) += accessfs/
fs/accessfs/Kconfig +82 -0
82 lines not on this page · raw message
fs/accessfs/Makefile +11 -0
@@ -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 +107 -0
107 lines not on this page · raw message
fs/accessfs/inode.c +418 -0
418 lines not on this page · raw message
fs/accessfs/ip.c +92 -0
92 lines not on this page · raw message
include/linux/accessfs_fs.h +49 -0
49 lines not on this page · raw message
include/net/sock.h +17 -0
@@ -1417,4 +1417,21 @@extern __u32 sysctl_wmem_default;extern __u32 sysctl_rmem_default; +/* Networking hooks */ +#ifdef CONFIG_NET_HOOKS +struct net_hook_operations { +int (*ip_prot_sock)(struct socket *sock, +struct sockaddr *uaddr,int addr_len); +int (*ip6_prot_sock)(struct socket *sock, +struct sockaddr *uaddr,int addr_len); +}; + +extern struct net_hook_operations *net_ops; + +extern int default_ip_prot_sock (struct socket *sock,struct sockaddr *uaddr,int addr_len); +extern int default_ip6_prot_sock (struct socket *sock,struct sockaddr *uaddr,int addr_len); +extern void net_hooks_register (struct net_hook_operations *ops); +extern void net_hooks_unregister (struct net_hook_operations *ops); +#endif +#endif /* _SOCK_H */
net/Kconfig +11 -0
@@ -56,6 +56,17 @@ 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. + endif # if INET
net/Makefile +1 -0
@@ -46,6 +46,7 @@ obj-$(CONFIG_IP_SCTP) += sctp/ obj-$(CONFIG_IEEE80211) += ieee80211/ obj-$(CONFIG_TIPC) += tipc/ +obj-$(CONFIG_NET_HOOKS) += hooks.o ifeq ($(CONFIG_NET),y) obj-$(CONFIG_SYSCTL) += sysctl_net.o
net/hooks.c +56 -0
56 lines not on this page · raw message
net/ipv4/af_inet.c +4 -0
@@ -431,7 +431,11 @@ snum =ntohs (addr->sin_port); err = -EACCES ; +#ifdef CONFIG_NET_HOOKS +if (net_ops->ip_prot_sock (sock, uaddr, addr_len)) +#else if (snum && snum < PROT_SOCK && !capable(CAP_NET_BIND_SERVICE)) +#endif goto out;/* We keep a pair of addresses. rcv_saddr is the one
net/ipv6/af_inet6.c +4 -0
@@ -260,7 +260,11 @@return -EINVAL ; snum =ntohs (addr->sin6_port); +#ifdef CONFIG_NET_HOOKS +if (net_ops->ip6_prot_sock (sock, uaddr, addr_len)) +#else if (snum && snum < PROT_SOCK && !capable(CAP_NET_BIND_SERVICE)) +#endif return -EACCES ;lock_sock (sk);
Re: [PATCH 2.6.16-rc1-git4] accessfs: a permission managing filesystem
Quoted 4 lines · Olaf Dietsche
Hi Andrew,
Can you please include this patch in -mm, to give it wider testing?
I doubt if it'll get a lot of runtime testing.
Quoted 6 lines
Accessfs is a permission managing filesystem. It allows to control access to system resources, based on file permissions. It also includes two modules. One module allows granting capabilities based on user-/groupid. The second module allows to grant access to lower numbered IP ports based on user-/groupid.
It seems to be network-centric?
Do these capabilities really need to be implemented via a brand-new security infrastructure, rather then by enhancing the existing one(s)?
fs/accessfs/Kconfig line 38
Quoted 6 lines
fs/accessfs/Kconfig +6
-0+ 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
Documenting a feature in Kconfig is a bit odd. I assume proper Documentation is forthcoming?
fs/accessfs/capabilities.c line 11
Quoted 8 lines
+ */
fs/accessfs/capabilities.c +7
-0+ +#include <linux/accessfs_fs.h> +#include <linux/init.h> +#include <linux/module.h> +#include <linux/security.h> + +static struct access_attr caps[29 ];
caps[ARRAY_SIZE(names)]
should work.
Quoted 30 lines
fs/accessfs/capabilities.c +30
-0+static const char *names[] = { +"chown" , +"dac_override" , +"dac_read_search" , +"fowner" , +"fsetid" , +"kill" , +"setgid" , +"setuid" , +"setpcap" , +"linux_immutable" , +"net_bind_service" , +"net_broadcast" , +"net_admin" , +"net_raw" , +"ipc_lock" , +"ipc_owner" , +"sys_module" , +"sys_rawio" , +"sys_chroot" , +"sys_ptrace" , +"sys_pacct" , +"sys_admin" , +"sys_boot" , +"sys_nice" , +"sys_resource" , +"sys_time" , +"sys_tty_config" , +"mknod" , +"lease"
fs/accessfs/capabilities.c line 66
Quoted 10 lines
fs/accessfs/capabilities.c +9
-0+}; + +static void unregister_capabilities (struct accessfs_direntry *dir,int n) +{ +int i; +for (i =0 ; i < n; ++i) { +accessfs_unregister (dir, names[i]); + } +}
Unneeded braces.
fs/accessfs/capabilities.c line 76
Quoted 9 lines
fs/accessfs/capabilities.c +9
-0+static int __init init_capabilities (void ) +{ +struct accessfs_direntry *dir; +int i, err; + dir =accessfs_make_dirpath ("capabilities" ); +if (dir ==0 ) +return -ENOTDIR ; + +for (i =0 ; i <sizeof (caps) /sizeof (caps[0 ]); ++i) {
ARRAY_SIZE() (lots of instances)
Quoted 1 line
+static
DECLARE_MUTEX(accessfs_sem);
Please use a `struct mutex'.
Quoted 10 lines
fs/accessfs/inode.c +10
-0+ +static inline void accessfs_readdir_aux (struct file *filp,struct accessfs_direntry *dir,int start,void *dirent,filldir_t filldir) +{ +struct list_head *list; +int i; + + list = dir->children.next; +for (i =2 ; i < start && list != &dir->children; ++i) + list = list->next; +
fs/accessfs/inode.c line 59
Quoted 10 lines
fs/accessfs/inode.c +10
-0+while (list != &dir->children) { +struct accessfs_entry *de; + de = list_entry(list, struct accessfs_entry, siblings); +if (filldir (dirent, de->name,strlen (de->name), filp->f_pos, de->ino,DT_UNKNOWN ) <0 ) +break ; + + ++filp->f_pos; + list = list->next; + } +}
Use standard list accessors?
Please fit code into 80 cols.
Quoted 15 lines
fs/accessfs/inode.c +15
-0+static int accessfs_readdir (struct file *filp,void *dirent,filldir_t filldir) +{ +int i; +struct dentry *dentry = filp->f_dentry; +struct accessfs_direntry *dir; + + i = filp->f_pos; +switch (i) { +case 0 : +if (filldir (dirent,"." ,1 , i, dentry->d_inode->i_ino,DT_DIR ) <0 ) +break ; + + ++i; + ++filp->f_pos; +/* NO break; */
fs/accessfs/inode.c line 85
Quoted 10 lines
fs/accessfs/inode.c +10
-0+case 1 : +if (filldir (dirent,".." ,2 , i, dentry->d_parent->d_inode->i_ino,DT_DIR ) <0 ) +break ; + + ++i; + ++filp->f_pos; +/* NO break; */ +default : +down (&accessfs_sem); + dir = (struct accessfs_direntry *) dentry->d_inode->u.generic_ip;
Unneeded typecast.
fs/accessfs/inode.c line 138
Quoted 12 lines
fs/accessfs/inode.c +11
-0+accessfs_readdir_aux (filp, dir, i, dirent, filldir); +up (&accessfs_sem); +break ; + } + +return 0 ; +} + +static void accessfs_init_inode (struct inode *inode,struct accessfs_entry *pe) +{ +static const struct timespec epoch = {0 ,0 };
Unneeded initialiser (although it does make things clearer)
Quoted 9 lines
fs/accessfs/inode.c +9
-0+ +static struct accessfs_direntry *accessfs_mkdir (struct accessfs_direntry *parent,const char *name,size_t len) +{ +int err; +struct accessfs_direntry *dir; + dir =kmalloc (sizeof (struct accessfs_direntry ),GFP_KERNEL ); +if (dir ==NULL ) +return NULL ; +
fs/accessfs/inode.c line 227
Quoted 10 lines
fs/accessfs/inode.c +10
-0+ dir->parent = parent; +INIT_LIST_HEAD (&dir->children); + err =accessfs_node_init (parent, &dir->node, name, len, &dir->attr,S_IFDIR |0755 ); +if (err) { +kfree (dir); + dir =0 ; + } + +return dir; +}
Again, painful to read in 80-cols.
fs/accessfs/inode.c line 233
Quoted 5 lines
fs/accessfs/inode.c +5
-0+struct accessfs_direntry *accessfs_make_dirpath (const char *name) +{ +struct accessfs_direntry *dir = &accessfs_rootdir; +const char *slash; +down (&accessfs_sem);
Shouldn't that lock be per-superblock?
fs/accessfs/inode.c line 296
Quoted 13 lines
fs/accessfs/inode.c +13
-0+static void accessfs_read_inode (struct inode *inode) +{ +ino_t ino = inode->i_ino; +struct list_head *list; +down (&accessfs_sem); +list_for_each (list, &hash) { +struct accessfs_entry *pe; + pe = list_entry(list, struct accessfs_entry, hash); +if (pe->ino == ino) { +accessfs_init_inode (inode, pe); +break ; + } + }
That's not a hash!
fs/accessfs/inode.c line 406
Quoted 7 lines
fs/accessfs/inode.c +7
-0+{ +unregister_filesystem (&accessfs_fs_type); + +#ifdef CONFIG_PROC_FS +remove_proc_entry ("access" ,&proc_root); +#endif +}
The CONFIG_PROC_FS ifdefs shouldn't be needed - we have stubs.
fs/accessfs/ip.c line 30
Quoted 4 lines
fs/accessfs/ip.c +4
-0+static int accessfs_ip6_prot_sock (struct socket *sock, +struct sockaddr *uaddr,int addr_len) +{ +#if defined(CONFIG_IPV6 ) || defined(CONFIG_IPV6_MODULE )
That's a bit awkward, especially the CONFIG_IPV6_MODULE dependency. Is it possible to just unconditionally compile this in?
fs/accessfs/ip.c line 54
Quoted 6 lines
fs/accessfs/ip.c +6
-0+static int __init init_ip (void ) +{ +struct accessfs_direntry *dir =accessfs_make_dirpath ("net/ip/bind" ); +int i; + bind_to_port =kmalloc (max_prot_sock *sizeof (*bind_to_port),GFP_KERNEL ); +if (bind_to_port ==0 )
Use NULL to avoid sparse warnings.
include/linux/accessfs_fs.h line 47
Quoted 6 lines
include/linux/accessfs_fs.h +6
-0+ +#if CONFIG_ACCESSFS_PROT_SOCK <PROT_SOCK +#define CONFIG_ACCESSFS_PROT_SOCK PROT_SOCK +#elseif CONFIG_ACCESSFS_PROT_SOCK > 65536 +#define CONFIG_ACCESSFS_PROT_SOCK 65536 +#endif
Please don't redefine CONFIG_ variables like this. I'd have expected the compiler to have generated a warning about this, too.
net/ipv4/af_inet.c line 439
Quoted 8 lines
net/ipv4/af_inet.c +4
-0snum =ntohs (addr->sin_port); err = -EACCES ; +#ifdef CONFIG_NET_HOOKS +if (net_ops->ip_prot_sock (sock, uaddr, addr_len)) +#else if (snum && snum < PROT_SOCK && !capable(CAP_NET_BIND_SERVICE)) +#endif goto out;
Maybe some wrapper which hides the above?
Quoted 5 lines
/* We keep a pair of addresses.
rcv_saddris the one
diff -urNa/net/ipv6/af_inet6.cb/net/ipv6/af_inet6.c
net/ipv6/af_inet6.c line 269
Quoted 10 lines
net/ipv6/af_inet6.c +4
-0@@ -260,7 +260,11 @@return -EINVAL ; snum =ntohs (addr->sin6_port); +#ifdef CONFIG_NET_HOOKS +if (net_ops->ip6_prot_sock (sock, uaddr, addr_len)) +#else if (snum && snum < PROT_SOCK && !capable(CAP_NET_BIND_SERVICE)) +#endif return -EACCES ;
which could be used here as well.
Re: [PATCH 2.6.16-rc1-git4] accessfs: a permission managing filesystem
Quoted 5 lines · Andrew Morton
Quoted 2 lines · Olaf Dietsche
Can you please include this patch in -mm, to give it wider testing?
I doubt if it'll get a lot of runtime testing.
Well, this review alone was worth the effort. Thanks.
Quoted 8 lines
Quoted 6 lines
Accessfs is a permission managing filesystem. It allows to control access to system resources, based on file permissions. It also includes two modules. One module allows granting capabilities based on user-/groupid. The second module allows to grant access to lower numbered IP ports based on user-/groupid.
It seems to be network-centric?
It could be used anywhere, where you want access control on a file permission (user, group, other) basis.
But yes, currently I use it that way only.
Quoted 2 lines
Do these capabilities really need to be implemented via a brand-new security infrastructure, rather then by enhancing the existing one(s)?
This doesn't change the existing security infrastructure. It just permits users and/or groups to get selected privileges. But I won't insist on this one, since I use filesystem capabilities anyway.
Quoted 9 lines
Review
Quoted 6 lines
(quoted diff) +6
-0+ 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/25Documenting a feature in
Kconfigis a bit odd. I assume proper Documentation is forthcoming?
When I encounter a new item in Kconfig, I expect help, which explains, what it is good for. Anyway, I moved a few lines to Documentation/filesystems/accessfs.txt
Quoted 7 lines
Review
Quoted 5 lines
(quoted diff) +5
-0+struct accessfs_direntry *accessfs_make_dirpath(const char *name) +{ + struct accessfs_direntry *dir = &accessfs_rootdir; + const char *slash; + down(&accessfs_sem);Shouldn't that lock be per-superblock?
Like procfs or sysfs there's only one instance, so I don't think this is necessary.
Quoted 7 lines
Quoted 7 lines
(quoted diff) +7
-0+static void accessfs_read_inode(struct inode *inode) +{ + ino_t ino = inode->i_ino; + struct list_head *list; + down(&accessfs_sem); + list_for_each(list, &hash) { + struct accessfs_entry *pe;
Quoted 8 lines
Review
Quoted 6 lines
(quoted diff) +6
-0+ pe = list_entry(list, struct accessfs_entry, hash); + if (pe->ino == ino) { + accessfs_init_inode(inode, pe); + break; + } + }That's not a hash!
Do you think it should be? accessfs_read_inode() is not a frequently called function.
I think, I addressed all your remaining points. If you have further concerns, I won't respond until next weekend.
Regards, Olaf.
--- Documentation/filesystems/accessfs.txt | 41 +++ fs/Kconfig | 1 fs/Makefile | 1 fs/accessfs/Kconfig | 50 +++ fs/accessfs/Makefile | 11 fs/accessfs/capabilities.c | 107 ++++++++ fs/accessfs/inode.c | 426 +++++++++++++++++++++++++++++++++ fs/accessfs/ip.c | 95 +++++++ include/linux/accessfs_fs.h | 43 +++ include/net/sock.h | 43 +++ net/Kconfig | 11 net/Makefile | 1 net/hooks.c | 55 ++++ net/ipv4/af_inet.c | 2 net/ipv6/af_inet6.c | 2 15 files changed, 887 insertions(+), 2 deletions(-)
Documentation/filesystems/accessfs.txt +41 -0
@@ -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
@@ -1253,6 +1253,7 @@ It's currently broken, so for now: answer N. +source "fs/accessfs/Kconfig" config SYSV_FS
fs/Makefile +1 -0
@@ -103,3 +103,4 @@ obj-$(CONFIG_DEBUG_FS) += debugfs/ obj-$(CONFIG_CONFIGFS_FS) += configfs/ obj-$(CONFIG_OCFS2_FS) += ocfs2/ +obj-$(CONFIG_ACCESS_FS) += accessfs/
fs/accessfs/Kconfig +50 -0
50 lines not on this page · raw message
fs/accessfs/Makefile +11 -0
@@ -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 +107 -0
107 lines not on this page · raw message
fs/accessfs/inode.c +426 -0
426 lines not on this page · raw message
fs/accessfs/ip.c +95 -0
95 lines not on this page · raw message
include/linux/accessfs_fs.h +43 -0
43 lines not on this page · raw message
include/net/sock.h +43 -0
47 lines not on this page · raw message
net/Kconfig +11 -0
@@ -56,6 +56,17 @@ 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. + endif # if INET
net/Makefile +1 -0
@@ -46,6 +46,7 @@ obj-$(CONFIG_IP_SCTP) += sctp/ obj-$(CONFIG_IEEE80211) += ieee80211/ obj-$(CONFIG_TIPC) += tipc/ +obj-$(CONFIG_NET_HOOKS) += hooks.o ifeq ($(CONFIG_NET),y) obj-$(CONFIG_SYSCTL) += sysctl_net.o
net/hooks.c +55 -0
55 lines not on this page · raw message
net/ipv4/af_inet.c +1 -1
@@ -431,7 +431,7 @@ 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
@@ -260,7 +260,7 @@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);
Re: [PATCH 2.6.16-rc1-git4] accessfs: a permission managing filesystem
In reply to Andrew MortonQuoted 4 lines
Quoted 2 lines
+static
DECLARE_MUTEX(accessfs_sem);Please use a `struct mutex'.
You know what's irritating? That DECLARE_MUTEX starts a semaphore and DEFINE_MUTEX a mutex.
Jan Engelhardt
Re: [PATCH 2.6.16-rc1-git4] accessfs: a permission managing filesystem
Quoted 9 lines · Jan Engelhardt
Quoted 5 lines
Quoted 3 lines
+static
DECLARE_MUTEX(accessfs_sem);Please use a `struct mutex'.
You know what's irritating? That
DECLARE_MUTEXstarts a semaphore andDEFINE_MUTEXa mutex.
DECLARE_MUTEX will go away.
Re: [PATCH 2.6.16-rc1-git4] accessfs: a permission managing filesystem
Quoted 8 lines
Quoted 6 lines
Quoted 3 lines
Quoted 1 line
+static
DECLARE_MUTEX(accessfs_sem);Please use a `struct mutex'.
You know what's irritating? That
DECLARE_MUTEXstarts a semaphore andDEFINE_MUTEXa mutex.
DECLARE_MUTEXwill go away.
And be replaced by... DEFINE_SEMAPHORE?
Jan Engelhardt
Re: [PATCH 2.6.16-rc1-git4] accessfs: a permission managing filesystem
Quoted 12 lines · Jan Engelhardt
Quoted 9 lines
Quoted 7 lines
Quoted 4 lines
Quoted 2 lines
+static
DECLARE_MUTEX(accessfs_sem);Please use a `struct mutex'.
You know what's irritating? That
DECLARE_MUTEXstarts a semaphore andDEFINE_MUTEXa mutex.
DECLARE_MUTEXwill go away.And be replaced by...
DEFINE_SEMAPHORE?
That would be logical.
Re: [PATCH 2.6.16-rc1-git4] accessfs: a permission managing filesystem
In reply to Jan EngelhardtQuoted 10 lines · Jan Engelhardt
Quoted 8 lines
Quoted 6 lines
Quoted 3 lines
Quoted 1 line
+static
DECLARE_MUTEX(accessfs_sem);Please use a `struct mutex'.
You know what's irritating? That
DECLARE_MUTEXstarts a semaphore andDEFINE_MUTEXa mutex.
DECLARE_MUTEXwill go away.And be replaced by...
DEFINE_SEMAPHORE?
... or just go away entirely, depending if there are any users of it left after all mutexes have been converted to DEFINE_MUTEX()...
Re: [PATCH 2.6.16-rc1-git4] accessfs: a permission managing filesystem
Quoted 6 lines
Quoted 3 lines
Quoted 1 line
DECLARE_MUTEXwill go away.And be replaced by...
DEFINE_SEMAPHORE?... or just go away entirely, depending if there are any users of it left after all mutexes have been converted to
DEFINE_MUTEX()...
Does that imply that struct semaphore be removed too? You can't do that.
Jan Engelhardt
Re: [PATCH 2.6.16-rc1-git4] accessfs: a permission managing filesystem
Quoted 8 lines · Jan Engelhardt
Quoted 6 lines
Quoted 3 lines
Quoted 1 line
DECLARE_MUTEXwill go away.And be replaced by...
DEFINE_SEMAPHORE?... or just go away entirely, depending if there are any users of it left after all mutexes have been converted to
DEFINE_MUTEX()...Does that imply that struct semaphore be removed too?
not per se
Quoted 1 line
You can't do that.
Exactly why not? Assuming there are zero users left in the kernel..... (which highly obviously is a prerequisite for even thinking about such a step)
Re: [PATCH 2.6.16-rc1-git4] accessfs: a permission managing filesystem
Quoted 5 lines
Quoted 1 line
You can't do that.
Exactly why not? Assuming there are zero users left in the kernel..... (which highly obviously is a prerequisite for even thinking about such a step)
Documentation/mutex-design.txt:
* - mutexes may not be used in irq contexts
I need some locking strategy within irq contexts, and that suggests semaphores do the job.
Jan Engelhardt
Signature · 3 lines
| Software Engineer and Linux/Unix Network Administrator | Alphagate Systems, http://alphagate.hopto.org/ | jengelh's site, http://jengelh.hopto.org/
Re: [PATCH 2.6.16-rc1-git4] accessfs: a permission managing filesystem
Quoted 11 lines · Jan Engelhardt
Quoted 5 lines
Quoted 1 line
You can't do that.
Exactly why not? Assuming there are zero users left in the kernel..... (which highly obviously is a prerequisite for even thinking about such a step)
Documentation/mutex-design.txt:
* - mutexes may not be used in irq contextsI need some locking strategy within irq contexts, and that suggests semaphores do the job.
well... maybe.
If you need to mess inside irq context, spinlocks sound more the right thing. Or if you need to do a "I'm done" in the irq and a "sleep until done" thing in process context, then you really should use completions instead.
Re: [PATCH 2.6.16-rc1-git4] accessfs: a permission managing filesystem
Quoted 6 lines
well... maybe.
If you need to mess inside irq context, spinlocks sound more the right thing. Or if you need to do a "I'm done" in the irq and a "sleep until done" thing in process context, then you really should use completions instead.
Hm, is it allowed to call copy_{from,to}_user() in irq context?
Jan Engelhardt
Re: [PATCH 2.6.16-rc1-git4] accessfs: a permission managing filesystem
Quoted 8 lines · Jan Engelhardt
Quoted 6 lines
well... maybe.
If you need to mess inside irq context, spinlocks sound more the right thing. Or if you need to do a "I'm done" in the irq and a "sleep until done" thing in process context, then you really should use completions instead.Hm, is it allowed to call copy_{from,to}_user() in irq context?
absolutely not.
IRQ context has no defined "userspace" context at all, so even if copy_from/to_user wouldn't sleep (they do, and that alone makes it "illegal" to do already) it would be highly undefined what you would be copying to/from.
Re: [PATCH 2.6.16-rc1-git4] accessfs: a permission managing filesystem
Quoted 3 lines
Quoted 1 line
Hm, is it allowed to call copy_{from,to}_user() in irq context?
absolutely not.
Right, everything clarified then. Remove the semaphores ;)
Jan Engelhardt