~ubuntu-branches/ubuntu/raring/apparmor/raring

« back to all changes in this revision

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

  • Committer: Bazaar Package Importer
  • Author(s): Kees Cook
  • Date: 2007-03-23 16:42:01 UTC
  • Revision ID: james.westby@ubuntu.com-20070323164201-jkax6f0oku087b7l
Tags: upstream-2.0.1+510.dfsg
ImportĀ upstreamĀ versionĀ 2.0.1+510.dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
Pass struct vfsmount to the inode_setattr 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/attr.c
 
7
===================================================================
 
8
--- a/fs/attr.c
 
9
+++ b/fs/attr.c
 
10
@@ -145,13 +145,13 @@ int notify_change(struct dentry *dentry,
 
11
                down_write(&dentry->d_inode->i_alloc_sem);
 
12
 
 
13
        if (inode->i_op && inode->i_op->setattr) {
 
14
-               error = security_inode_setattr(dentry, attr);
 
15
+               error = security_inode_setattr(dentry, mnt, attr);
 
16
                if (!error)
 
17
                        error = inode->i_op->setattr(dentry, attr);
 
18
        } else {
 
19
                error = inode_change_ok(inode, attr);
 
20
                if (!error)
 
21
-                       error = security_inode_setattr(dentry, attr);
 
22
+                       error = security_inode_setattr(dentry, mnt, attr);
 
23
                if (!error) {
 
24
                        if ((ia_valid & ATTR_UID && attr->ia_uid != inode->i_uid) ||
 
25
                            (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid))
 
26
Index: b/include/linux/security.h
 
27
===================================================================
 
28
--- a/include/linux/security.h
 
29
+++ b/include/linux/security.h
 
30
@@ -358,6 +358,7 @@ struct request_sock;
 
31
  *     file attributes change (such as when a file is truncated, chown/chmod
 
32
  *     operations, transferring disk quotas, etc).
 
33
  *     @dentry contains the dentry structure for the file.
 
34
+ *     @mnt is the vfsmount corresponding to @dentry (may be NULL).
 
35
  *     @attr is the iattr structure containing the new file attributes.
 
36
  *     Return 0 if permission is granted.
 
37
  * @inode_getattr:
 
38
@@ -1221,7 +1222,8 @@ struct security_operations {
 
39
        int (*inode_readlink) (struct dentry *dentry);
 
40
        int (*inode_follow_link) (struct dentry *dentry, struct nameidata *nd);
 
41
        int (*inode_permission) (struct inode *inode, int mask, struct nameidata *nd);
 
42
-       int (*inode_setattr)    (struct dentry *dentry, struct iattr *attr);
 
43
+       int (*inode_setattr) (struct dentry *dentry, struct vfsmount *mnt,
 
44
+                             struct iattr *attr);
 
45
        int (*inode_getattr) (struct vfsmount *mnt, struct dentry *dentry);
 
46
         void (*inode_delete) (struct inode *inode);
 
47
        int (*inode_setxattr) (struct dentry *dentry, char *name, void *value,
 
48
@@ -1708,11 +1710,12 @@ static inline int security_inode_permiss
 
49
 }
 
50
 
 
51
 static inline int security_inode_setattr (struct dentry *dentry,
 
52
+                                         struct vfsmount *mnt,
 
53
                                          struct iattr *attr)
 
54
 {
 
55
        if (unlikely (IS_PRIVATE (dentry->d_inode)))
 
56
                return 0;
 
57
-       return security_ops->inode_setattr (dentry, attr);
 
58
+       return security_ops->inode_setattr (dentry, mnt, attr);
 
59
 }
 
60
 
 
61
 static inline int security_inode_getattr (struct vfsmount *mnt,
 
62
@@ -2412,6 +2415,7 @@ static inline int security_inode_permiss
 
63
 }
 
64
 
 
65
 static inline int security_inode_setattr (struct dentry *dentry,
 
66
+                                         struct vfsmount *mnt,
 
67
                                          struct iattr *attr)
 
68
 {
 
69
        return 0;
 
70
Index: b/security/dummy.c
 
71
===================================================================
 
72
--- a/security/dummy.c
 
73
+++ b/security/dummy.c
 
74
@@ -328,7 +328,8 @@ static int dummy_inode_permission (struc
 
75
        return 0;
 
76
 }
 
77
 
 
78
-static int dummy_inode_setattr (struct dentry *dentry, struct iattr *iattr)
 
79
+static int dummy_inode_setattr (struct dentry *dentry, struct vfsmount *mnt,
 
80
+                               struct iattr *iattr)
 
81
 {
 
82
        return 0;
 
83
 }
 
84
Index: b/security/selinux/hooks.c
 
85
===================================================================
 
86
--- a/security/selinux/hooks.c
 
87
+++ b/security/selinux/hooks.c
 
88
@@ -2269,11 +2269,12 @@ static int selinux_inode_permission(stru
 
89
                               file_mask_to_av(inode->i_mode, mask), NULL);
 
90
 }
 
91
 
 
92
-static int selinux_inode_setattr(struct dentry *dentry, struct iattr *iattr)
 
93
+static int selinux_inode_setattr(struct dentry *dentry, struct vfsmount *mnt,
 
94
+                                struct iattr *iattr)
 
95
 {
 
96
        int rc;
 
97
 
 
98
-       rc = secondary_ops->inode_setattr(dentry, iattr);
 
99
+       rc = secondary_ops->inode_setattr(dentry, mnt, iattr);
 
100
        if (rc)
 
101
                return rc;
 
102