Skip to contentSkip to conversation

ceph_wait_on_conflict_unlink(): grab reference before dropping ->d_lock

PATCH In review Al Viro 3 participants 3 messages Oct 26, 2023 – Oct 30, 2023

Subsystems (2)
lore
Share & tools
lore

Al Viro

author maintainer
#0 lore raw

PATCH 1/1 ceph_wait_on_conflict_unlink(): grab reference before dropping ->d_lock

[at the moment in viro/vfs.git#fixes]
Use of dget() after we'd dropped ->d_lock is too late - dentry might be gone by that point.

---
 fs/ceph/mds_client.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/ceph/mds_client.c +1 -1
index 615db141b6c4..293b93182955 100644
@@ -861,8 +861,8 @@ int ceph_wait_on_conflict_unlink(struct dentry *dentry)
 		if (!d_same_name(udentry, pdentry, &dname))
 			goto next;
 
+		found = dget_dlock(udentry);
 		spin_unlock(&udentry->d_lock);
-		found = dget(udentry);
 		break;
 next:
 		spin_unlock(&udentry->d_lock);
Signature · 1 line
2.39.2
Reviewed-by on v1 1/1
#1 lore raw
Quoted 14 lines · Al Viro

[at the moment in viro/vfs.git#fixes]
Use of dget() after we'd dropped ->d_lock is too late - dentry might be gone by that point.

---
 fs/ceph/mds_client.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/ceph/mds_client.c +0 -0
index 615db141b6c4..293b93182955 100644

fs/ceph/mds_client.c int ceph_wait_on_conflict_unlink(struct dentry *dentry) · line 868

Quoted 9 lines
fs/ceph/mds_client.c +1 -1
@@ -861,8 +861,8 @@ int ceph_wait_on_conflict_unlink(struct dentry *dentry)
 		if (!d_same_name(udentry, pdentry, &dname))
 			goto next;
 
+		found = dget_dlock(udentry);
 		spin_unlock(&udentry->d_lock);
-		found = dget(udentry);
 		break;
 next:
 		spin_unlock(&udentry->d_lock);
#2 lore raw
In reply to Al Viro
Quoted 14 lines · Al Viro

[at the moment in viro/vfs.git#fixes]
Use of dget() after we'd dropped ->d_lock is too late - dentry might be gone by that point.

---
  fs/ceph/mds_client.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
fs/ceph/mds_client.c +0 -0
index 615db141b6c4..293b93182955 100644

fs/ceph/mds_client.c int ceph_wait_on_conflict_unlink(struct dentry *dentry) · line 868

Quoted 9 lines
fs/ceph/mds_client.c +1 -1
@@ -861,8 +861,8 @@ int ceph_wait_on_conflict_unlink(struct dentry *dentry)
  		if (!d_same_name(udentry, pdentry, &dname))
  			goto next;
 
+		found = dget_dlock(udentry);
  		spin_unlock(&udentry->d_lock);
-		found = dget(udentry);
  		break;
  next:
  		spin_unlock(&udentry->d_lock);

Good catch.

Thanks Al.

- Xiubo