2007-04-03 07:50:09 +00:00
|
|
|
Add d_namespace_path() to obtain namespace relative pathnames
|
|
|
|
|
2007-04-03 13:26:33 +00:00
|
|
|
In AppArmor we are interested in pathnames relative to the namespace
|
|
|
|
root. Except for the root where the search ends, this is the same as
|
|
|
|
d_path(). Add d_namespace_path() for that.
|
|
|
|
internals.
|
|
|
|
|
2007-04-03 07:50:09 +00:00
|
|
|
Signed-off-by: Andreas Gruenbacher <agruen@suse.de>
|
|
|
|
Reviewed-by: John Johansen <jjohansen@suse.de>
|
|
|
|
|
2007-04-04 20:30:36 +00:00
|
|
|
Index: linux-2.6-apparmor/include/linux/dcache.h
|
2007-02-06 18:57:06 +00:00
|
|
|
===================================================================
|
2007-04-04 20:30:36 +00:00
|
|
|
--- linux-2.6-apparmor.orig/include/linux/dcache.h
|
|
|
|
+++ linux-2.6-apparmor/include/linux/dcache.h
|
2007-02-06 18:57:06 +00:00
|
|
|
@@ -293,6 +293,8 @@ extern struct dentry * d_hash_and_lookup
|
|
|
|
/* validate "insecure" dentry pointer */
|
|
|
|
extern int d_validate(struct dentry *, struct dentry *);
|
|
|
|
|
|
|
|
+extern char *__d_path(struct dentry *, struct vfsmount *, struct dentry *,
|
|
|
|
+ struct vfsmount *, char *, int, int);
|
|
|
|
extern char * d_path(struct dentry *, struct vfsmount *, char *, int);
|
|
|
|
|
|
|
|
/* Allocation counts.. */
|
2007-04-04 20:30:36 +00:00
|
|
|
Index: linux-2.6-apparmor/fs/dcache.c
|
2007-02-06 18:57:06 +00:00
|
|
|
===================================================================
|
2007-04-04 20:30:36 +00:00
|
|
|
--- linux-2.6-apparmor.orig/fs/dcache.c
|
|
|
|
+++ linux-2.6-apparmor/fs/dcache.c
|
2007-02-15 11:03:05 +00:00
|
|
|
@@ -1750,9 +1750,9 @@ shouldnt_be_hashed:
|
2007-02-06 18:57:06 +00:00
|
|
|
*
|
|
|
|
* Returns the buffer or an error code.
|
|
|
|
*/
|
|
|
|
-static char *__d_path(struct dentry *dentry, struct vfsmount *vfsmnt,
|
|
|
|
- struct dentry *root, struct vfsmount *rootmnt,
|
|
|
|
- char *buffer, int buflen, int fail_deleted)
|
|
|
|
+char *__d_path(struct dentry *dentry, struct vfsmount *vfsmnt,
|
|
|
|
+ struct dentry *root, struct vfsmount *rootmnt,
|
|
|
|
+ char *buffer, int buflen, int fail_deleted)
|
|
|
|
{
|
2007-02-27 08:42:00 +00:00
|
|
|
int namelen, is_slash, vfsmount_locked = 0;
|
2007-02-15 11:03:05 +00:00
|
|
|
|
2007-04-04 20:30:36 +00:00
|
|
|
Index: linux-2.6-apparmor/fs/namespace.c
|
2007-02-06 18:57:06 +00:00
|
|
|
===================================================================
|
2007-04-04 20:30:36 +00:00
|
|
|
--- linux-2.6-apparmor.orig/fs/namespace.c
|
|
|
|
+++ linux-2.6-apparmor/fs/namespace.c
|
|
|
|
@@ -1896,3 +1896,25 @@ void __put_mnt_ns(struct mnt_namespace *
|
2007-02-06 18:57:06 +00:00
|
|
|
release_mounts(&umount_list);
|
|
|
|
kfree(ns);
|
|
|
|
}
|
|
|
|
+
|
|
|
|
+char *d_namespace_path(struct dentry *dentry, struct vfsmount *vfsmnt,
|
2007-02-23 07:38:14 +00:00
|
|
|
+ char *buf, int buflen)
|
2007-02-06 18:57:06 +00:00
|
|
|
+{
|
|
|
|
+ char *res;
|
|
|
|
+ struct vfsmount *rootmnt, *nsrootmnt;
|
|
|
|
+ struct dentry *root;
|
|
|
|
+
|
|
|
|
+ read_lock(¤t->fs->lock);
|
|
|
|
+ rootmnt = mntget(current->fs->rootmnt);
|
|
|
|
+ read_unlock(¤t->fs->lock);
|
|
|
|
+ spin_lock(&vfsmount_lock);
|
|
|
|
+ nsrootmnt = mntget(rootmnt->mnt_ns->root);
|
|
|
|
+ root = dget(nsrootmnt->mnt_root);
|
|
|
|
+ spin_unlock(&vfsmount_lock);
|
|
|
|
+ mntput(rootmnt);
|
2007-02-23 07:38:14 +00:00
|
|
|
+ res = __d_path(dentry, vfsmnt, root, nsrootmnt, buf, buflen, 1);
|
2007-02-06 18:57:06 +00:00
|
|
|
+ dput(root);
|
|
|
|
+ mntput(nsrootmnt);
|
|
|
|
+ return res;
|
|
|
|
+}
|
|
|
|
+EXPORT_SYMBOL(d_namespace_path);
|
2007-04-04 20:30:36 +00:00
|
|
|
Index: linux-2.6-apparmor/include/linux/mount.h
|
2007-02-06 18:57:06 +00:00
|
|
|
===================================================================
|
2007-04-04 20:30:36 +00:00
|
|
|
--- linux-2.6-apparmor.orig/include/linux/mount.h
|
|
|
|
+++ linux-2.6-apparmor/include/linux/mount.h
|
2007-02-16 01:34:49 +00:00
|
|
|
@@ -103,5 +103,7 @@ extern void shrink_submounts(struct vfsm
|
2007-02-06 18:57:06 +00:00
|
|
|
extern spinlock_t vfsmount_lock;
|
|
|
|
extern dev_t name_to_dev_t(char *name);
|
|
|
|
|
2007-02-23 07:38:14 +00:00
|
|
|
+extern char *d_namespace_path(struct dentry *, struct vfsmount *, char *, int);
|
2007-02-06 18:57:06 +00:00
|
|
|
+
|
|
|
|
#endif
|
|
|
|
#endif /* _LINUX_MOUNT_H */
|