]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blame - releases/4.4.103/fs-9p-compare-qid.path-in-v9fs_test_inode.patch
4.14-stable patches
[thirdparty/kernel/stable-queue.git] / releases / 4.4.103 / fs-9p-compare-qid.path-in-v9fs_test_inode.patch
CommitLineData
d431789d
GKH
1From 8ee031631546cf2f7859cc69593bd60bbdd70b46 Mon Sep 17 00:00:00 2001
2From: Tuomas Tynkkynen <tuomas@tuxera.com>
3Date: Wed, 6 Sep 2017 17:59:07 +0300
4Subject: fs/9p: Compare qid.path in v9fs_test_inode
5
6From: Tuomas Tynkkynen <tuomas@tuxera.com>
7
8commit 8ee031631546cf2f7859cc69593bd60bbdd70b46 upstream.
9
10Commit fd2421f54423 ("fs/9p: When doing inode lookup compare qid details
11and inode mode bits.") transformed v9fs_qid_iget() to use iget5_locked()
12instead of iget_locked(). However, the test() callback is not checking
13fid.path at all, which means that a lookup in the inode cache can now
14accidentally locate a completely wrong inode from the same inode hash
15bucket if the other fields (qid.type and qid.version) match.
16
17Fixes: fd2421f54423 ("fs/9p: When doing inode lookup compare qid details and inode mode bits.")
18Reviewed-by: Latchesar Ionkov <lucho@ionkov.net>
19Signed-off-by: Tuomas Tynkkynen <tuomas@tuxera.com>
20Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
21Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
22
23---
24 fs/9p/vfs_inode.c | 3 +++
25 fs/9p/vfs_inode_dotl.c | 3 +++
26 2 files changed, 6 insertions(+)
27
28--- a/fs/9p/vfs_inode.c
29+++ b/fs/9p/vfs_inode.c
30@@ -483,6 +483,9 @@ static int v9fs_test_inode(struct inode
31
32 if (v9inode->qid.type != st->qid.type)
33 return 0;
34+
35+ if (v9inode->qid.path != st->qid.path)
36+ return 0;
37 return 1;
38 }
39
40--- a/fs/9p/vfs_inode_dotl.c
41+++ b/fs/9p/vfs_inode_dotl.c
42@@ -87,6 +87,9 @@ static int v9fs_test_inode_dotl(struct i
43
44 if (v9inode->qid.type != st->qid.type)
45 return 0;
46+
47+ if (v9inode->qid.path != st->qid.path)
48+ return 0;
49 return 1;
50 }
51