Skip to contentSkip to conversation

CIFS posix acl permission checking

RFC PATCH New Jon Severinsson 1 participant 1 message Mar 1, 2010 VFS

lore
Share & tools
lore
#0 lore raw

RFC PATCH 1/1 CIFS posix acl permission checking

Hello everyone

Firstly, please note that I'm new to the kernel community, so if I'm doing something wrong, just please politely point it out to me and I'll try to fix it, or at the very least not do it again. Also please bear in mind that English isn't my native language.

Anyway, I recently realised that while the CIFS file system driver in Linux does supports posix acl retrieval and modification using the getfacl and setfacl command line tools, it does not use acl for client side permission checking. On the server side Samba does consult the acl, but that doesn't really help when cifs.ko never even asks the server, due to the users only source of permission being from an acl.

I'm attaching a first attempt at implementing it. I have tested it, but only on a single setup, so I can give no guarantees to its portability. Also please note that this is my first kernel patch, so if I'm doing something wrong, such as not following some coding standard, please enlighten me and I'll gladly fix it.

I only subscribed to the linux-fsdevel list, so please include it in any response you might send.

Best Regards
Jon Severinsson

commit fab1872fcbb8a5cdb85d7e7a88ecf0cad99d1c80

Author: Jon Severinsson <[email protected]>
Date:   Mon Mar 1 15:49:40 2010 +0100

[CIFS] Adds support for permision checking vs. posix acl.

CIFS already supports getting and setting acls through getfacl and setfacl, but prior to this patch, any acls was ignored when doing permission checking.

fs/cifs/cifsfs.c +10 -1
index 29f1da7..0605e11 100644
@@ -284,7 +284,7 @@ static int cifs_permission(struct inode *inode, int mask)
 		on the client (above and beyond ACL on servers) for
 		servers which do not support setting and viewing mode bits,
 		so allowing client to check permissions is useful */
-		return generic_permission(inode, mask, NULL);
+		return generic_permission(inode, mask, inode->i_op->check_acl);
 }
 
 static struct kmem_cache *cifs_inode_cachep;
@@ -702,6 +702,9 @@ const struct inode_operations cifs_dir_inode_ops = {
 	.getxattr = cifs_getxattr,
 	.listxattr = cifs_listxattr,
 	.removexattr = cifs_removexattr,
+#ifdef CONFIG_CIFS_POSIX
+	.check_acl = cifs_check_acl,
+#endif
 #endif
 };
 
@@ -716,6 +719,9 @@ const struct inode_operations cifs_file_inode_ops = {
 	.getxattr = cifs_getxattr,
 	.listxattr = cifs_listxattr,
 	.removexattr = cifs_removexattr,
+#ifdef CONFIG_CIFS_POSIX
+	.check_acl = cifs_check_acl,
+#endif
 #endif
 };
 
@@ -732,6 +738,9 @@ const struct inode_operations cifs_symlink_inode_ops = {
 	.getxattr = cifs_getxattr,
 	.listxattr = cifs_listxattr,
 	.removexattr = cifs_removexattr,
+#ifdef CONFIG_CIFS_POSIX
+	.check_acl = cifs_check_acl,
+#endif
 #endif
 };
 
fs/cifs/cifsfs.h +4 -0
index ac2b24c..6409a83 100644
@@ -102,11 +102,15 @@ extern int cifs_readlink(struct dentry *direntry, char __user *buffer,
 			 int buflen);
 extern int cifs_symlink(struct inode *inode, struct dentry *direntry,
 			const char *symname);
+
+/* Functions related to extended attributes */
 extern int	cifs_removexattr(struct dentry *, const char *);
 extern int 	cifs_setxattr(struct dentry *, const char *, const void *,
 			size_t, int);
 extern ssize_t	cifs_getxattr(struct dentry *, const char *, void *, size_t);
 extern ssize_t	cifs_listxattr(struct dentry *, char *, size_t);
+extern int cifs_check_acl(struct inode *inode, int mask);
+
 extern long cifs_ioctl(struct file *filep, unsigned int cmd, unsigned long arg);
 
 #ifdef CONFIG_CIFS_EXPERIMENTAL
fs/cifs/xattr.c +71 -0

74 lines not on this page · raw message