Commit 415b536d authored by Jeff Mahoney's avatar Jeff Mahoney Committed by Linus Torvalds

[PATCH] vfs: adds the S_PRIVATE flag and adds use to security

This patch series adds SELinux support to reiserfs.

This patch adds an S_PRIVATE flag to inode->i_flags to mark an inode as
filesystem-internal. As such, it should be excepted from the security
infrastructure to allow the filesystem to perform its own access control.
Signed-off-by: default avatarJeff Mahoney <jeffm@suse.com>
Acked-by: default avatarStephen Smalley <sds@tycho.nsa.gov>
Acked-by: default avatarChris Wright <chrisw@osdl.org>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 5d5d3694
...@@ -129,6 +129,7 @@ extern int dir_notify_enable; ...@@ -129,6 +129,7 @@ extern int dir_notify_enable;
#define S_DIRSYNC 64 /* Directory modifications are synchronous */ #define S_DIRSYNC 64 /* Directory modifications are synchronous */
#define S_NOCMTIME 128 /* Do not update file c/mtime */ #define S_NOCMTIME 128 /* Do not update file c/mtime */
#define S_SWAPFILE 256 /* Do not truncate: swapon got its bmaps */ #define S_SWAPFILE 256 /* Do not truncate: swapon got its bmaps */
#define S_PRIVATE 512 /* Inode is fs-internal */
/* /*
* Note that nosuid etc flags are inode-specific: setting some file-system * Note that nosuid etc flags are inode-specific: setting some file-system
...@@ -162,6 +163,7 @@ extern int dir_notify_enable; ...@@ -162,6 +163,7 @@ extern int dir_notify_enable;
#define IS_DEADDIR(inode) ((inode)->i_flags & S_DEAD) #define IS_DEADDIR(inode) ((inode)->i_flags & S_DEAD)
#define IS_NOCMTIME(inode) ((inode)->i_flags & S_NOCMTIME) #define IS_NOCMTIME(inode) ((inode)->i_flags & S_NOCMTIME)
#define IS_SWAPFILE(inode) ((inode)->i_flags & S_SWAPFILE) #define IS_SWAPFILE(inode) ((inode)->i_flags & S_SWAPFILE)
#define IS_PRIVATE(inode) ((inode)->i_flags & S_PRIVATE)
/* the read-only stuff doesn't really belong here, but any other place is /* the read-only stuff doesn't really belong here, but any other place is
probably as bad and I don't want to create yet another include file. */ probably as bad and I don't want to create yet another include file. */
......
...@@ -1426,11 +1426,15 @@ static inline void security_sb_post_pivotroot (struct nameidata *old_nd, ...@@ -1426,11 +1426,15 @@ static inline void security_sb_post_pivotroot (struct nameidata *old_nd,
static inline int security_inode_alloc (struct inode *inode) static inline int security_inode_alloc (struct inode *inode)
{ {
if (unlikely (IS_PRIVATE (inode)))
return 0;
return security_ops->inode_alloc_security (inode); return security_ops->inode_alloc_security (inode);
} }
static inline void security_inode_free (struct inode *inode) static inline void security_inode_free (struct inode *inode)
{ {
if (unlikely (IS_PRIVATE (inode)))
return;
security_ops->inode_free_security (inode); security_ops->inode_free_security (inode);
} }
...@@ -1438,6 +1442,8 @@ static inline int security_inode_create (struct inode *dir, ...@@ -1438,6 +1442,8 @@ static inline int security_inode_create (struct inode *dir,
struct dentry *dentry, struct dentry *dentry,
int mode) int mode)
{ {
if (unlikely (IS_PRIVATE (dir)))
return 0;
return security_ops->inode_create (dir, dentry, mode); return security_ops->inode_create (dir, dentry, mode);
} }
...@@ -1445,6 +1451,8 @@ static inline void security_inode_post_create (struct inode *dir, ...@@ -1445,6 +1451,8 @@ static inline void security_inode_post_create (struct inode *dir,
struct dentry *dentry, struct dentry *dentry,
int mode) int mode)
{ {
if (dentry->d_inode && unlikely (IS_PRIVATE (dentry->d_inode)))
return;
security_ops->inode_post_create (dir, dentry, mode); security_ops->inode_post_create (dir, dentry, mode);
} }
...@@ -1452,6 +1460,8 @@ static inline int security_inode_link (struct dentry *old_dentry, ...@@ -1452,6 +1460,8 @@ static inline int security_inode_link (struct dentry *old_dentry,
struct inode *dir, struct inode *dir,
struct dentry *new_dentry) struct dentry *new_dentry)
{ {
if (unlikely (IS_PRIVATE (old_dentry->d_inode)))
return 0;
return security_ops->inode_link (old_dentry, dir, new_dentry); return security_ops->inode_link (old_dentry, dir, new_dentry);
} }
...@@ -1459,12 +1469,16 @@ static inline void security_inode_post_link (struct dentry *old_dentry, ...@@ -1459,12 +1469,16 @@ static inline void security_inode_post_link (struct dentry *old_dentry,
struct inode *dir, struct inode *dir,
struct dentry *new_dentry) struct dentry *new_dentry)
{ {
if (new_dentry->d_inode && unlikely (IS_PRIVATE (new_dentry->d_inode)))
return;
security_ops->inode_post_link (old_dentry, dir, new_dentry); security_ops->inode_post_link (old_dentry, dir, new_dentry);
} }
static inline int security_inode_unlink (struct inode *dir, static inline int security_inode_unlink (struct inode *dir,
struct dentry *dentry) struct dentry *dentry)
{ {
if (unlikely (IS_PRIVATE (dentry->d_inode)))
return 0;
return security_ops->inode_unlink (dir, dentry); return security_ops->inode_unlink (dir, dentry);
} }
...@@ -1472,6 +1486,8 @@ static inline int security_inode_symlink (struct inode *dir, ...@@ -1472,6 +1486,8 @@ static inline int security_inode_symlink (struct inode *dir,
struct dentry *dentry, struct dentry *dentry,
const char *old_name) const char *old_name)
{ {
if (unlikely (IS_PRIVATE (dir)))
return 0;
return security_ops->inode_symlink (dir, dentry, old_name); return security_ops->inode_symlink (dir, dentry, old_name);
} }
...@@ -1479,6 +1495,8 @@ static inline void security_inode_post_symlink (struct inode *dir, ...@@ -1479,6 +1495,8 @@ static inline void security_inode_post_symlink (struct inode *dir,
struct dentry *dentry, struct dentry *dentry,
const char *old_name) const char *old_name)
{ {
if (dentry->d_inode && unlikely (IS_PRIVATE (dentry->d_inode)))
return;
security_ops->inode_post_symlink (dir, dentry, old_name); security_ops->inode_post_symlink (dir, dentry, old_name);
} }
...@@ -1486,6 +1504,8 @@ static inline int security_inode_mkdir (struct inode *dir, ...@@ -1486,6 +1504,8 @@ static inline int security_inode_mkdir (struct inode *dir,
struct dentry *dentry, struct dentry *dentry,
int mode) int mode)
{ {
if (unlikely (IS_PRIVATE (dir)))
return 0;
return security_ops->inode_mkdir (dir, dentry, mode); return security_ops->inode_mkdir (dir, dentry, mode);
} }
...@@ -1493,12 +1513,16 @@ static inline void security_inode_post_mkdir (struct inode *dir, ...@@ -1493,12 +1513,16 @@ static inline void security_inode_post_mkdir (struct inode *dir,
struct dentry *dentry, struct dentry *dentry,
int mode) int mode)
{ {
if (dentry->d_inode && unlikely (IS_PRIVATE (dentry->d_inode)))
return;
security_ops->inode_post_mkdir (dir, dentry, mode); security_ops->inode_post_mkdir (dir, dentry, mode);
} }
static inline int security_inode_rmdir (struct inode *dir, static inline int security_inode_rmdir (struct inode *dir,
struct dentry *dentry) struct dentry *dentry)
{ {
if (unlikely (IS_PRIVATE (dentry->d_inode)))
return 0;
return security_ops->inode_rmdir (dir, dentry); return security_ops->inode_rmdir (dir, dentry);
} }
...@@ -1506,6 +1530,8 @@ static inline int security_inode_mknod (struct inode *dir, ...@@ -1506,6 +1530,8 @@ static inline int security_inode_mknod (struct inode *dir,
struct dentry *dentry, struct dentry *dentry,
int mode, dev_t dev) int mode, dev_t dev)
{ {
if (unlikely (IS_PRIVATE (dir)))
return 0;
return security_ops->inode_mknod (dir, dentry, mode, dev); return security_ops->inode_mknod (dir, dentry, mode, dev);
} }
...@@ -1513,6 +1539,8 @@ static inline void security_inode_post_mknod (struct inode *dir, ...@@ -1513,6 +1539,8 @@ static inline void security_inode_post_mknod (struct inode *dir,
struct dentry *dentry, struct dentry *dentry,
int mode, dev_t dev) int mode, dev_t dev)
{ {
if (dentry->d_inode && unlikely (IS_PRIVATE (dentry->d_inode)))
return;
security_ops->inode_post_mknod (dir, dentry, mode, dev); security_ops->inode_post_mknod (dir, dentry, mode, dev);
} }
...@@ -1521,6 +1549,9 @@ static inline int security_inode_rename (struct inode *old_dir, ...@@ -1521,6 +1549,9 @@ static inline int security_inode_rename (struct inode *old_dir,
struct inode *new_dir, struct inode *new_dir,
struct dentry *new_dentry) struct dentry *new_dentry)
{ {
if (unlikely (IS_PRIVATE (old_dentry->d_inode) ||
(new_dentry->d_inode && IS_PRIVATE (new_dentry->d_inode))))
return 0;
return security_ops->inode_rename (old_dir, old_dentry, return security_ops->inode_rename (old_dir, old_dentry,
new_dir, new_dentry); new_dir, new_dentry);
} }
...@@ -1530,83 +1561,114 @@ static inline void security_inode_post_rename (struct inode *old_dir, ...@@ -1530,83 +1561,114 @@ static inline void security_inode_post_rename (struct inode *old_dir,
struct inode *new_dir, struct inode *new_dir,
struct dentry *new_dentry) struct dentry *new_dentry)
{ {
if (unlikely (IS_PRIVATE (old_dentry->d_inode) ||
(new_dentry->d_inode && IS_PRIVATE (new_dentry->d_inode))))
return;
security_ops->inode_post_rename (old_dir, old_dentry, security_ops->inode_post_rename (old_dir, old_dentry,
new_dir, new_dentry); new_dir, new_dentry);
} }
static inline int security_inode_readlink (struct dentry *dentry) static inline int security_inode_readlink (struct dentry *dentry)
{ {
if (unlikely (IS_PRIVATE (dentry->d_inode)))
return 0;
return security_ops->inode_readlink (dentry); return security_ops->inode_readlink (dentry);
} }
static inline int security_inode_follow_link (struct dentry *dentry, static inline int security_inode_follow_link (struct dentry *dentry,
struct nameidata *nd) struct nameidata *nd)
{ {
if (unlikely (IS_PRIVATE (dentry->d_inode)))
return 0;
return security_ops->inode_follow_link (dentry, nd); return security_ops->inode_follow_link (dentry, nd);
} }
static inline int security_inode_permission (struct inode *inode, int mask, static inline int security_inode_permission (struct inode *inode, int mask,
struct nameidata *nd) struct nameidata *nd)
{ {
if (unlikely (IS_PRIVATE (inode)))
return 0;
return security_ops->inode_permission (inode, mask, nd); return security_ops->inode_permission (inode, mask, nd);
} }
static inline int security_inode_setattr (struct dentry *dentry, static inline int security_inode_setattr (struct dentry *dentry,
struct iattr *attr) struct iattr *attr)
{ {
if (unlikely (IS_PRIVATE (dentry->d_inode)))
return 0;
return security_ops->inode_setattr (dentry, attr); return security_ops->inode_setattr (dentry, attr);
} }
static inline int security_inode_getattr (struct vfsmount *mnt, static inline int security_inode_getattr (struct vfsmount *mnt,
struct dentry *dentry) struct dentry *dentry)
{ {
if (unlikely (IS_PRIVATE (dentry->d_inode)))
return 0;
return security_ops->inode_getattr (mnt, dentry); return security_ops->inode_getattr (mnt, dentry);
} }
static inline void security_inode_delete (struct inode *inode) static inline void security_inode_delete (struct inode *inode)
{ {
if (unlikely (IS_PRIVATE (inode)))
return;
security_ops->inode_delete (inode); security_ops->inode_delete (inode);
} }
static inline int security_inode_setxattr (struct dentry *dentry, char *name, static inline int security_inode_setxattr (struct dentry *dentry, char *name,
void *value, size_t size, int flags) void *value, size_t size, int flags)
{ {
if (unlikely (IS_PRIVATE (dentry->d_inode)))
return 0;
return security_ops->inode_setxattr (dentry, name, value, size, flags); return security_ops->inode_setxattr (dentry, name, value, size, flags);
} }
static inline void security_inode_post_setxattr (struct dentry *dentry, char *name, static inline void security_inode_post_setxattr (struct dentry *dentry, char *name,
void *value, size_t size, int flags) void *value, size_t size, int flags)
{ {
if (unlikely (IS_PRIVATE (dentry->d_inode)))
return;
security_ops->inode_post_setxattr (dentry, name, value, size, flags); security_ops->inode_post_setxattr (dentry, name, value, size, flags);
} }
static inline int security_inode_getxattr (struct dentry *dentry, char *name) static inline int security_inode_getxattr (struct dentry *dentry, char *name)
{ {
if (unlikely (IS_PRIVATE (dentry->d_inode)))
return 0;
return security_ops->inode_getxattr (dentry, name); return security_ops->inode_getxattr (dentry, name);
} }
static inline int security_inode_listxattr (struct dentry *dentry) static inline int security_inode_listxattr (struct dentry *dentry)
{ {
if (unlikely (IS_PRIVATE (dentry->d_inode)))
return 0;
return security_ops->inode_listxattr (dentry); return security_ops->inode_listxattr (dentry);
} }
static inline int security_inode_removexattr (struct dentry *dentry, char *name) static inline int security_inode_removexattr (struct dentry *dentry, char *name)
{ {
if (unlikely (IS_PRIVATE (dentry->d_inode)))
return 0;
return security_ops->inode_removexattr (dentry, name); return security_ops->inode_removexattr (dentry, name);
} }
static inline int security_inode_getsecurity(struct inode *inode, const char *name, void *buffer, size_t size) static inline int security_inode_getsecurity(struct inode *inode, const char *name, void *buffer, size_t size)
{ {
if (unlikely (IS_PRIVATE (inode)))
return 0;
return security_ops->inode_getsecurity(inode, name, buffer, size); return security_ops->inode_getsecurity(inode, name, buffer, size);
} }
static inline int security_inode_setsecurity(struct inode *inode, const char *name, const void *value, size_t size, int flags) static inline int security_inode_setsecurity(struct inode *inode, const char *name, const void *value, size_t size, int flags)
{ {
if (unlikely (IS_PRIVATE (inode)))
return 0;
return security_ops->inode_setsecurity(inode, name, value, size, flags); return security_ops->inode_setsecurity(inode, name, value, size, flags);
} }
static inline int security_inode_listsecurity(struct inode *inode, char *buffer, size_t buffer_size) static inline int security_inode_listsecurity(struct inode *inode, char *buffer, size_t buffer_size)
{ {
if (unlikely (IS_PRIVATE (inode)))
return 0;
return security_ops->inode_listsecurity(inode, buffer, buffer_size); return security_ops->inode_listsecurity(inode, buffer, buffer_size);
} }
...@@ -1883,6 +1945,8 @@ static inline int security_sem_semop (struct sem_array * sma, ...@@ -1883,6 +1945,8 @@ static inline int security_sem_semop (struct sem_array * sma,
static inline void security_d_instantiate (struct dentry *dentry, struct inode *inode) static inline void security_d_instantiate (struct dentry *dentry, struct inode *inode)
{ {
if (unlikely (inode && IS_PRIVATE (inode)))
return;
security_ops->d_instantiate (dentry, inode); security_ops->d_instantiate (dentry, inode);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment