1 // SPDX-License-Identifier: GPL-2.0 1 2 /* 3 * Regression3 4 * Description: 5 * Helper radix_tree_iter_retry resets next_in 6 * In following radix_tree_next_slot current c 7 * This isn't checked and it tries to derefere 8 * 9 * Helper radix_tree_iter_resume reset slot to 10 * for tagger iteraction it also must reset ca 11 * next radix_tree_next_slot and go to slow-pa 12 * 13 * Running: 14 * This test should run to completion immediat 15 * cause it to segfault. 16 * 17 * Upstream commit: 18 * Not yet 19 */ 20 #include <linux/kernel.h> 21 #include <linux/gfp.h> 22 #include <linux/slab.h> 23 #include <linux/radix-tree.h> 24 #include <stdlib.h> 25 #include <stdio.h> 26 27 #include "regression.h" 28 29 void regression3_test(void) 30 { 31 RADIX_TREE(root, GFP_KERNEL); 32 void *ptr0 = (void *)4ul; 33 void *ptr = (void *)8ul; 34 struct radix_tree_iter iter; 35 void **slot; 36 bool first; 37 38 printv(1, "running regression test 3 ( 39 40 radix_tree_insert(&root, 0, ptr0); 41 radix_tree_tag_set(&root, 0, 0); 42 43 first = true; 44 radix_tree_for_each_tagged(slot, &root 45 printv(2, "tagged %ld %p\n", i 46 if (first) { 47 radix_tree_insert(&roo 48 radix_tree_tag_set(&ro 49 first = false; 50 } 51 if (radix_tree_deref_retry(*sl 52 printv(2, "retry at %l 53 slot = radix_tree_iter 54 continue; 55 } 56 } 57 radix_tree_delete(&root, 1); 58 59 first = true; 60 radix_tree_for_each_slot(slot, &root, 61 printv(2, "slot %ld %p\n", ite 62 if (first) { 63 radix_tree_insert(&roo 64 first = false; 65 } 66 if (radix_tree_deref_retry(*sl 67 printv(2, "retry at %l 68 slot = radix_tree_iter 69 continue; 70 } 71 } 72 73 radix_tree_for_each_slot(slot, &root, 74 printv(2, "slot %ld %p\n", ite 75 if (!iter.index) { 76 printv(2, "next at %ld 77 slot = radix_tree_iter 78 } 79 } 80 81 radix_tree_tag_set(&root, 0, 0); 82 radix_tree_tag_set(&root, 1, 0); 83 radix_tree_for_each_tagged(slot, &root 84 printv(2, "tagged %ld %p\n", i 85 if (!iter.index) { 86 printv(2, "next at %ld 87 slot = radix_tree_iter 88 } 89 } 90 91 radix_tree_delete(&root, 0); 92 radix_tree_delete(&root, 1); 93 94 printv(1, "regression test 3 passed\n" 95 } 96
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.