~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/tools/testing/radix-tree/regression3.c

Version: ~ [ linux-5.2 ] ~ [ linux-5.1.16 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.57 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.132 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.184 ] ~ [ linux-4.8.17 ] ~ [ linux-4.7.10 ] ~ [ linux-4.6.7 ] ~ [ linux-4.5.7 ] ~ [ linux-4.4.184 ] ~ [ linux-4.3.6 ] ~ [ linux-4.2.8 ] ~ [ linux-4.1.52 ] ~ [ linux-4.0.9 ] ~ [ linux-3.19.8 ] ~ [ linux-3.18.140 ] ~ [ linux-3.17.8 ] ~ [ linux-3.16.69 ] ~ [ linux-3.15.10 ] ~ [ linux-3.14.79 ] ~ [ linux-3.13.11 ] ~ [ linux-3.12.74 ] ~ [ linux-3.11.10 ] ~ [ linux-3.10.108 ] ~ [ linux-3.9.11 ] ~ [ linux-3.8.13 ] ~ [ linux-3.7.10 ] ~ [ linux-3.6.11 ] ~ [ linux-3.5.7 ] ~ [ linux-3.4.113 ] ~ [ linux-3.3.8 ] ~ [ linux-3.2.102 ] ~ [ linux-3.1.10 ] ~ [ linux-3.0.101 ] ~ [ linux-2.6.39.4 ] ~ [ linux-2.6.38.8 ] ~ [ linux-2.6.37.6 ] ~ [ linux-2.6.36.4 ] ~ [ linux-2.6.35.14 ] ~ [ linux-2.6.34.15 ] ~ [ linux-2.6.33.20 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.5 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 /*
  2  * Regression3
  3  * Description:
  4  * Helper radix_tree_iter_retry resets next_index to the current index.
  5  * In following radix_tree_next_slot current chunk size becomes zero.
  6  * This isn't checked and it tries to dereference null pointer in slot.
  7  *
  8  * Helper radix_tree_iter_resume reset slot to NULL and next_index to index + 1,
  9  * for tagger iteraction it also must reset cached tags in iterator to abort
 10  * next radix_tree_next_slot and go to slow-path into radix_tree_next_chunk.
 11  *
 12  * Running:
 13  * This test should run to completion immediately. The above bug would
 14  * cause it to segfault.
 15  *
 16  * Upstream commit:
 17  * Not yet
 18  */
 19 #include <linux/kernel.h>
 20 #include <linux/gfp.h>
 21 #include <linux/slab.h>
 22 #include <linux/radix-tree.h>
 23 #include <stdlib.h>
 24 #include <stdio.h>
 25 
 26 #include "regression.h"
 27 
 28 void regression3_test(void)
 29 {
 30         RADIX_TREE(root, GFP_KERNEL);
 31         void *ptr0 = (void *)4ul;
 32         void *ptr = (void *)8ul;
 33         struct radix_tree_iter iter;
 34         void **slot;
 35         bool first;
 36 
 37         printf("running regression test 3 (should take milliseconds)\n");
 38 
 39         radix_tree_insert(&root, 0, ptr0);
 40         radix_tree_tag_set(&root, 0, 0);
 41 
 42         first = true;
 43         radix_tree_for_each_tagged(slot, &root, &iter, 0, 0) {
 44                 printf("tagged %ld %p\n", iter.index, *slot);
 45                 if (first) {
 46                         radix_tree_insert(&root, 1, ptr);
 47                         radix_tree_tag_set(&root, 1, 0);
 48                         first = false;
 49                 }
 50                 if (radix_tree_deref_retry(*slot)) {
 51                         printf("retry at %ld\n", iter.index);
 52                         slot = radix_tree_iter_retry(&iter);
 53                         continue;
 54                 }
 55         }
 56         radix_tree_delete(&root, 1);
 57 
 58         first = true;
 59         radix_tree_for_each_slot(slot, &root, &iter, 0) {
 60                 printf("slot %ld %p\n", iter.index, *slot);
 61                 if (first) {
 62                         radix_tree_insert(&root, 1, ptr);
 63                         first = false;
 64                 }
 65                 if (radix_tree_deref_retry(*slot)) {
 66                         printk("retry at %ld\n", iter.index);
 67                         slot = radix_tree_iter_retry(&iter);
 68                         continue;
 69                 }
 70         }
 71         radix_tree_delete(&root, 1);
 72 
 73         first = true;
 74         radix_tree_for_each_contig(slot, &root, &iter, 0) {
 75                 printk("contig %ld %p\n", iter.index, *slot);
 76                 if (first) {
 77                         radix_tree_insert(&root, 1, ptr);
 78                         first = false;
 79                 }
 80                 if (radix_tree_deref_retry(*slot)) {
 81                         printk("retry at %ld\n", iter.index);
 82                         slot = radix_tree_iter_retry(&iter);
 83                         continue;
 84                 }
 85         }
 86 
 87         radix_tree_for_each_slot(slot, &root, &iter, 0) {
 88                 printf("slot %ld %p\n", iter.index, *slot);
 89                 if (!iter.index) {
 90                         printf("next at %ld\n", iter.index);
 91                         slot = radix_tree_iter_resume(slot, &iter);
 92                 }
 93         }
 94 
 95         radix_tree_for_each_contig(slot, &root, &iter, 0) {
 96                 printf("contig %ld %p\n", iter.index, *slot);
 97                 if (!iter.index) {
 98                         printf("next at %ld\n", iter.index);
 99                         slot = radix_tree_iter_resume(slot, &iter);
100                 }
101         }
102 
103         radix_tree_tag_set(&root, 0, 0);
104         radix_tree_tag_set(&root, 1, 0);
105         radix_tree_for_each_tagged(slot, &root, &iter, 0, 0) {
106                 printf("tagged %ld %p\n", iter.index, *slot);
107                 if (!iter.index) {
108                         printf("next at %ld\n", iter.index);
109                         slot = radix_tree_iter_resume(slot, &iter);
110                 }
111         }
112 
113         radix_tree_delete(&root, 0);
114         radix_tree_delete(&root, 1);
115 
116         printf("regression test 3 passed\n");
117 }
118 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | Wiki (Japanese) | Wiki (English) | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

osdn.jp