1
Pass struct vfsmount to the inode_readlink LSM hook
3
Signed-off-by: Tony Jones <tonyj@suse.de>
4
Signed-off-by: Andreas Gruenbacher <agruen@suse.de>
7
===================================================================
10
@@ -307,7 +307,7 @@ asmlinkage long sys_readlinkat(int dfd,
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);
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;
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.
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
44
-static inline int security_inode_readlink (struct dentry *dentry)
45
+static inline int security_inode_readlink (struct dentry *dentry,
46
+ struct vfsmount *mnt)
48
if (unlikely (IS_PRIVATE (dentry->d_inode)))
50
- return security_ops->inode_readlink (dentry);
51
+ return security_ops->inode_readlink (dentry, mnt);
54
static inline int security_inode_follow_link (struct dentry *dentry,
55
@@ -2407,7 +2409,8 @@ static inline int security_inode_rename
59
-static inline int security_inode_readlink (struct dentry *dentry)
60
+static inline int security_inode_readlink (struct dentry *dentry,
61
+ struct vfsmount *mnt)
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
73
-static int dummy_inode_readlink (struct dentry *dentry)
74
+static int dummy_inode_readlink (struct dentry *dentry, struct vfsmount *mnt)
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);
86
-static int selinux_inode_readlink(struct dentry *dentry)
87
+static int selinux_inode_readlink(struct dentry *dentry, struct vfsmount *mnt)
89
return dentry_has_perm(current, NULL, dentry, FILE__READ);