]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - releases/3.4.2/radix-tree-fix-contiguous-iterator.patch
Linux 4.14.95
[thirdparty/kernel/stable-queue.git] / releases / 3.4.2 / radix-tree-fix-contiguous-iterator.patch
1 From fffaee365fded09f9ebf2db19066065fa54323c3 Mon Sep 17 00:00:00 2001
2 From: Konstantin Khlebnikov <khlebnikov@openvz.org>
3 Date: Tue, 5 Jun 2012 21:36:33 +0400
4 Subject: radix-tree: fix contiguous iterator
5 MIME-Version: 1.0
6 Content-Type: text/plain; charset=UTF-8
7 Content-Transfer-Encoding: 8bit
8
9 From: Konstantin Khlebnikov <khlebnikov@openvz.org>
10
11 commit fffaee365fded09f9ebf2db19066065fa54323c3 upstream.
12
13 This patch fixes bug in macro radix_tree_for_each_contig().
14
15 If radix_tree_next_slot() sees NULL in next slot it returns NULL, but following
16 radix_tree_next_chunk() switches iterating into next chunk. As result iterating
17 becomes non-contiguous and breaks vfs "splice" and all its users.
18
19 Signed-off-by: Konstantin Khlebnikov <khlebnikov@openvz.org>
20 Reported-and-bisected-by: Hans de Bruin <jmdebruin@xmsnet.nl>
21 Reported-and-bisected-by: Ondrej Zary <linux@rainbow-software.org>
22 Reported-bisected-and-tested-by: Toralf Förster <toralf.foerster@gmx.de>
23 Link: https://lkml.org/lkml/2012/6/5/64
24 Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
25 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
26
27 ---
28 include/linux/radix-tree.h | 5 ++++-
29 lib/radix-tree.c | 3 +++
30 2 files changed, 7 insertions(+), 1 deletion(-)
31
32 --- a/include/linux/radix-tree.h
33 +++ b/include/linux/radix-tree.h
34 @@ -368,8 +368,11 @@ radix_tree_next_slot(void **slot, struct
35 iter->index++;
36 if (likely(*slot))
37 return slot;
38 - if (flags & RADIX_TREE_ITER_CONTIG)
39 + if (flags & RADIX_TREE_ITER_CONTIG) {
40 + /* forbid switching to the next chunk */
41 + iter->next_index = 0;
42 break;
43 + }
44 }
45 }
46 return NULL;
47 --- a/lib/radix-tree.c
48 +++ b/lib/radix-tree.c
49 @@ -673,6 +673,9 @@ void **radix_tree_next_chunk(struct radi
50 * during iterating; it can be zero only at the beginning.
51 * And we cannot overflow iter->next_index in a single step,
52 * because RADIX_TREE_MAP_SHIFT < BITS_PER_LONG.
53 + *
54 + * This condition also used by radix_tree_next_slot() to stop
55 + * contiguous iterating, and forbid swithing to the next chunk.
56 */
57 index = iter->next_index;
58 if (!index && iter->index)