~ubuntu-branches/ubuntu/wily/apparmor/wily

« back to all changes in this revision

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

  • Committer: Bazaar Package Importer
  • Author(s): Kees Cook
  • Date: 2011-04-27 10:38:07 UTC
  • mfrom: (5.1.118 natty)
  • Revision ID: james.westby@ubuntu.com-20110427103807-ym3rhwys6o84ith0
Tags: 2.6.1-2
debian/copyright: clarify for some full organization names.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
Pass struct vfsmount to the inode_create LSM hook.
2
 
 
3
 
Signed-off-by: Tony Jones <tonyj@suse.de>
4
 
Signed-off-by: Andreas Gruenbacher <agruen@suse.de>
5
 
 
6
 
Index: b/fs/namei.c
7
 
===================================================================
8
 
--- a/fs/namei.c
9
 
+++ b/fs/namei.c
10
 
@@ -1503,7 +1503,7 @@ int vfs_create(struct inode *dir, struct
11
 
                return -EACCES; /* shouldn't it be ENOSYS? */
12
 
        mode &= S_IALLUGO;
13
 
        mode |= S_IFREG;
14
 
-       error = security_inode_create(dir, dentry, mode);
15
 
+       error = security_inode_create(dir, dentry, nd ? nd->mnt : NULL, mode);
16
 
        if (error)
17
 
                return error;
18
 
        DQUOT_INIT(dir);
19
 
Index: b/include/linux/security.h
20
 
===================================================================
21
 
--- a/include/linux/security.h
22
 
+++ b/include/linux/security.h
23
 
@@ -283,6 +283,7 @@ struct request_sock;
24
 
  *     Check permission to create a regular file.
25
 
  *     @dir contains inode structure of the parent of the new file.
26
 
  *     @dentry contains the dentry structure for the file to be created.
27
 
+ *     @mnt is the vfsmount corresponding to @dentry (may be NULL).
28
 
  *     @mode contains the file mode of the file to be created.
29
 
  *     Return 0 if permission is granted.
30
 
  * @inode_link:
31
 
@@ -1204,8 +1205,8 @@ struct security_operations {
32
 
        void (*inode_free_security) (struct inode *inode);
33
 
        int (*inode_init_security) (struct inode *inode, struct inode *dir,
34
 
                                    char **name, void **value, size_t *len);
35
 
-       int (*inode_create) (struct inode *dir,
36
 
-                            struct dentry *dentry, int mode);
37
 
+       int (*inode_create) (struct inode *dir, struct dentry *dentry,
38
 
+                            struct vfsmount *mnt, int mode);
39
 
        int (*inode_link) (struct dentry *old_dentry,
40
 
                           struct inode *dir, struct dentry *new_dentry);
41
 
        int (*inode_unlink) (struct inode *dir, struct dentry *dentry);
42
 
@@ -1611,11 +1612,12 @@ static inline int security_inode_init_se
43
 
        
44
 
 static inline int security_inode_create (struct inode *dir,
45
 
                                         struct dentry *dentry,
46
 
+                                        struct vfsmount *mnt,
47
 
                                         int mode)
48
 
 {
49
 
        if (unlikely (IS_PRIVATE (dir)))
50
 
                return 0;
51
 
-       return security_ops->inode_create (dir, dentry, mode);
52
 
+       return security_ops->inode_create (dir, dentry, mnt, mode);
53
 
 }
54
 
 
55
 
 static inline int security_inode_link (struct dentry *old_dentry,
56
 
@@ -2338,6 +2340,7 @@ static inline int security_inode_init_se
57
 
        
58
 
 static inline int security_inode_create (struct inode *dir,
59
 
                                         struct dentry *dentry,
60
 
+                                        struct vfsmount *mnt,
61
 
                                         int mode)
62
 
 {
63
 
        return 0;
64
 
Index: b/security/dummy.c
65
 
===================================================================
66
 
--- a/security/dummy.c
67
 
+++ b/security/dummy.c
68
 
@@ -265,7 +265,7 @@ static int dummy_inode_init_security (st
69
 
 }
70
 
 
71
 
 static int dummy_inode_create (struct inode *inode, struct dentry *dentry,
72
 
-                              int mask)
73
 
+                              struct vfsmount *mnt, int mask)
74
 
 {
75
 
        return 0;
76
 
 }
77
 
Index: b/security/selinux/hooks.c
78
 
===================================================================
79
 
--- a/security/selinux/hooks.c
80
 
+++ b/security/selinux/hooks.c
81
 
@@ -2178,7 +2178,8 @@ static int selinux_inode_init_security(s
82
 
        return 0;
83
 
 }
84
 
 
85
 
-static int selinux_inode_create(struct inode *dir, struct dentry *dentry, int mask)
86
 
+static int selinux_inode_create(struct inode *dir, struct dentry *dentry,
87
 
+                                struct vfsmount *mnt, int mask)
88
 
 {
89
 
        return may_create(dir, dentry, SECCLASS_FILE);
90
 
 }