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

« back to all changes in this revision

Viewing changes to kernel-patches/for-mainline/security-readlink.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_readlink 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/stat.c
 
7
===================================================================
 
8
--- a/fs/stat.c
 
9
+++ b/fs/stat.c
 
10
@@ -307,7 +307,7 @@ asmlinkage long sys_readlinkat(int dfd, 
 
11
 
 
12
                error = -EINVAL;
 
13
                if (inode->i_op && inode->i_op->readlink) {
 
14
-                       error = security_inode_readlink(nd.dentry);
 
15
+                       error = security_inode_readlink(nd.dentry, nd.mnt);
 
16
                        if (!error) {
 
17
                                touch_atime(nd.mnt, nd.dentry);
 
18
                                error = inode->i_op->readlink(nd.dentry, buf, bufsiz);
 
19
Index: b/include/linux/security.h
 
20
===================================================================
 
21
--- a/include/linux/security.h
 
22
+++ b/include/linux/security.h
 
23
@@ -338,6 +338,7 @@ struct request_sock;
 
24
  * @inode_readlink:
 
25
  *     Check the permission to read the symbolic link.
 
26
  *     @dentry contains the dentry structure for the file link.
 
27
+ *     @mnt is the vfsmount corresponding to @dentry (may be NULL).
 
28
  *     Return 0 if permission is granted.
 
29
  * @inode_follow_link:
 
30
  *     Check permission to follow a symbolic link when looking up a pathname.
 
31
@@ -1223,7 +1224,7 @@ struct security_operations {
 
32
                            struct vfsmount *mnt, int mode, dev_t dev);
 
33
        int (*inode_rename) (struct inode *old_dir, struct dentry *old_dentry,
 
34
                             struct inode *new_dir, struct dentry *new_dentry);
 
35
-       int (*inode_readlink) (struct dentry *dentry);
 
36
+       int (*inode_readlink) (struct dentry *dentry, struct vfsmount *mnt);
 
37
        int (*inode_follow_link) (struct dentry *dentry, struct nameidata *nd);
 
38
        int (*inode_permission) (struct inode *inode, int mask, struct nameidata *nd);
 
39
        int (*inode_setattr) (struct dentry *dentry, struct vfsmount *mnt,
 
40
@@ -1693,11 +1694,12 @@ static inline int security_inode_rename 
 
41
                                           new_dir, new_dentry);
 
42
 }
 
43
 
 
44
-static inline int security_inode_readlink (struct dentry *dentry)
 
45
+static inline int security_inode_readlink (struct dentry *dentry,
 
46
+                                          struct vfsmount *mnt)
 
47
 {
 
48
        if (unlikely (IS_PRIVATE (dentry->d_inode)))
 
49
                return 0;
 
50
-       return security_ops->inode_readlink (dentry);
 
51
+       return security_ops->inode_readlink (dentry, mnt);
 
52
 }
 
53
 
 
54
 static inline int security_inode_follow_link (struct dentry *dentry,
 
55
@@ -2407,7 +2409,8 @@ static inline int security_inode_rename 
 
56
        return 0;
 
57
 }
 
58
 
 
59
-static inline int security_inode_readlink (struct dentry *dentry)
 
60
+static inline int security_inode_readlink (struct dentry *dentry,
 
61
+                                          struct vfsmount *mnt)
 
62
 {
 
63
        return 0;
 
64
 }
 
65
Index: b/security/dummy.c
 
66
===================================================================
 
67
--- a/security/dummy.c
 
68
+++ b/security/dummy.c
 
69
@@ -312,7 +312,7 @@ static int dummy_inode_rename (struct in
 
70
        return 0;
 
71
 }
 
72
 
 
73
-static int dummy_inode_readlink (struct dentry *dentry)
 
74
+static int dummy_inode_readlink (struct dentry *dentry, struct vfsmount *mnt)
 
75
 {
 
76
        return 0;
 
77
 }
 
78
Index: b/security/selinux/hooks.c
 
79
===================================================================
 
80
--- a/security/selinux/hooks.c
 
81
+++ b/security/selinux/hooks.c
 
82
@@ -2239,7 +2239,7 @@ static int selinux_inode_rename(struct i
 
83
        return may_rename(old_inode, old_dentry, new_inode, new_dentry);
 
84
 }
 
85
 
 
86
-static int selinux_inode_readlink(struct dentry *dentry)
 
87
+static int selinux_inode_readlink(struct dentry *dentry, struct vfsmount *mnt)
 
88
 {
 
89
        return dentry_has_perm(current, NULL, dentry, FILE__READ);
 
90
 }