diff --git a/fs/9p/acl.c b/fs/9p/acl.c index 7350f53f3b51bb53b5f8d3cdc9d9c876b29afaf5..8be87857605ce1aaea75c007a6264348f934a4d9 100644 --- a/fs/9p/acl.c +++ b/fs/9p/acl.c @@ -101,9 +101,6 @@ int v9fs_check_acl(struct inode *inode, int mask) struct posix_acl *acl; struct v9fs_session_info *v9ses; - if (mask & MAY_NOT_BLOCK) - return -ECHILD; - v9ses = v9fs_inode2v9ses(inode); if (((v9ses->flags & V9FS_ACCESS_MASK) != V9FS_ACCESS_CLIENT) || ((v9ses->flags & V9FS_ACL_MASK) != V9FS_POSIX_ACL)) { diff --git a/fs/btrfs/acl.c b/fs/btrfs/acl.c index 9f62ab2a7282ed49aeacc560ef8586b09ce37b24..c13ea9fbf36b1ab766264c86bb8f80c8cc21c64f 100644 --- a/fs/btrfs/acl.c +++ b/fs/btrfs/acl.c @@ -198,19 +198,14 @@ static int btrfs_xattr_acl_set(struct dentry *dentry, const char *name, int btrfs_check_acl(struct inode *inode, int mask) { int error = -EAGAIN; + struct posix_acl *acl; - if (mask & MAY_NOT_BLOCK) { - if (!negative_cached_acl(inode, ACL_TYPE_ACCESS)) - error = -ECHILD; - } else { - struct posix_acl *acl; - acl = btrfs_get_acl(inode, ACL_TYPE_ACCESS); - if (IS_ERR(acl)) - return PTR_ERR(acl); - if (acl) { - error = posix_acl_permission(inode, acl, mask); - posix_acl_release(acl); - } + acl = btrfs_get_acl(inode, ACL_TYPE_ACCESS); + if (IS_ERR(acl)) + return PTR_ERR(acl); + if (acl) { + error = posix_acl_permission(inode, acl, mask); + posix_acl_release(acl); } return error; diff --git a/fs/ext2/acl.c b/fs/ext2/acl.c index bfe651f9ae1631ab0abd40281d92f18974530565..ced1c478ebdb4873afe1175005288055c00840e1 100644 --- a/fs/ext2/acl.c +++ b/fs/ext2/acl.c @@ -236,12 +236,6 @@ ext2_check_acl(struct inode *inode, int mask) { struct posix_acl *acl; - if (mask & MAY_NOT_BLOCK) { - if (!negative_cached_acl(inode, ACL_TYPE_ACCESS)) - return -ECHILD; - return -EAGAIN; - } - acl = ext2_get_acl(inode, ACL_TYPE_ACCESS); if (IS_ERR(acl)) return PTR_ERR(acl); diff --git a/fs/ext3/acl.c b/fs/ext3/acl.c index edfeb293d4cb601457339ca97d5ceeae64416623..5326038e8536a60563325eb0c90cf2cf06f6284d 100644 --- a/fs/ext3/acl.c +++ b/fs/ext3/acl.c @@ -244,12 +244,6 @@ ext3_check_acl(struct inode *inode, int mask) { struct posix_acl *acl; - if (mask & MAY_NOT_BLOCK) { - if (!negative_cached_acl(inode, ACL_TYPE_ACCESS)) - return -ECHILD; - return -EAGAIN; - } - acl = ext3_get_acl(inode, ACL_TYPE_ACCESS); if (IS_ERR(acl)) return PTR_ERR(acl); diff --git a/fs/ext4/acl.c b/fs/ext4/acl.c index 60d900fcc3dbbee54bba6d8ef4c77c8a3aa3bc39..4cd9e2e4085e3e0056ba63da04471a8f23995b12 100644 --- a/fs/ext4/acl.c +++ b/fs/ext4/acl.c @@ -242,12 +242,6 @@ ext4_check_acl(struct inode *inode, int mask) { struct posix_acl *acl; - if (mask & MAY_NOT_BLOCK) { - if (!negative_cached_acl(inode, ACL_TYPE_ACCESS)) - return -ECHILD; - return -EAGAIN; - } - acl = ext4_get_acl(inode, ACL_TYPE_ACCESS); if (IS_ERR(acl)) return PTR_ERR(acl); diff --git a/fs/generic_acl.c b/fs/generic_acl.c index 70e90b4974cedd355467552653eae47ab3b07cd0..4949473d354281362e35076fe1190dfd5012b5f9 100644 --- a/fs/generic_acl.c +++ b/fs/generic_acl.c @@ -192,18 +192,13 @@ generic_acl_chmod(struct inode *inode) int generic_check_acl(struct inode *inode, int mask) { - if (mask & MAY_NOT_BLOCK) { - if (!negative_cached_acl(inode, ACL_TYPE_ACCESS)) - return -ECHILD; - } else { - struct posix_acl *acl; - - acl = get_cached_acl(inode, ACL_TYPE_ACCESS); - if (acl) { - int error = posix_acl_permission(inode, acl, mask); - posix_acl_release(acl); - return error; - } + struct posix_acl *acl; + + acl = get_cached_acl(inode, ACL_TYPE_ACCESS); + if (acl) { + int error = posix_acl_permission(inode, acl, mask); + posix_acl_release(acl); + return error; } return -EAGAIN; } diff --git a/fs/gfs2/acl.c b/fs/gfs2/acl.c index 8ef1079f166503e9c4c1a16dd9ea0eb57f2c5875..48171f4c943dbb2523a22011a25aca402fe3e6e5 100644 --- a/fs/gfs2/acl.c +++ b/fs/gfs2/acl.c @@ -80,12 +80,6 @@ int gfs2_check_acl(struct inode *inode, int mask) struct posix_acl *acl; int error; - if (mask & MAY_NOT_BLOCK) { - if (!negative_cached_acl(inode, ACL_TYPE_ACCESS)) - return -ECHILD; - return -EAGAIN; - } - acl = gfs2_acl_get(GFS2_I(inode), ACL_TYPE_ACCESS); if (IS_ERR(acl)) return PTR_ERR(acl); diff --git a/fs/jffs2/acl.c b/fs/jffs2/acl.c index f9c302430aa12e68b75835a431d6d3a26b6d383e..4933a8f8ecc9317180318128e81896655b18b18a 100644 --- a/fs/jffs2/acl.c +++ b/fs/jffs2/acl.c @@ -264,9 +264,6 @@ int jffs2_check_acl(struct inode *inode, int mask) struct posix_acl *acl; int rc; - if (mask & MAY_NOT_BLOCK) - return -ECHILD; - acl = jffs2_get_acl(inode, ACL_TYPE_ACCESS); if (IS_ERR(acl)) return PTR_ERR(acl); diff --git a/fs/jfs/acl.c b/fs/jfs/acl.c index 8a0a0666d5a6f141e4f1f5f387d3b69db9a02938..ead200eef5e4fdae4b9c260e050d23e5a96ecc51 100644 --- a/fs/jfs/acl.c +++ b/fs/jfs/acl.c @@ -118,9 +118,6 @@ int jfs_check_acl(struct inode *inode, int mask) { struct posix_acl *acl; - if (mask & MAY_NOT_BLOCK) - return -ECHILD; - acl = jfs_get_acl(inode, ACL_TYPE_ACCESS); if (IS_ERR(acl)) return PTR_ERR(acl); diff --git a/fs/namei.c b/fs/namei.c index b7fad009bbf69884ab938ed26d4fd6ab0a257d9c..120efc76d3d06e3980db48c97199e9b604b5c94c 100644 --- a/fs/namei.c +++ b/fs/namei.c @@ -32,6 +32,7 @@ #include #include #include +#include #include #include "internal.h" @@ -173,12 +174,58 @@ void putname(const char *name) EXPORT_SYMBOL(putname); #endif +static int check_acl(struct inode *inode, int mask) +{ + struct posix_acl *acl; + + /* + * Under RCU walk, we cannot even do a "get_cached_acl()", + * because that involves locking and getting a refcount on + * a cached ACL. + * + * So the only case we handle during RCU walking is the + * case of a cached "no ACL at all", which needs no locks + * or refcounts. + */ + if (mask & MAY_NOT_BLOCK) { + if (negative_cached_acl(inode, ACL_TYPE_ACCESS)) + return -EAGAIN; + return -ECHILD; + } + + acl = get_cached_acl(inode, ACL_TYPE_ACCESS); + + /* + * A filesystem can force a ACL callback by just never + * filling the ACL cache. But normally you'd fill the + * cache either at inode instantiation time, or on the + * first ->check_acl call. + * + * If the filesystem doesn't have a check_acl() function + * at all, we'll just create the negative cache entry. + */ + if (acl == ACL_NOT_CACHED) { + if (inode->i_op->check_acl) + return inode->i_op->check_acl(inode, mask); + + set_cached_acl(inode, ACL_TYPE_ACCESS, NULL); + return -EAGAIN; + } + + if (acl) { + int error = posix_acl_permission(inode, acl, mask); + posix_acl_release(acl); + return error; + } + + return -EAGAIN; +} + /* * This does basic POSIX ACL permission checking */ static int acl_permission_check(struct inode *inode, int mask) { - int (*check_acl)(struct inode *inode, int mask); unsigned int mode = inode->i_mode; mask &= MAY_READ | MAY_WRITE | MAY_EXEC | MAY_NOT_BLOCK; @@ -189,8 +236,7 @@ static int acl_permission_check(struct inode *inode, int mask) if (current_fsuid() == inode->i_uid) mode >>= 6; else { - check_acl = inode->i_op->check_acl; - if (IS_POSIXACL(inode) && (mode & S_IRWXG) && check_acl) { + if (IS_POSIXACL(inode) && (mode & S_IRWXG)) { int error = check_acl(inode, mask); if (error != -EAGAIN) return error; diff --git a/fs/ocfs2/acl.c b/fs/ocfs2/acl.c index f4cf451ce6e87bbae2759564c799c2539462851b..aff23e59b58c4c39016f7e2bc5719fea2057cf8a 100644 --- a/fs/ocfs2/acl.c +++ b/fs/ocfs2/acl.c @@ -297,9 +297,6 @@ int ocfs2_check_acl(struct inode *inode, int mask) struct posix_acl *acl; int ret = -EAGAIN; - if (mask & MAY_NOT_BLOCK) - return -ECHILD; - osb = OCFS2_SB(inode->i_sb); if (!(osb->s_mount_opt & OCFS2_MOUNT_POSIX_ACL)) return ret; diff --git a/fs/xfs/linux-2.6/xfs_acl.c b/fs/xfs/linux-2.6/xfs_acl.c index cac48fe22ad513ae3a85dd47beed88ce5011886f..f6d065ac56b596dc0d9c89f7ebff0998645b2dd2 100644 --- a/fs/xfs/linux-2.6/xfs_acl.c +++ b/fs/xfs/linux-2.6/xfs_acl.c @@ -231,16 +231,12 @@ xfs_check_acl(struct inode *inode, int mask) /* * If there is no attribute fork no ACL exists on this inode and * we can skip the whole exercise. + * + * FIXME! Fill the cache! Locking? */ if (!XFS_IFORK_Q(ip)) return -EAGAIN; - if (mask & MAY_NOT_BLOCK) { - if (!negative_cached_acl(inode, ACL_TYPE_ACCESS)) - return -ECHILD; - return -EAGAIN; - } - acl = xfs_get_acl(inode, ACL_TYPE_ACCESS); if (IS_ERR(acl)) return PTR_ERR(acl);