Skip to content

Commit

Permalink
exportfs: do not read dentry after free
Browse files Browse the repository at this point in the history
The function dentry_connected calls dput(dentry) to drop the previously
acquired reference to dentry. In this case, dentry can be released.
After that, IS_ROOT(dentry) checks the condition
(dentry == dentry->d_parent), which may result in a use-after-free bug.
This patch directly compares dentry with its parent obtained before
dropping the reference.

Fixes: a056cc8("exportfs: stop retrying once we race with
rename/remove")

Signed-off-by: Pan Bian <[email protected]>
Signed-off-by: Al Viro <[email protected]>
  • Loading branch information
SinkFinder authored and Al Viro committed Nov 23, 2018
1 parent 909e22e commit 2084ac6
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion fs/exportfs/expfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ static bool dentry_connected(struct dentry *dentry)
struct dentry *parent = dget_parent(dentry);

dput(dentry);
if (IS_ROOT(dentry)) {
if (dentry == parent) {
dput(parent);
return false;
}
Expand Down

0 comments on commit 2084ac6

Please sign in to comment.