Linux Headquarters
[ Register ]
[ About us ] [ Home Page ]

Advertisement
[ Kernel ] [ Documentation ] [ Links ] [ Books ]

Advertisement

Kernel v2.6.24-git16 /fs/xattr.c

Filename:/fs/xattr.c
Lines Added:36
Lines Deleted:9
Also changed in: (Previous) 2.6.24-git15  2.6.24  2.6.24-rc8  2.6.24-rc7  2.6.24-rc6  2.6.24-rc5 
(Following) 2.6.24-git17  2.6.24-git18  2.6.24-git19  2.6.24-git20  2.6.24-git21  2.6.24-git22 

Location
[  2.6.24-git16
  [  fs
     o  xattr.c

Patch

diff --git a/fs/xattr.c b/fs/xattr.c
index 6645b73..f7c8f87 100644
--- a/fs/xattr.c
+++ b/fs/xattr.c
@@ -105,6 +105,33 @@ out:
 EXPORT_SYMBOL_GPL(vfs_setxattr);
 
 ssize_t
+xattr_getsecurity(struct inode *inode, const char *name, void *value,
+         size_t size)
+{
+   void *buffer = NULL;
+   ssize_t len;
+
+   if (!value || !size) {
+      len = security_inode_getsecurity(inode, name, &buffer, false);
+      goto out_noalloc;
+   }
+
+   len = security_inode_getsecurity(inode, name, &buffer, true);
+   if (len < 0)
+      return len;
+   if (size < len) {
+      len = -ERANGE;
+      goto out;
+   }
+   memcpy(value, buffer, len);
+out:
+   security_release_secctx(buffer, len);
+out_noalloc:
+   return len;
+}
+EXPORT_SYMBOL_GPL(xattr_getsecurity);
+
+ssize_t
 vfs_getxattr(struct dentry *dentry, char *name, void *value, size_t size)
 {
    struct inode *inode = dentry->d_inode;
@@ -118,23 +145,23 @@ vfs_getxattr(struct dentry *dentry, char *name, void *value, size_t size)
    if (error)
       return error;
 
-   if (inode->i_op->getxattr)
-      error = inode->i_op->getxattr(dentry, name, value, size);
-   else
-      error = -EOPNOTSUPP;
-
    if (!strncmp(name, XATTR_SECURITY_PREFIX,
             XATTR_SECURITY_PREFIX_LEN)) {
       const char *suffix = name + XATTR_SECURITY_PREFIX_LEN;
-      int ret = security_inode_getsecurity(inode, suffix, value,
-                       size, error);
+      int ret = xattr_getsecurity(inode, suffix, value, size);
       /*
        * Only overwrite the return value if a security module
        * is actually active.
        */
-      if (ret != -EOPNOTSUPP)
-         error = ret;
+      if (ret == -EOPNOTSUPP)
+         goto nolsm;
+      return ret;
    }
+nolsm:
+   if (inode->i_op->getxattr)
+      error = inode->i_op->getxattr(dentry, name, value, size);
+   else
+      error = -EOPNOTSUPP;
 
    return error;
 }


Comments: webmaster (at) linuxhq.com.
Advertising: banners (at) linuxhq.com.
Compilation ©1998-2008 Linux Headquarters, Inc.