]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blame - releases/4.7.3/sunrpc-fix-infinite-looping-in-rpc_clnt_iterate_for_each_xprt.patch
5.1-stable patches
[thirdparty/kernel/stable-queue.git] / releases / 4.7.3 / sunrpc-fix-infinite-looping-in-rpc_clnt_iterate_for_each_xprt.patch
CommitLineData
ad834691
GKH
1From bdc54d8e3cb4a41dddcabfd86d9eb3aa5f622b75 Mon Sep 17 00:00:00 2001
2From: Trond Myklebust <trond.myklebust@primarydata.com>
3Date: Sat, 16 Jul 2016 11:47:00 -0400
4Subject: SUNRPC: Fix infinite looping in rpc_clnt_iterate_for_each_xprt
5
6From: Trond Myklebust <trond.myklebust@primarydata.com>
7
8commit bdc54d8e3cb4a41dddcabfd86d9eb3aa5f622b75 upstream.
9
10If there were less than 2 entries in the multipath list, then
11xprt_iter_next_entry_multiple() would never advance beyond the
12first entry, which is correct for round robin behaviour, but not
13for the list iteration.
14
15The end result would be infinite looping in rpc_clnt_iterate_for_each_xprt()
16as we would never see the xprt == NULL condition fulfilled.
17
18Reported-by: Oleg Drokin <green@linuxhacker.ru>
19Fixes: 80b14d5e61ca ("SUNRPC: Add a structure to track multiple transports")
20Signed-off-by: Trond Myklebust <trond.myklebust@primarydata.com>
21Cc: Jason L Tibbitts III <tibbs@math.uh.edu>
22Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
23
24---
25 net/sunrpc/xprtmultipath.c | 8 +++-----
26 1 file changed, 3 insertions(+), 5 deletions(-)
27
28--- a/net/sunrpc/xprtmultipath.c
29+++ b/net/sunrpc/xprtmultipath.c
30@@ -271,14 +271,12 @@ struct rpc_xprt *xprt_iter_next_entry_mu
31 xprt_switch_find_xprt_t find_next)
32 {
33 struct rpc_xprt_switch *xps = rcu_dereference(xpi->xpi_xpswitch);
34- struct list_head *head;
35
36 if (xps == NULL)
37 return NULL;
38- head = &xps->xps_xprt_list;
39- if (xps->xps_nxprts < 2)
40- return xprt_switch_find_first_entry(head);
41- return xprt_switch_set_next_cursor(head, &xpi->xpi_cursor, find_next);
42+ return xprt_switch_set_next_cursor(&xps->xps_xprt_list,
43+ &xpi->xpi_cursor,
44+ find_next);
45 }
46
47 static