All of lore.kernel.org
 help / color / mirror / Atom feed
* [uml-devel] [PATCH] make UML call dentry_open() with a valid vfsmount
@ 2007-09-27 22:09 Dave Hansen
  2007-09-28 15:03 ` Jeff Dike
  0 siblings, 1 reply; 4+ messages in thread
From: Dave Hansen @ 2007-09-27 22:09 UTC (permalink / raw)
  To: jdike; +Cc: Dave Hansen, user-mode-linux-devel


I'm trying to enforce the convention that you may not call
dentry_open() with a NULL vfsmount.  This is so that the
r/o bind mount patches can consistenty acquire write access
to the mounts there.

This patch fixes up UML's HPPFS to track both the vfsmount
and the dentry for its files.  Compile, but not runtime
tested.

---

 lxc-dave/fs/hppfs/hppfs_kern.c |   31 +++++++++++++++++--------------
 1 file changed, 17 insertions(+), 14 deletions(-)

diff -puN fs/open.c~remove-UML-callers-of-dentry_open-with-null-mnt fs/open.c
diff -puN fs/hppfs/hppfs_kern.c~remove-UML-callers-of-dentry_open-with-null-mnt fs/hppfs/hppfs_kern.c
--- lxc/fs/hppfs/hppfs_kern.c~remove-UML-callers-of-dentry_open-with-null-mnt	2007-09-27 15:03:07.000000000 -0700
+++ lxc-dave/fs/hppfs/hppfs_kern.c	2007-09-27 15:03:07.000000000 -0700
@@ -32,7 +32,7 @@ struct hppfs_private {
 };
 
 struct hppfs_inode_info {
-        struct dentry *proc_dentry;
+	struct path proc_path;
 	struct inode vfs_inode;
 };
 
@@ -139,10 +139,10 @@ static void hppfs_read_inode(struct inod
 {
 	struct inode *proc_ino;
 
-	if(HPPFS_I(ino)->proc_dentry == NULL)
+	if (HPPFS_I(ino)->proc_path.dentry == NULL)
 		return;
 
-	proc_ino = HPPFS_I(ino)->proc_dentry->d_inode;
+	proc_ino = HPPFS_I(ino)->proc_path.dentry->d_inode;
 	ino->i_uid = proc_ino->i_uid;
 	ino->i_gid = proc_ino->i_gid;
 	ino->i_atime = proc_ino->i_atime;
@@ -169,7 +169,7 @@ static struct dentry *hppfs_lookup(struc
 		return(ERR_PTR(-ENOENT));
 
 	err = -ENOMEM;
-	parent = HPPFS_I(ino)->proc_dentry;
+	parent = HPPFS_I(ino)->proc_path.dentry;
 	mutex_lock(&parent->d_inode->i_mutex);
 	proc_dentry = d_lookup(parent, &dentry->d_name);
 	if(proc_dentry == NULL){
@@ -455,7 +455,7 @@ static int file_mode(int fmode)
 static int hppfs_open(struct inode *inode, struct file *file)
 {
 	struct hppfs_private *data;
-	struct dentry *proc_dentry;
+	struct path *proc_path;
 	char *host_file;
 	int err, fd, type, filter;
 
@@ -468,10 +468,11 @@ static int hppfs_open(struct inode *inod
 	if(host_file == NULL)
 		goto out_free2;
 
-	proc_dentry = HPPFS_I(inode)->proc_dentry;
+	proc_path = &HPPFS_I(inode)->proc_path;
 
 	/* XXX This isn't closed anywhere */
-	data->proc_file = dentry_open(dget(proc_dentry), NULL,
+	data->proc_file = dentry_open(dget(proc_path->dentry),
+				      mntget(proc_path->mnt),
 				      file_mode(file->f_mode));
 	err = PTR_ERR(data->proc_file);
 	if(IS_ERR(data->proc_file))
@@ -516,7 +517,7 @@ static int hppfs_open(struct inode *inod
 static int hppfs_dir_open(struct inode *inode, struct file *file)
 {
 	struct hppfs_private *data;
-	struct dentry *proc_dentry;
+	struct path *proc_path;
 	int err;
 
 	err = -ENOMEM;
@@ -524,8 +525,9 @@ static int hppfs_dir_open(struct inode *
 	if(data == NULL)
 		goto out;
 
-	proc_dentry = HPPFS_I(inode)->proc_dentry;
-	data->proc_file = dentry_open(dget(proc_dentry), NULL,
+	proc_path = &HPPFS_I(inode)->proc_path;
+	data->proc_file = dentry_open(dget(proc_path->dentry),
+				      mntget(proc_path->mnt),
 				      file_mode(file->f_mode));
 	err = PTR_ERR(data->proc_file);
 	if(IS_ERR(data->proc_file))
@@ -634,7 +636,8 @@ static struct inode *hppfs_alloc_inode(s
 	if(hi == NULL)
 		return(NULL);
 
-	*hi = ((struct hppfs_inode_info) { .proc_dentry	= NULL });
+	hi->proc_path.dentry = NULL;
+	hi->proc_path.mnt = NULL;
 	inode_init_once(&hi->vfs_inode);
 	return(&hi->vfs_inode);
 }
@@ -663,7 +666,7 @@ static int hppfs_readlink(struct dentry 
 	struct dentry *proc_dentry;
 	int ret;
 
-	proc_dentry = HPPFS_I(dentry->d_inode)->proc_dentry;
+	proc_dentry = HPPFS_I(dentry->d_inode)->proc_path.dentry;
 	proc_file = dentry_open(dget(proc_dentry), NULL, O_RDONLY);
 	if (IS_ERR(proc_file))
 		return PTR_ERR(proc_file);
@@ -681,7 +684,7 @@ static void* hppfs_follow_link(struct de
 	struct dentry *proc_dentry;
 	void *ret;
 
-	proc_dentry = HPPFS_I(dentry->d_inode)->proc_dentry;
+	proc_dentry = HPPFS_I(dentry->d_inode)->proc_path.dentry;
 	proc_file = dentry_open(dget(proc_dentry), NULL, O_RDONLY);
 	if (IS_ERR(proc_file))
 		return proc_file;
@@ -717,7 +720,7 @@ static int init_inode(struct inode *inod
 		inode->i_fop = &hppfs_file_fops;
 	}
 
-	HPPFS_I(inode)->proc_dentry = dentry;
+	HPPFS_I(inode)->proc_path.dentry = dentry;
 
 	return(0);
 }
diff -puN fs/Kconfig~remove-UML-callers-of-dentry_open-with-null-mnt fs/Kconfig
diff -puN fs/Makefile~remove-UML-callers-of-dentry_open-with-null-mnt fs/Makefile
diff -puN arch/um/Kconfig~remove-UML-callers-of-dentry_open-with-null-mnt arch/um/Kconfig
diff -puN include/linux/namei.h~remove-UML-callers-of-dentry_open-with-null-mnt include/linux/namei.h
diff -puN arch/um/os-Linux/time.c~remove-UML-callers-of-dentry_open-with-null-mnt arch/um/os-Linux/time.c
diff -puN fs/hppfs/Makefile~remove-UML-callers-of-dentry_open-with-null-mnt fs/hppfs/Makefile
diff -puN MAINTAINERS~remove-UML-callers-of-dentry_open-with-null-mnt MAINTAINERS
_

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
User-mode-linux-devel mailing list
User-mode-linux-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [uml-devel] [PATCH] make UML call dentry_open() with a valid vfsmount
  2007-09-27 22:09 [uml-devel] [PATCH] make UML call dentry_open() with a valid vfsmount Dave Hansen
@ 2007-09-28 15:03 ` Jeff Dike
  2007-09-28 16:00   ` Dave Hansen
  0 siblings, 1 reply; 4+ messages in thread
From: Jeff Dike @ 2007-09-28 15:03 UTC (permalink / raw)
  To: Dave Hansen; +Cc: user-mode-linux-devel

On Thu, Sep 27, 2007 at 03:09:23PM -0700, Dave Hansen wrote:
> 
> I'm trying to enforce the convention that you may not call
> dentry_open() with a NULL vfsmount.  This is so that the
> r/o bind mount patches can consistenty acquire write access
> to the mounts there.
> 
> This patch fixes up UML's HPPFS to track both the vfsmount
> and the dentry for its files.  Compile, but not runtime
> tested.

Can I get a Signed-off-by:?

			Jeff

-- 
Work email - jdike at linux dot intel dot com

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
User-mode-linux-devel mailing list
User-mode-linux-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [uml-devel] [PATCH] make UML call dentry_open() with a valid vfsmount
  2007-09-28 15:03 ` Jeff Dike
@ 2007-09-28 16:00   ` Dave Hansen
  2007-09-28 16:47     ` Jeff Dike
  0 siblings, 1 reply; 4+ messages in thread
From: Dave Hansen @ 2007-09-28 16:00 UTC (permalink / raw)
  To: Jeff Dike; +Cc: user-mode-linux-devel

On Fri, 2007-09-28 at 11:03 -0400, Jeff Dike wrote:
> On Thu, Sep 27, 2007 at 03:09:23PM -0700, Dave Hansen wrote:
> > 
> > I'm trying to enforce the convention that you may not call
> > dentry_open() with a NULL vfsmount.  This is so that the
> > r/o bind mount patches can consistenty acquire write access
> > to the mounts there.
> > 
> > This patch fixes up UML's HPPFS to track both the vfsmount
> > and the dentry for its files.  Compile, but not runtime
> > tested.
> 
> Can I get a Signed-off-by:?

I'm trying to enforce the convention that you may not call
dentry_open() with a NULL vfsmount.  This is so that the
r/o bind mount patches can consistenty acquire write access
to the mounts there.

This patch fixes up UML's HPPFS to track both the vfsmount
and the dentry for its files.  Compile, but not runtime
tested.

This also fixes a potential oops with the r/o bind mount patches caused
by passing a NULL mnt into dentry_open().  After you've had a chance to
verify that this works, could you send it up to -mm?

One more thing... have you had any problems getting
arch/um/os-Linux/time.c to compile because of a lack of tv_to_nsec()?

Signed-off-by: Dave Hansen <haveblue@us.ibm.com>

---

 lxc-dave/fs/hppfs/hppfs_kern.c |   45 +++++++++++++++++++++++------------------
 1 file changed, 26 insertions(+), 19 deletions(-)

diff -puN fs/hppfs/hppfs_kern.c~remove-UML-callers-of-dentry_open-with-null-mnt fs/hppfs/hppfs_kern.c
--- lxc/fs/hppfs/hppfs_kern.c~remove-UML-callers-of-dentry_open-with-null-mnt	2007-09-28 08:57:05.000000000 -0700
+++ lxc-dave/fs/hppfs/hppfs_kern.c	2007-09-28 08:57:05.000000000 -0700
@@ -17,7 +17,8 @@
 #include <asm/fcntl.h>
 #include "os.h"
 
-static int init_inode(struct inode *inode, struct dentry *dentry);
+static int init_inode(struct inode *inode, struct dentry *dentry,
+		struct vfsmount *mnt);
 
 struct hppfs_data {
 	struct list_head list;
@@ -32,7 +33,7 @@ struct hppfs_private {
 };
 
 struct hppfs_inode_info {
-        struct dentry *proc_dentry;
+	struct path proc_path;
 	struct inode vfs_inode;
 };
 
@@ -139,10 +140,10 @@ static void hppfs_read_inode(struct inod
 {
 	struct inode *proc_ino;
 
-	if(HPPFS_I(ino)->proc_dentry == NULL)
+	if (HPPFS_I(ino)->proc_path.dentry == NULL)
 		return;
 
-	proc_ino = HPPFS_I(ino)->proc_dentry->d_inode;
+	proc_ino = HPPFS_I(ino)->proc_path.dentry->d_inode;
 	ino->i_uid = proc_ino->i_uid;
 	ino->i_gid = proc_ino->i_gid;
 	ino->i_atime = proc_ino->i_atime;
@@ -169,7 +170,7 @@ static struct dentry *hppfs_lookup(struc
 		return(ERR_PTR(-ENOENT));
 
 	err = -ENOMEM;
-	parent = HPPFS_I(ino)->proc_dentry;
+	parent = HPPFS_I(ino)->proc_path.dentry;
 	mutex_lock(&parent->d_inode->i_mutex);
 	proc_dentry = d_lookup(parent, &dentry->d_name);
 	if(proc_dentry == NULL){
@@ -194,7 +195,7 @@ static struct dentry *hppfs_lookup(struc
 	if(inode == NULL)
 		goto out_dput;
 
-	err = init_inode(inode, proc_dentry);
+	err = init_inode(inode, proc_dentry, nd->mnt);
 	if(err)
 		goto out_put;
 
@@ -455,7 +456,7 @@ static int file_mode(int fmode)
 static int hppfs_open(struct inode *inode, struct file *file)
 {
 	struct hppfs_private *data;
-	struct dentry *proc_dentry;
+	struct path *proc_path;
 	char *host_file;
 	int err, fd, type, filter;
 
@@ -468,10 +469,11 @@ static int hppfs_open(struct inode *inod
 	if(host_file == NULL)
 		goto out_free2;
 
-	proc_dentry = HPPFS_I(inode)->proc_dentry;
+	proc_path = &HPPFS_I(inode)->proc_path;
 
 	/* XXX This isn't closed anywhere */
-	data->proc_file = dentry_open(dget(proc_dentry), NULL,
+	data->proc_file = dentry_open(dget(proc_path->dentry),
+				      mntget(proc_path->mnt),
 				      file_mode(file->f_mode));
 	err = PTR_ERR(data->proc_file);
 	if(IS_ERR(data->proc_file))
@@ -516,7 +518,7 @@ static int hppfs_open(struct inode *inod
 static int hppfs_dir_open(struct inode *inode, struct file *file)
 {
 	struct hppfs_private *data;
-	struct dentry *proc_dentry;
+	struct path *proc_path;
 	int err;
 
 	err = -ENOMEM;
@@ -524,8 +526,9 @@ static int hppfs_dir_open(struct inode *
 	if(data == NULL)
 		goto out;
 
-	proc_dentry = HPPFS_I(inode)->proc_dentry;
-	data->proc_file = dentry_open(dget(proc_dentry), NULL,
+	proc_path = &HPPFS_I(inode)->proc_path;
+	data->proc_file = dentry_open(dget(proc_path->dentry),
+				      mntget(proc_path->mnt),
 				      file_mode(file->f_mode));
 	err = PTR_ERR(data->proc_file);
 	if(IS_ERR(data->proc_file))
@@ -634,7 +637,8 @@ static struct inode *hppfs_alloc_inode(s
 	if(hi == NULL)
 		return(NULL);
 
-	*hi = ((struct hppfs_inode_info) { .proc_dentry	= NULL });
+	hi->proc_path.dentry = NULL;
+	hi->proc_path.mnt = NULL;
 	inode_init_once(&hi->vfs_inode);
 	return(&hi->vfs_inode);
 }
@@ -663,7 +667,7 @@ static int hppfs_readlink(struct dentry 
 	struct dentry *proc_dentry;
 	int ret;
 
-	proc_dentry = HPPFS_I(dentry->d_inode)->proc_dentry;
+	proc_dentry = HPPFS_I(dentry->d_inode)->proc_path.dentry;
 	proc_file = dentry_open(dget(proc_dentry), NULL, O_RDONLY);
 	if (IS_ERR(proc_file))
 		return PTR_ERR(proc_file);
@@ -681,7 +685,7 @@ static void* hppfs_follow_link(struct de
 	struct dentry *proc_dentry;
 	void *ret;
 
-	proc_dentry = HPPFS_I(dentry->d_inode)->proc_dentry;
+	proc_dentry = HPPFS_I(dentry->d_inode)->proc_path.dentry;
 	proc_file = dentry_open(dget(proc_dentry), NULL, O_RDONLY);
 	if (IS_ERR(proc_file))
 		return proc_file;
@@ -702,7 +706,8 @@ static const struct inode_operations hpp
 	.follow_link	= hppfs_follow_link,
 };
 
-static int init_inode(struct inode *inode, struct dentry *dentry)
+static int init_inode(struct inode *inode, struct dentry *dentry,
+			struct vfsmount *mnt)
 {
 	if(S_ISDIR(dentry->d_inode->i_mode)){
 		inode->i_op = &hppfs_dir_iops;
@@ -717,7 +722,8 @@ static int init_inode(struct inode *inod
 		inode->i_fop = &hppfs_file_fops;
 	}
 
-	HPPFS_I(inode)->proc_dentry = dentry;
+	HPPFS_I(inode)->proc_path.dentry = dentry;
+	HPPFS_I(inode)->proc_path.mnt = mnt;
 
 	return(0);
 }
@@ -727,6 +733,7 @@ static int hppfs_fill_super(struct super
 	struct inode *root_inode;
 	struct file_system_type *procfs;
 	struct super_block *proc_sb;
+	struct vfsmount *mnt = d;
 	int err;
 
 	err = -ENOENT;
@@ -749,7 +756,7 @@ static int hppfs_fill_super(struct super
 	if(root_inode == NULL)
 		goto out;
 
-	err = init_inode(root_inode, proc_sb->s_root);
+	err = init_inode(root_inode, proc_sb->s_root, mnt);
 	if(err)
 		goto out_put;
 
@@ -772,7 +779,7 @@ static int hppfs_read_super(struct file_
 			    int flags, const char *dev_name,
 			    void *data, struct vfsmount *mnt)
 {
-	return get_sb_nodev(type, flags, data, hppfs_fill_super, mnt);
+	return get_sb_nodev(type, flags, mnt, hppfs_fill_super, mnt);
 }
 
 static struct file_system_type hppfs_type = {
_


-- Dave


-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
User-mode-linux-devel mailing list
User-mode-linux-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [uml-devel] [PATCH] make UML call dentry_open() with a valid vfsmount
  2007-09-28 16:00   ` Dave Hansen
@ 2007-09-28 16:47     ` Jeff Dike
  0 siblings, 0 replies; 4+ messages in thread
From: Jeff Dike @ 2007-09-28 16:47 UTC (permalink / raw)
  To: Dave Hansen; +Cc: user-mode-linux-devel

On Fri, Sep 28, 2007 at 09:00:14AM -0700, Dave Hansen wrote:
> One more thing... have you had any problems getting
> arch/um/os-Linux/time.c to compile because of a lack of tv_to_nsec()?

That should be fixed in current -mm.

				Jeff

-- 
Work email - jdike at linux dot intel dot com

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
User-mode-linux-devel mailing list
User-mode-linux-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2007-09-28 16:47 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-09-27 22:09 [uml-devel] [PATCH] make UML call dentry_open() with a valid vfsmount Dave Hansen
2007-09-28 15:03 ` Jeff Dike
2007-09-28 16:00   ` Dave Hansen
2007-09-28 16:47     ` Jeff Dike

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.