Re: [TOMOYO #5 02/18] Add wrapper functions for VFS helper functions.
Hello. Christoph Hellwig wrote: > > NACK to this. Passing function parameters through the task_struct is > > definitely not an acceptable hack > Exactly. Having a vfsmount other than the current processes root or > current working directory in task_struct doesn't make any sense. The process's root and cwd vfsmounts are used permanently, but this last_vfsmount passed via task_struct behaves like temporary variable pushed on stack memory. In other words, last_vfsmount becomes NULL when it becomes invalid. | static inline int vfs_create2(struct inode *dir, struct dentry *dentry, | int mode, struct nameidata *nd) | { | int ret; | struct vfsmount *mnt = nd ? nd->path.mnt : NULL; | struct task_struct *task = current; | struct vfsmount *prev_mnt = task->last_vfsmount; | task->last_vfsmount = mntget(mnt); | ret = vfs_create(dir, dentry, mode, nd); | task->last_vfsmount = prev_mnt; | mntput(mnt); | return ret; | } I agree that keeping last_vfsmount after it lost it's reference count is bad, but I don't understand why keeping last_vfsmount while it has it's reference count is bad too. Regards. - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [TOMOYO #5 02/18] Add wrapper functions for VFS helper functions.
On Fri, Nov 16, 2007 at 12:47:35PM -0500, Trond Myklebust wrote: > > On Sat, 2007-11-17 at 02:34 +0900, [EMAIL PROTECTED] > wrote: > > plain text document attachment > > (add-wrapper-functions-for-vfs-helper-functions.patch) > > This patch allows LSM hooks refer previously associated "struct vfsmount" > > parameter > > so that they can calculate pathname of given "struct dentry". > > NACK to this. Passing function parameters through the task_struct is > definitely not an acceptable hack Exactly. Having a vfsmount other than the current processes root or current working directory in task_struct doesn't make any sense. - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [TOMOYO #5 02/18] Add wrapper functions for VFS helper functions.
On Fri, Nov 16, 2007 at 12:47:35PM -0500, Trond Myklebust wrote: On Sat, 2007-11-17 at 02:34 +0900, [EMAIL PROTECTED] wrote: plain text document attachment (add-wrapper-functions-for-vfs-helper-functions.patch) This patch allows LSM hooks refer previously associated struct vfsmount parameter so that they can calculate pathname of given struct dentry. NACK to this. Passing function parameters through the task_struct is definitely not an acceptable hack Exactly. Having a vfsmount other than the current processes root or current working directory in task_struct doesn't make any sense. - To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [TOMOYO #5 02/18] Add wrapper functions for VFS helper functions.
Hello. Christoph Hellwig wrote: NACK to this. Passing function parameters through the task_struct is definitely not an acceptable hack Exactly. Having a vfsmount other than the current processes root or current working directory in task_struct doesn't make any sense. The process's root and cwd vfsmounts are used permanently, but this last_vfsmount passed via task_struct behaves like temporary variable pushed on stack memory. In other words, last_vfsmount becomes NULL when it becomes invalid. | static inline int vfs_create2(struct inode *dir, struct dentry *dentry, | int mode, struct nameidata *nd) | { | int ret; | struct vfsmount *mnt = nd ? nd-path.mnt : NULL; | struct task_struct *task = current; | struct vfsmount *prev_mnt = task-last_vfsmount; | task-last_vfsmount = mntget(mnt); | ret = vfs_create(dir, dentry, mode, nd); | task-last_vfsmount = prev_mnt; | mntput(mnt); | return ret; | } I agree that keeping last_vfsmount after it lost it's reference count is bad, but I don't understand why keeping last_vfsmount while it has it's reference count is bad too. Regards. - To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [TOMOYO #5 02/18] Add wrapper functions for VFS helper functions.
On Sat, 2007-11-17 at 02:34 +0900, [EMAIL PROTECTED] wrote: > plain text document attachment > (add-wrapper-functions-for-vfs-helper-functions.patch) > This patch allows LSM hooks refer previously associated "struct vfsmount" > parameter > so that they can calculate pathname of given "struct dentry". NACK to this. Passing function parameters through the task_struct is definitely not an acceptable hack (unless you're doing it through the stack). Trond - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[TOMOYO #5 02/18] Add wrapper functions for VFS helper functions.
This patch allows LSM hooks refer previously associated "struct vfsmount" parameter so that they can calculate pathname of given "struct dentry". Signed-off-by: Tetsuo Handa <[EMAIL PROTECTED]> --- include/linux/fs.h | 138 + 1 file changed, 138 insertions(+) --- linux-2.6-mm.orig/include/linux/fs.h2007-11-14 15:14:52.0 +0900 +++ linux-2.6-mm/include/linux/fs.h 2007-11-14 15:20:32.0 +0900 @@ -1086,6 +1086,116 @@ extern int vfs_rmdir(struct inode *, str extern int vfs_unlink(struct inode *, struct dentry *); extern int vfs_rename(struct inode *, struct dentry *, struct inode *, struct dentry *); +#include +#include + +static inline int vfs_create2(struct inode *dir, struct dentry *dentry, + int mode, struct nameidata *nd) +{ + int ret; + struct vfsmount *mnt = nd ? nd->path.mnt : NULL; + struct task_struct *task = current; + struct vfsmount *prev_mnt = task->last_vfsmount; + task->last_vfsmount = mntget(mnt); + ret = vfs_create(dir, dentry, mode, nd); + task->last_vfsmount = prev_mnt; + mntput(mnt); + return ret; +} + +static inline int vfs_mkdir2(struct inode *dir, struct dentry *dentry, +struct vfsmount *mnt, int mode) +{ + int ret; + struct task_struct *task = current; + struct vfsmount *prev_mnt = task->last_vfsmount; + task->last_vfsmount = mntget(mnt); + ret = vfs_mkdir(dir, dentry, mode); + task->last_vfsmount = prev_mnt; + mntput(mnt); + return ret; +} + +static inline int vfs_mknod2(struct inode *dir, struct dentry *dentry, +struct vfsmount *mnt, int mode, dev_t dev) +{ + int ret; + struct task_struct *task = current; + struct vfsmount *prev_mnt = task->last_vfsmount; + task->last_vfsmount = mntget(mnt); + ret = vfs_mknod(dir, dentry, mode, dev); + task->last_vfsmount = prev_mnt; + mntput(mnt); + return ret; +} + +static inline int vfs_symlink2(struct inode *dir, struct dentry *dentry, + struct vfsmount *mnt, const char *oldname, + int mode) +{ + int ret; + struct task_struct *task = current; + struct vfsmount *prev_mnt = task->last_vfsmount; + task->last_vfsmount = mntget(mnt); + ret = vfs_symlink(dir, dentry, oldname, mode); + task->last_vfsmount = prev_mnt; + mntput(mnt); + return ret; +} + +static inline int vfs_link2(struct dentry *old_dentry, struct inode *dir, + struct dentry *new_dentry, struct vfsmount *mnt) +{ + int ret; + struct task_struct *task = current; + struct vfsmount *prev_mnt = task->last_vfsmount; + task->last_vfsmount = mntget(mnt); + ret = vfs_link(old_dentry, dir, new_dentry); + task->last_vfsmount = prev_mnt; + mntput(mnt); + return ret; +} + +static inline int vfs_rmdir2(struct inode *dir, struct dentry *dentry, +struct vfsmount *mnt) +{ + int ret; + struct task_struct *task = current; + struct vfsmount *prev_mnt = task->last_vfsmount; + task->last_vfsmount = mntget(mnt); + ret = vfs_rmdir(dir, dentry); + task->last_vfsmount = prev_mnt; + mntput(mnt); + return ret; +} + +static inline int vfs_unlink2(struct inode *dir, struct dentry *dentry, +struct vfsmount *mnt) +{ + int ret; + struct task_struct *task = current; + struct vfsmount *prev_mnt = task->last_vfsmount; + task->last_vfsmount = mntget(mnt); + ret = vfs_unlink(dir, dentry); + task->last_vfsmount = prev_mnt; + mntput(mnt); + return ret; +} + +static inline int vfs_rename2(struct inode *old_dir, struct dentry *old_dentry, + struct inode *new_dir, struct dentry *new_dentry, + struct vfsmount *mnt) +{ + int ret; + struct task_struct *task = current; + struct vfsmount *prev_mnt = task->last_vfsmount; + task->last_vfsmount = mntget(mnt); + ret = vfs_rename(old_dir, old_dentry, new_dir, new_dentry); + task->last_vfsmount = prev_mnt; + mntput(mnt); + return ret; +} + /* * VFS dentry helper functions. */ @@ -1548,6 +1658,21 @@ static inline int break_lease(struct ino extern int do_truncate(struct dentry *, loff_t start, unsigned int time_attrs, struct file *filp); + +static inline int do_truncate2(struct dentry *dentry, struct vfsmount *mnt, + loff_t length, unsigned int time_attrs, + struct file *filp) +{ + int ret; + struct task_struct *task = current; + struct vfsmount *prev_mnt = task->last_vfsmount; + task->last_vfsmount = mntget(mnt); + ret =
[TOMOYO #5 02/18] Add wrapper functions for VFS helper functions.
This patch allows LSM hooks refer previously associated struct vfsmount parameter so that they can calculate pathname of given struct dentry. Signed-off-by: Tetsuo Handa [EMAIL PROTECTED] --- include/linux/fs.h | 138 + 1 file changed, 138 insertions(+) --- linux-2.6-mm.orig/include/linux/fs.h2007-11-14 15:14:52.0 +0900 +++ linux-2.6-mm/include/linux/fs.h 2007-11-14 15:20:32.0 +0900 @@ -1086,6 +1086,116 @@ extern int vfs_rmdir(struct inode *, str extern int vfs_unlink(struct inode *, struct dentry *); extern int vfs_rename(struct inode *, struct dentry *, struct inode *, struct dentry *); +#include linux/mount.h +#include linux/sched.h + +static inline int vfs_create2(struct inode *dir, struct dentry *dentry, + int mode, struct nameidata *nd) +{ + int ret; + struct vfsmount *mnt = nd ? nd-path.mnt : NULL; + struct task_struct *task = current; + struct vfsmount *prev_mnt = task-last_vfsmount; + task-last_vfsmount = mntget(mnt); + ret = vfs_create(dir, dentry, mode, nd); + task-last_vfsmount = prev_mnt; + mntput(mnt); + return ret; +} + +static inline int vfs_mkdir2(struct inode *dir, struct dentry *dentry, +struct vfsmount *mnt, int mode) +{ + int ret; + struct task_struct *task = current; + struct vfsmount *prev_mnt = task-last_vfsmount; + task-last_vfsmount = mntget(mnt); + ret = vfs_mkdir(dir, dentry, mode); + task-last_vfsmount = prev_mnt; + mntput(mnt); + return ret; +} + +static inline int vfs_mknod2(struct inode *dir, struct dentry *dentry, +struct vfsmount *mnt, int mode, dev_t dev) +{ + int ret; + struct task_struct *task = current; + struct vfsmount *prev_mnt = task-last_vfsmount; + task-last_vfsmount = mntget(mnt); + ret = vfs_mknod(dir, dentry, mode, dev); + task-last_vfsmount = prev_mnt; + mntput(mnt); + return ret; +} + +static inline int vfs_symlink2(struct inode *dir, struct dentry *dentry, + struct vfsmount *mnt, const char *oldname, + int mode) +{ + int ret; + struct task_struct *task = current; + struct vfsmount *prev_mnt = task-last_vfsmount; + task-last_vfsmount = mntget(mnt); + ret = vfs_symlink(dir, dentry, oldname, mode); + task-last_vfsmount = prev_mnt; + mntput(mnt); + return ret; +} + +static inline int vfs_link2(struct dentry *old_dentry, struct inode *dir, + struct dentry *new_dentry, struct vfsmount *mnt) +{ + int ret; + struct task_struct *task = current; + struct vfsmount *prev_mnt = task-last_vfsmount; + task-last_vfsmount = mntget(mnt); + ret = vfs_link(old_dentry, dir, new_dentry); + task-last_vfsmount = prev_mnt; + mntput(mnt); + return ret; +} + +static inline int vfs_rmdir2(struct inode *dir, struct dentry *dentry, +struct vfsmount *mnt) +{ + int ret; + struct task_struct *task = current; + struct vfsmount *prev_mnt = task-last_vfsmount; + task-last_vfsmount = mntget(mnt); + ret = vfs_rmdir(dir, dentry); + task-last_vfsmount = prev_mnt; + mntput(mnt); + return ret; +} + +static inline int vfs_unlink2(struct inode *dir, struct dentry *dentry, +struct vfsmount *mnt) +{ + int ret; + struct task_struct *task = current; + struct vfsmount *prev_mnt = task-last_vfsmount; + task-last_vfsmount = mntget(mnt); + ret = vfs_unlink(dir, dentry); + task-last_vfsmount = prev_mnt; + mntput(mnt); + return ret; +} + +static inline int vfs_rename2(struct inode *old_dir, struct dentry *old_dentry, + struct inode *new_dir, struct dentry *new_dentry, + struct vfsmount *mnt) +{ + int ret; + struct task_struct *task = current; + struct vfsmount *prev_mnt = task-last_vfsmount; + task-last_vfsmount = mntget(mnt); + ret = vfs_rename(old_dir, old_dentry, new_dir, new_dentry); + task-last_vfsmount = prev_mnt; + mntput(mnt); + return ret; +} + /* * VFS dentry helper functions. */ @@ -1548,6 +1658,21 @@ static inline int break_lease(struct ino extern int do_truncate(struct dentry *, loff_t start, unsigned int time_attrs, struct file *filp); + +static inline int do_truncate2(struct dentry *dentry, struct vfsmount *mnt, + loff_t length, unsigned int time_attrs, + struct file *filp) +{ + int ret; + struct task_struct *task = current; + struct vfsmount *prev_mnt = task-last_vfsmount; + task-last_vfsmount = mntget(mnt); + ret =
Re: [TOMOYO #5 02/18] Add wrapper functions for VFS helper functions.
On Sat, 2007-11-17 at 02:34 +0900, [EMAIL PROTECTED] wrote: plain text document attachment (add-wrapper-functions-for-vfs-helper-functions.patch) This patch allows LSM hooks refer previously associated struct vfsmount parameter so that they can calculate pathname of given struct dentry. NACK to this. Passing function parameters through the task_struct is definitely not an acceptable hack (unless you're doing it through the stack). Trond - To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/