]> git.ipfire.org Git - people/teissler/ipfire-2.x.git/blobdiff - src/patches/suse-2.6.27.31/patches.apparmor/security-readlink.diff
Added missing Xen Kernel Patches which were not commited because
[people/teissler/ipfire-2.x.git] / src / patches / suse-2.6.27.31 / patches.apparmor / security-readlink.diff
diff --git a/src/patches/suse-2.6.27.31/patches.apparmor/security-readlink.diff b/src/patches/suse-2.6.27.31/patches.apparmor/security-readlink.diff
new file mode 100644 (file)
index 0000000..3eab4f5
--- /dev/null
@@ -0,0 +1,104 @@
+From: Tony Jones <tonyj@suse.de>
+Subject: Pass struct vfsmount to the inode_readlink LSM hook
+
+This is needed for computing pathnames in the AppArmor LSM.
+
+Signed-off-by: Tony Jones <tonyj@suse.de>
+Signed-off-by: Andreas Gruenbacher <agruen@suse.de>
+Signed-off-by: John Johansen <jjohansen@suse.de>
+
+---
+ fs/stat.c                |    2 +-
+ include/linux/security.h |    8 +++++---
+ security/capability.c    |    2 +-
+ security/security.c      |    4 ++--
+ security/selinux/hooks.c |    2 +-
+ 5 files changed, 10 insertions(+), 8 deletions(-)
+
+--- a/fs/stat.c
++++ b/fs/stat.c
+@@ -308,7 +308,7 @@ SYSCALL_DEFINE4(readlinkat, int, dfd, co
+               error = -EINVAL;
+               if (inode->i_op && inode->i_op->readlink) {
+-                      error = security_inode_readlink(path.dentry);
++                      error = security_inode_readlink(path.dentry, path.mnt);
+                       if (!error) {
+                               touch_atime(path.mnt, path.dentry);
+                               error = inode->i_op->readlink(path.dentry,
+--- a/include/linux/security.h
++++ b/include/linux/security.h
+@@ -392,6 +392,7 @@ static inline void security_free_mnt_opt
+  * @inode_readlink:
+  *    Check the permission to read the symbolic link.
+  *    @dentry contains the dentry structure for the file link.
++ *    @mnt is the vfsmount corresponding to @dentry (may be NULL).
+  *    Return 0 if permission is granted.
+  * @inode_follow_link:
+  *    Check permission to follow a symbolic link when looking up a pathname.
+@@ -1373,7 +1374,7 @@ struct security_operations {
+                           struct vfsmount *mnt, int mode, dev_t dev);
+       int (*inode_rename) (struct inode *old_dir, struct dentry *old_dentry,
+                            struct inode *new_dir, struct dentry *new_dentry);
+-      int (*inode_readlink) (struct dentry *dentry);
++      int (*inode_readlink) (struct dentry *dentry, struct vfsmount *mnt);
+       int (*inode_follow_link) (struct dentry *dentry, struct nameidata *nd);
+       int (*inode_permission) (struct inode *inode, int mask);
+       int (*inode_setattr)    (struct dentry *dentry, struct vfsmount *,
+@@ -1643,7 +1644,7 @@ int security_inode_mknod(struct inode *d
+                        struct vfsmount *mnt, int mode, dev_t dev);
+ int security_inode_rename(struct inode *old_dir, struct dentry *old_dentry,
+                         struct inode *new_dir, struct dentry *new_dentry);
+-int security_inode_readlink(struct dentry *dentry);
++int security_inode_readlink(struct dentry *dentry, struct vfsmount *mnt);
+ int security_inode_follow_link(struct dentry *dentry, struct nameidata *nd);
+ int security_inode_permission(struct inode *inode, int mask);
+ int security_inode_setattr(struct dentry *dentry, struct vfsmount *mnt,
+@@ -2036,7 +2037,8 @@ static inline int security_inode_rename(
+       return 0;
+ }
+-static inline int security_inode_readlink(struct dentry *dentry)
++static inline int security_inode_readlink(struct dentry *dentry,
++                                        struct vfsmount *mnt)
+ {
+       return 0;
+ }
+--- a/security/capability.c
++++ b/security/capability.c
+@@ -200,7 +200,7 @@ static int cap_inode_rename(struct inode
+       return 0;
+ }
+-static int cap_inode_readlink(struct dentry *dentry)
++static int cap_inode_readlink(struct dentry *dentry, struct vfsmount *mnt)
+ {
+       return 0;
+ }
+--- a/security/security.c
++++ b/security/security.c
+@@ -419,11 +419,11 @@ int security_inode_rename(struct inode *
+                                          new_dir, new_dentry);
+ }
+-int security_inode_readlink(struct dentry *dentry)
++int security_inode_readlink(struct dentry *dentry, struct vfsmount *mnt)
+ {
+       if (unlikely(IS_PRIVATE(dentry->d_inode)))
+               return 0;
+-      return security_ops->inode_readlink(dentry);
++      return security_ops->inode_readlink(dentry, mnt);
+ }
+ int security_inode_follow_link(struct dentry *dentry, struct nameidata *nd)
+--- a/security/selinux/hooks.c
++++ b/security/selinux/hooks.c
+@@ -2627,7 +2627,7 @@ static int selinux_inode_rename(struct i
+       return may_rename(old_inode, old_dentry, new_inode, new_dentry);
+ }
+-static int selinux_inode_readlink(struct dentry *dentry)
++static int selinux_inode_readlink(struct dentry *dentry, struct vfsmount *mnt)
+ {
+       return dentry_has_perm(current, NULL, dentry, FILE__READ);
+ }