Skip to content

Commit

Permalink
kernfs: fix hash calculation in kernfs_rename_ns()
Browse files Browse the repository at this point in the history
3eef34a ("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.

Signed-off-by: Tejun Heo <[email protected]>
Reported-by: Dan Carpenter [email protected]
Signed-off-by: Greg Kroah-Hartman <[email protected]>
  • Loading branch information
htejun authored and gregkh committed Feb 11, 2014
1 parent ba341d5 commit 9561a89
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion fs/kernfs/dir.c
Original file line number Diff line number Diff line change
Expand Up @@ -1295,7 +1295,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);
Expand Down

0 comments on commit 9561a89

Please sign in to comment.