linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] 9p: don't use v9fs_parent_fid() when v9fs_fid_clone() is needed
@ 2016-08-01 19:57 Johannes Berg
  2016-08-02  0:30 ` Al Viro
  0 siblings, 1 reply; 3+ messages in thread
From: Johannes Berg @ 2016-08-01 19:57 UTC (permalink / raw)
  To: Al Viro, v9fs-developer, linux-kernel

The introduction of v9fs_parent_fid() broke v9fs_vfs_rename()
since that doesn't just do v9fs_fid_lookup() but rather uses
v9fs_fid_clone() on the ->d_parent.

I suppose it'd be possible to introduce v9fs_clone_parent_fid()
but I decided that just reverting the broken change was better
for now.

Fixes: 77d5a6b7d992 ("9p: new helper - v9fs_parent_fid()")
Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
---
 fs/9p/vfs_inode.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/fs/9p/vfs_inode.c b/fs/9p/vfs_inode.c
index 7da9a8354fad..d6488fb95dbf 100644
--- a/fs/9p/vfs_inode.c
+++ b/fs/9p/vfs_inode.c
@@ -975,13 +975,13 @@ v9fs_vfs_rename(struct inode *old_dir, struct dentry *old_dentry,
 	if (IS_ERR(oldfid))
 		return PTR_ERR(oldfid);
 
-	olddirfid = v9fs_parent_fid(old_dentry);
+	olddirfid = v9fs_fid_clone(old_dentry->d_parent);
 	if (IS_ERR(olddirfid)) {
 		retval = PTR_ERR(olddirfid);
 		goto done;
 	}
 
-	newdirfid = v9fs_parent_fid(new_dentry);
+	newdirfid = v9fs_fid_clone(new_dentry->d_parent);
 	if (IS_ERR(newdirfid)) {
 		retval = PTR_ERR(newdirfid);
 		goto clunk_olddir;
-- 
2.8.1

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

* Re: [PATCH] 9p: don't use v9fs_parent_fid() when v9fs_fid_clone() is needed
  2016-08-01 19:57 [PATCH] 9p: don't use v9fs_parent_fid() when v9fs_fid_clone() is needed Johannes Berg
@ 2016-08-02  0:30 ` Al Viro
  2016-08-02  5:50   ` Johannes Berg
  0 siblings, 1 reply; 3+ messages in thread
From: Al Viro @ 2016-08-02  0:30 UTC (permalink / raw)
  To: Johannes Berg; +Cc: v9fs-developer, linux-kernel

On Mon, Aug 01, 2016 at 09:57:17PM +0200, Johannes Berg wrote:
> The introduction of v9fs_parent_fid() broke v9fs_vfs_rename()
> since that doesn't just do v9fs_fid_lookup() but rather uses
> v9fs_fid_clone() on the ->d_parent.
> 
> I suppose it'd be possible to introduce v9fs_clone_parent_fid()
> but I decided that just reverting the broken change was better
> for now.

Sorry for the braino; FWIW, I'd rather add

static inline struct p9_fid *fid_clone(struct p9_fid *fid)
{
	if (IS_ERR(fid))
		return fid;
	return p9_client_walk(fid, 0, NULL, 1);
}

and turn those into fid_clone(v9fs_parent_fid(old_dentry)), etc.  Has an
extra benefit of simplifying several other places.  I'll fix and post
(with credits to you for spotting the bug in question, of course).

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

* Re: [PATCH] 9p: don't use v9fs_parent_fid() when v9fs_fid_clone() is needed
  2016-08-02  0:30 ` Al Viro
@ 2016-08-02  5:50   ` Johannes Berg
  0 siblings, 0 replies; 3+ messages in thread
From: Johannes Berg @ 2016-08-02  5:50 UTC (permalink / raw)
  To: Al Viro; +Cc: v9fs-developer, linux-kernel

On Tue, 2016-08-02 at 01:30 +0100, Al Viro wrote:
> On Mon, Aug 01, 2016 at 09:57:17PM +0200, Johannes Berg wrote:
> > The introduction of v9fs_parent_fid() broke v9fs_vfs_rename()
> > since that doesn't just do v9fs_fid_lookup() but rather uses
> > v9fs_fid_clone() on the ->d_parent.
> > 
> > I suppose it'd be possible to introduce v9fs_clone_parent_fid()
> > but I decided that just reverting the broken change was better
> > for now.
> 
> Sorry for the braino; FWIW, I'd rather add
> 
> static inline struct p9_fid *fid_clone(struct p9_fid *fid)
> {
> 	if (IS_ERR(fid))
> 		return fid;
> 	return p9_client_walk(fid, 0, NULL, 1);
> }
> 
> and turn those into fid_clone(v9fs_parent_fid(old_dentry)), etc.

That would have required much more looking into what happens than I was
about to do :)

>   Has an extra benefit of simplifying several other places.  I'll fix
> and post (with credits to you for spotting the bug in question, of
> course).

No objection, I just did the minimum necessary to make my setup not
crash on use-after-free all the time (thanks to slab debug) :)

Thanks,
johannes

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

end of thread, other threads:[~2016-08-02  7:00 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-08-01 19:57 [PATCH] 9p: don't use v9fs_parent_fid() when v9fs_fid_clone() is needed Johannes Berg
2016-08-02  0:30 ` Al Viro
2016-08-02  5:50   ` Johannes Berg

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).