Skip to content

Commit 2084ac6

Browse files
SinkFinderAl Viro
authored andcommitted
exportfs: do not read dentry after free
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 <bianpan2016@163.com> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
1 parent 909e22e commit 2084ac6

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

fs/exportfs/expfs.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ static bool dentry_connected(struct dentry *dentry)
7777
struct dentry *parent = dget_parent(dentry);
7878

7979
dput(dentry);
80-
if (IS_ROOT(dentry)) {
80+
if (dentry == parent) {
8181
dput(parent);
8282
return false;
8383
}

0 commit comments

Comments
 (0)