summarylogtreecommitdiffstats
path: root/0004-Linux-lock-the-parent-dentry-for-lookup_one_len.patch
blob: 52856dcbcc56864450e560b35caadaa46481aafb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
From a42d68d51dc8c864cf5fde02a8f0277e82ca8696 Mon Sep 17 00:00:00 2001
From: Benjamin Kaduk <kaduk@mit.edu>
Date: Sun, 1 May 2016 19:39:55 -0400
Subject: [PATCH 4/5] Linux: lock the parent dentry for lookup_one_len()

During review of the changes in Linux 4.5, it was noted that
callers of lookup_one_len() are obligated to hold the i_mutex
on the parent directory, though we do not currently do so.
Take the lock around the call as needed.

The only call to lookup_one_len() occurs in afs_linux_sillyrename(),
so may workloads may not encounter this codepath.

Change-Id: I4d566c9a704173973c062c3d38f1d481f76c42da
---
 src/afs/LINUX/osi_vnodeops.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/src/afs/LINUX/osi_vnodeops.c b/src/afs/LINUX/osi_vnodeops.c
index 00b41ef..532c9e9 100644
--- a/src/afs/LINUX/osi_vnodeops.c
+++ b/src/afs/LINUX/osi_vnodeops.c
@@ -1654,7 +1654,9 @@ afs_linux_sillyrename(struct inode *dir, struct dentry *dentry,
 	__name = afs_newname();
 	AFS_GUNLOCK();
 
+	afs_linux_lock_inode(dentry->d_parent->d_inode);
 	__dp = lookup_one_len(__name, dentry->d_parent, strlen(__name));
+	afs_linux_unlock_inode(dentry->d_parent->d_inode);
 
 	if (IS_ERR(__dp)) {
 	    osi_FreeSmallSpace(__name);
-- 
2.8.2