kernfs: fix hash calculation in kernfs_rename_ns()
Tejun Heo
maintainerPATCH 1/1 kernfs: fix hash calculation in kernfs_rename_ns()
3eef34ad7dc3 ("kernfs: implement kernfs_get_parent(), kernfs_name/path() and friends") restructured kernfs_rename_ns() such that new name assignment happens under kernfs_rename_lock; unfortunately, it mistakenly passed NULL to kernfs_name_hash() to calculate the new hash if the name hasn't changed, which can lead to oops.
Fix it by using kn->name and kn->ns when calculating the new hash.
--- fs/kernfs/dir.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/kernfs/dir.c +1 -1
@@ -1296,7 +1296,7 @@ int kernfs_rename_ns(struct kernfs_node *kn, struct kernfs_node *new_parent,spin_unlock_irq (&kernfs_rename_lock); - kn->hash =kernfs_name_hash (new_name, new_ns); + kn->hash =kernfs_name_hash (kn->name, kn->ns);kernfs_link_sibling (kn);kernfs_put (old_parent);
Greg Kroah-Hartman
maintainerQuoted 8 lines · Tejun Heo
3eef34ad7dc3("kernfs: implementkernfs_get_parent(), kernfs_name/path() and friends") restructuredkernfs_rename_ns()such that new name assignment happens underkernfs_rename_lock; unfortunately, it mistakenly passed NULL tokernfs_name_hash()to calculate the new hash if the name hasn't changed, which can lead to oops.Fix it by using
kn->nameandkn->nswhen calculating the new hash.
Now applied, thanks.
Also, can you look into the merge of 3.14-rc2 into the driver-core-next branch? There are some conflicts in the kernfs code due to the lockdep changes that I couldn't easily verify I got right, so I didn't do the merge. Could you give me a diff of the merge for me to work off of?
thanks,
greg k-h
Tejun Heo
maintainerHello, Greg.
Quoted 4 lines · Greg Kroah-Hartman
Also, can you look into the merge of 3.14-rc2 into the driver-core-next branch? There are some conflicts in the kernfs code due to the lockdep changes that I couldn't easily verify I got right, so I didn't do the merge. Could you give me a diff of the merge for me to work off of?
Sure thing. It can be resolved by simply ignoring the driver-core-linus side. kernfs_drain() updates in driver-core-next already has all the necessary lockdep flag checks through kernfs_lockdep().
The following git branch contains a test merge between driver-core-next and rc2.
git://git.kernel.org/pub/scm/linux/kernel/git/tj/misc.git driver-core-next-test-merge-rc2
Thanks!
Signature · 1 line
tejun
Greg Kroah-Hartman
maintainerQuoted 13 lines · Tejun Heo
Hello, Greg.
Quoted 4 lines · Greg Kroah-Hartman
Also, can you look into the merge of 3.14-rc2 into the driver-core-next branch? There are some conflicts in the kernfs code due to the lockdep changes that I couldn't easily verify I got right, so I didn't do the merge. Could you give me a diff of the merge for me to work off of?
Sure thing. It can be resolved by simply ignoring the driver-core-linus side.
kernfs_drain()updates in driver-core-next already has all the necessary lockdep flag checks throughkernfs_lockdep().
Quoted 4 lines
The following git branch contains a test merge between driver-core-next and rc2.
git://git.kernel.org/pub/scm/linux/kernel/git/tj/misc.gitdriver-core-next-test-merge-rc2
Thanks, I took this merge and pulled it into my tree.
greg k-h