* [PATCH] namei: free new_dentry late
@ 2018-11-24 9:23 Pan Bian
2018-11-24 19:51 ` Al Viro
0 siblings, 1 reply; 3+ messages in thread
From: Pan Bian @ 2018-11-24 9:23 UTC (permalink / raw)
To: Alexander Viro; +Cc: linux-fsdevel, linux-kernel, Pan Bian
After calling dput(new_dentry), new_dentry is passed to fsnotify_move.
This may result in a use-after-free bug. This patch moves the put
operation late.
Fixes: 49d31c2f389a("dentry name snapshots")
Signed-off-by: Pan Bian <bianpan2016@163.com>
---
fs/namei.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/fs/namei.c b/fs/namei.c
index 0cab649..8b104d9 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -4498,7 +4498,6 @@ int vfs_rename(struct inode *old_dir, struct dentry *old_dentry,
unlock_two_nondirectories(source, target);
else if (target)
inode_unlock(target);
- dput(new_dentry);
if (!error) {
fsnotify_move(old_dir, new_dir, old_name.name, is_dir,
!(flags & RENAME_EXCHANGE) ? target : NULL, old_dentry);
@@ -4507,6 +4506,7 @@ int vfs_rename(struct inode *old_dir, struct dentry *old_dentry,
new_is_dir, NULL, new_dentry);
}
}
+ dput(new_dentry);
release_dentry_name_snapshot(&old_name);
return error;
--
2.7.4
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] namei: free new_dentry late
2018-11-24 9:23 [PATCH] namei: free new_dentry late Pan Bian
@ 2018-11-24 19:51 ` Al Viro
2018-11-25 0:11 ` PanBian
0 siblings, 1 reply; 3+ messages in thread
From: Al Viro @ 2018-11-24 19:51 UTC (permalink / raw)
To: Pan Bian; +Cc: linux-fsdevel, linux-kernel
On Sat, Nov 24, 2018 at 05:23:24PM +0800, Pan Bian wrote:
> After calling dput(new_dentry), new_dentry is passed to fsnotify_move.
> This may result in a use-after-free bug. This patch moves the put
> operation late.
>
> Fixes: 49d31c2f389a("dentry name snapshots")
What does that commit have to do with anything? The broken part is
fsnotify_move(new_dir, old_dir, old_dentry->d_name.name,
new_is_dir, NULL, new_dentry);
and it predates that commit by 3 years - it came from da1ce0670c14 ("vfs: add
cross-rename")...
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] namei: free new_dentry late
2018-11-24 19:51 ` Al Viro
@ 2018-11-25 0:11 ` PanBian
0 siblings, 0 replies; 3+ messages in thread
From: PanBian @ 2018-11-25 0:11 UTC (permalink / raw)
To: Al Viro; +Cc: linux-fsdevel, linux-kernel
On Sat, Nov 24, 2018 at 07:51:17PM +0000, Al Viro wrote:
> On Sat, Nov 24, 2018 at 05:23:24PM +0800, Pan Bian wrote:
> > After calling dput(new_dentry), new_dentry is passed to fsnotify_move.
> > This may result in a use-after-free bug. This patch moves the put
> > operation late.
> >
> > Fixes: 49d31c2f389a("dentry name snapshots")
>
> What does that commit have to do with anything? The broken part is
> fsnotify_move(new_dir, old_dir, old_dentry->d_name.name,
> new_is_dir, NULL, new_dentry);
> and it predates that commit by 3 years - it came from da1ce0670c14 ("vfs: add
> cross-rename")...
Thank you for pointing out my mistake! I will correct it and resubmit
the patch!
Best regards,
Pan
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2018-11-25 11:01 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-11-24 9:23 [PATCH] namei: free new_dentry late Pan Bian
2018-11-24 19:51 ` Al Viro
2018-11-25 0:11 ` PanBian
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).