~apparmor-dev/apparmor/2_3

« back to all changes in this revision

Viewing changes to kernel-patches/for-mainline/security-rmdir.diff

  • Committer: jrjohansen
  • Date: 2008-05-27 12:04:33 UTC
  • Revision ID: svn-v4:40609528-9d10-0410-9bd8-e926d5471da9:branches/2_3:1265
remove for-mainline dir from kernel patches

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
From: Tony Jones <tonyj@suse.de>
2
 
Subject: Pass struct vfsmount to the inode_rmdir LSM hook
3
 
 
4
 
This is needed for computing pathnames in the AppArmor LSM.
5
 
 
6
 
Signed-off-by: Tony Jones <tonyj@suse.de>
7
 
Signed-off-by: Andreas Gruenbacher <agruen@suse.de>
8
 
Signed-off-by: John Johansen <jjohansen@suse.de>
9
 
 
10
 
---
11
 
 fs/namei.c               |    2 +-
12
 
 include/linux/security.h |   10 +++++++---
13
 
 security/dummy.c         |    3 ++-
14
 
 security/security.c      |    5 +++--
15
 
 security/selinux/hooks.c |    3 ++-
16
 
 5 files changed, 15 insertions(+), 8 deletions(-)
17
 
 
18
 
--- a/fs/namei.c
19
 
+++ b/fs/namei.c
20
 
@@ -2104,7 +2104,7 @@ int vfs_rmdir(struct inode *dir, struct 
21
 
        if (d_mountpoint(dentry))
22
 
                error = -EBUSY;
23
 
        else {
24
 
-               error = security_inode_rmdir(dir, dentry);
25
 
+               error = security_inode_rmdir(dir, dentry, mnt);
26
 
                if (!error) {
27
 
                        error = dir->i_op->rmdir(dir, dentry);
28
 
                        if (!error)
29
 
--- a/include/linux/security.h
30
 
+++ b/include/linux/security.h
31
 
@@ -332,6 +332,7 @@ struct request_sock;
32
 
  *     Check the permission to remove a directory.
33
 
  *     @dir contains the inode structure of parent of the directory to be removed.
34
 
  *     @dentry contains the dentry structure of directory to be removed.
35
 
+ *     @mnt is the vfsmount corresponding to @dentry (may be NULL).
36
 
  *     Return 0 if permission is granted.
37
 
  * @inode_mknod:
38
 
  *     Check permissions when creating a special file (or a socket or a fifo
39
 
@@ -1265,7 +1266,8 @@ struct security_operations {
40
 
                              struct vfsmount *mnt, const char *old_name);
41
 
        int (*inode_mkdir) (struct inode *dir, struct dentry *dentry,
42
 
                            struct vfsmount *mnt, int mode);
43
 
-       int (*inode_rmdir) (struct inode *dir, struct dentry *dentry);
44
 
+       int (*inode_rmdir) (struct inode *dir, struct dentry *dentry,
45
 
+                           struct vfsmount *mnt);
46
 
        int (*inode_mknod) (struct inode *dir, struct dentry *dentry,
47
 
                            struct vfsmount *mnt, int mode, dev_t dev);
48
 
        int (*inode_rename) (struct inode *old_dir, struct dentry *old_dentry,
49
 
@@ -1524,7 +1526,8 @@ int security_inode_symlink(struct inode 
50
 
                           struct vfsmount *mnt, const char *old_name);
51
 
 int security_inode_mkdir(struct inode *dir, struct dentry *dentry,
52
 
                         struct vfsmount *mnt, int mode);
53
 
-int security_inode_rmdir(struct inode *dir, struct dentry *dentry);
54
 
+int security_inode_rmdir(struct inode *dir, struct dentry *dentry,
55
 
+                        struct vfsmount *mnt);
56
 
 int security_inode_mknod(struct inode *dir, struct dentry *dentry,
57
 
                         struct vfsmount *mnt, int mode, dev_t dev);
58
 
 int security_inode_rename(struct inode *old_dir, struct dentry *old_dentry,
59
 
@@ -1867,7 +1870,8 @@ static inline int security_inode_mkdir (
60
 
 }
61
 
 
62
 
 static inline int security_inode_rmdir (struct inode *dir,
63
 
-                                       struct dentry *dentry)
64
 
+                                       struct dentry *dentry,
65
 
+                                       struct vfsmount *mnt)
66
 
 {
67
 
        return 0;
68
 
 }
69
 
--- a/security/dummy.c
70
 
+++ b/security/dummy.c
71
 
@@ -292,7 +292,8 @@ static int dummy_inode_mkdir (struct ino
72
 
        return 0;
73
 
 }
74
 
 
75
 
-static int dummy_inode_rmdir (struct inode *inode, struct dentry *dentry)
76
 
+static int dummy_inode_rmdir (struct inode *inode, struct dentry *dentry,
77
 
+                             struct vfsmount *mnt)
78
 
 {
79
 
        return 0;
80
 
 }
81
 
--- a/security/security.c
82
 
+++ b/security/security.c
83
 
@@ -369,11 +369,12 @@ int security_inode_mkdir(struct inode *d
84
 
        return security_ops->inode_mkdir(dir, dentry, mnt, mode);
85
 
 }
86
 
 
87
 
-int security_inode_rmdir(struct inode *dir, struct dentry *dentry)
88
 
+int security_inode_rmdir(struct inode *dir, struct dentry *dentry,
89
 
+                        struct vfsmount *mnt)
90
 
 {
91
 
        if (unlikely(IS_PRIVATE(dentry->d_inode)))
92
 
                return 0;
93
 
-       return security_ops->inode_rmdir(dir, dentry);
94
 
+       return security_ops->inode_rmdir(dir, dentry, mnt);
95
 
 }
96
 
 
97
 
 int security_inode_mknod(struct inode *dir, struct dentry *dentry,
98
 
--- a/security/selinux/hooks.c
99
 
+++ b/security/selinux/hooks.c
100
 
@@ -2227,7 +2227,8 @@ static int selinux_inode_mkdir(struct in
101
 
        return may_create(dir, dentry, SECCLASS_DIR);
102
 
 }
103
 
 
104
 
-static int selinux_inode_rmdir(struct inode *dir, struct dentry *dentry)
105
 
+static int selinux_inode_rmdir(struct inode *dir, struct dentry *dentry,
106
 
+                              struct vfsmount *mnt)
107
 
 {
108
 
        return may_link(dir, dentry, MAY_RMDIR);
109
 
 }