Gitweb:     
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=4bea58053f206be9a89ca35850f9ad295dac2042
Commit:     4bea58053f206be9a89ca35850f9ad295dac2042
Parent:     42492594043d621a7910ff5877c3eb9202870b45
Author:     David P. Quigley <[EMAIL PROTECTED]>
AuthorDate: Mon Feb 4 22:29:40 2008 -0800
Committer:  Linus Torvalds <[EMAIL PROTECTED]>
CommitDate: Tue Feb 5 09:44:20 2008 -0800

    VFS: Reorder vfs_getxattr to avoid unnecessary calls to the LSM
    
    Originally vfs_getxattr would pull the security xattr variable using
    the inode getxattr handle and then proceed to clobber it with a subsequent 
call
    to the LSM.
    
    This patch reorders the two operations such that when the xattr requested is
    in the security namespace it first attempts to grab the value from the LSM
    directly.
    
    If it fails to obtain the value because there is no module present or the
    module does not support the operation it will fall back to using the inode
    getxattr operation.
    
    In the event that both are inaccessible it returns EOPNOTSUPP.
    
    Signed-off-by: David P. Quigley <[EMAIL PROTECTED]>
    Cc: Stephen Smalley <[EMAIL PROTECTED]>
    Cc: Chris Wright <[EMAIL PROTECTED]>
    Acked-by: James Morris <[EMAIL PROTECTED]>
    Acked-by: Serge Hallyn <[EMAIL PROTECTED]>
    Cc: Casey Schaufler <[EMAIL PROTECTED]>
    Cc: Al Viro <[EMAIL PROTECTED]>
    Cc: Christoph Hellwig <[EMAIL PROTECTED]>
    Signed-off-by: Andrew Morton <[EMAIL PROTECTED]>
    Signed-off-by: Linus Torvalds <[EMAIL PROTECTED]>
---
 fs/xattr.c |   15 ++++++++-------
 1 files changed, 8 insertions(+), 7 deletions(-)

diff --git a/fs/xattr.c b/fs/xattr.c
index 1858552..f7c8f87 100644
--- a/fs/xattr.c
+++ b/fs/xattr.c
@@ -145,11 +145,6 @@ 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;
@@ -158,9 +153,15 @@ vfs_getxattr(struct dentry *dentry, char *name, void 
*value, size_t 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;
 }
-
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to