Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Richacl #109

Closed
wants to merge 27 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
d5d1fb4
vfs: Indicate that the permission functions take all the MAY_* flags
Oct 18, 2011
0f69c40
vfs: Add hex format for MAY_* flag values
kvaneesh Oct 18, 2011
bf56180
vfs: Pass all mask flags down to iop->check_acl
Oct 18, 2011
518cbba
vfs: Add a comment to inode_permission()
Oct 18, 2011
89e1033
vfs: Add generic IS_ACL() test for acl support
Oct 18, 2011
45481f1
vfs: Add IS_RICHACL() test for richacl support
Oct 18, 2011
c684918
vfs: Optimize out IS_RICHACL() if CONFIG_FS_RICHACL is not defined
Oct 18, 2011
004723e
vfs: Add new file and directory create permission flags
Oct 18, 2011
1654a09
vfs: Add delete child and delete self permission flags
Oct 18, 2011
3437a82
vfs: Make the inode passed to inode_change_ok non-const
Oct 18, 2011
e963a4c
vfs: Add permission flags for setting file attributes
Oct 18, 2011
26dc449
vfs: Make acl_permission_check() work for richacls
Oct 18, 2011
e210ab8
richacl: In-memory representation and helper functions
Oct 18, 2011
36ee026
richacl: Permission mapping functions
Oct 18, 2011
dc240c0
richacl: Compute maximum file masks from an acl
Oct 18, 2011
6be646b
richacl: Update the file masks in chmod()
Oct 18, 2011
61bf134
richacl: Permission check algorithm
Oct 18, 2011
9d9bef3
richacl: Create-time inheritance
Oct 18, 2011
8013f16
richacl: Check if an acl is equivalent to a file mode
Oct 18, 2011
5882a81
richacl: Automatic Inheritance
Oct 18, 2011
862d861
richacl: xattr mapping functions
Oct 18, 2011
69d9df5
vfs: Cache richacl in struct inode
Oct 18, 2011
e86e410
vfs: Add richacl permission check
kvaneesh Oct 18, 2011
434e398
ext4: Use IS_POSIXACL() to check for POSIX ACL support
kvaneesh Oct 18, 2011
69b47fd
ext4: Implement rich acl for ext4
kvaneesh Oct 18, 2011
e17ad31
ext4: Add Ext4 compat richacl feature flag
kvaneesh Oct 18, 2011
13fc237
ext4: Add temporary richacl mount option for ext4
kvaneesh Oct 18, 2011
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
vfs: Cache richacl in struct inode
Cache richacls in struct inode so that this doesn't have to be done
individually in each filesystem.

Acked-by: J. Bruce Fields <[email protected]>
Acked-by: David Howells <[email protected]>
Signed-off-by: Andreas Gruenbacher <[email protected]>
Signed-off-by: Aneesh Kumar K.V <[email protected]>
  • Loading branch information
Andreas Gruenbacher authored and kvaneesh committed Oct 23, 2011
commit 69d9df5683dcdd2473a29ed4498dfc09f4e94e01
25 changes: 20 additions & 5 deletions fs/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include <linux/ima.h>
#include <linux/cred.h>
#include <linux/buffer_head.h> /* for inode_has_buffers */
#include <linux/richacl.h>
#include "internal.h"

/*
Expand Down Expand Up @@ -192,7 +193,12 @@ int inode_init_always(struct super_block *sb, struct inode *inode)
inode->i_private = NULL;
inode->i_mapping = mapping;
#ifdef CONFIG_FS_POSIX_ACL
inode->i_acl = inode->i_default_acl = ACL_NOT_CACHED;
if (IS_POSIXACL(inode))
inode->i_acl = inode->i_default_acl = ACL_NOT_CACHED;
#endif
#ifdef CONFIG_FS_RICHACL
if (IS_RICHACL(inode))
inode->i_richacl = ACL_NOT_CACHED;
#endif

#ifdef CONFIG_FSNOTIFY
Expand Down Expand Up @@ -242,10 +248,19 @@ void __destroy_inode(struct inode *inode)
security_inode_free(inode);
fsnotify_inode_delete(inode);
#ifdef CONFIG_FS_POSIX_ACL
if (inode->i_acl && inode->i_acl != ACL_NOT_CACHED)
posix_acl_release(inode->i_acl);
if (inode->i_default_acl && inode->i_default_acl != ACL_NOT_CACHED)
posix_acl_release(inode->i_default_acl);
if (IS_POSIXACL(inode)) {
if (inode->i_acl && inode->i_acl != ACL_NOT_CACHED)
posix_acl_release(inode->i_acl);
if (inode->i_default_acl &&
inode->i_default_acl != ACL_NOT_CACHED)
posix_acl_release(inode->i_default_acl);
}
#endif
#ifdef CONFIG_FS_RICHACL
if (IS_RICHACL(inode)) {
if (inode->i_richacl && inode->i_richacl != ACL_NOT_CACHED)
richacl_put(inode->i_richacl);
}
#endif
this_cpu_dec(nr_inodes);
}
Expand Down
12 changes: 10 additions & 2 deletions include/linux/fs.h
Original file line number Diff line number Diff line change
Expand Up @@ -755,6 +755,7 @@ static inline int mapping_writably_mapped(struct address_space *mapping)
#endif

struct posix_acl;
struct richacl;
#define ACL_NOT_CACHED ((void *)(-1))

#define IOP_FASTPERM 0x0001
Expand All @@ -773,10 +774,17 @@ struct inode {
gid_t i_gid;
unsigned int i_flags;

union {
#ifdef CONFIG_FS_POSIX_ACL
struct posix_acl *i_acl;
struct posix_acl *i_default_acl;
struct {
struct posix_acl *i_acl;
struct posix_acl *i_default_acl;
};
#endif
#ifdef CONFIG_FS_RICHACL
struct richacl *i_richacl;
#endif
};

const struct inode_operations *i_op;
struct super_block *i_sb;
Expand Down
53 changes: 53 additions & 0 deletions include/linux/richacl.h
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,59 @@ richacl_put(struct richacl *acl)
kfree(acl);
}

#ifdef CONFIG_FS_RICHACL
static inline struct richacl *get_cached_richacl(struct inode *inode)
{
struct richacl **p, *acl;

p = &inode->i_richacl;
acl = ACCESS_ONCE(*p);
if (acl) {
spin_lock(&inode->i_lock);
acl = *p;
if (acl != ACL_NOT_CACHED)
acl = richacl_get(acl);
spin_unlock(&inode->i_lock);
}
return acl;
}

static inline void set_cached_richacl(struct inode *inode,
struct richacl *acl)
{
struct richacl *old = NULL;
spin_lock(&inode->i_lock);
old = inode->i_richacl;
inode->i_richacl = richacl_get(acl);
spin_unlock(&inode->i_lock);
if (old != ACL_NOT_CACHED)
richacl_put(old);
}

static inline void forget_cached_richacl(struct inode *inode)
{
struct richacl *old = NULL;
spin_lock(&inode->i_lock);
old = inode->i_richacl;
inode->i_richacl = ACL_NOT_CACHED;
spin_unlock(&inode->i_lock);
if (old != ACL_NOT_CACHED)
richacl_put(old);
}

static inline int negative_cached_richacl(struct inode *inode)
{
struct richacl **p, *acl;

p = &inode->i_richacl;
acl = ACCESS_ONCE(*p);
if (acl)
return 0;
return 1;
}

#endif

static inline int
richacl_is_auto_inherit(const struct richacl *acl)
{
Expand Down