blob: 8b90220216e23f678a5636f9d48f3e644decfa9c [file] [log] [blame]
Ankita Garg8bb31b92006-10-02 02:17:36 -07001/*
Kees Cook426f3a52016-06-03 11:16:32 -07002 * Linux Kernel Dump Test Module for testing kernel crashes conditions:
3 * induces system failures at predefined crashpoints and under predefined
4 * operational conditions in order to evaluate the reliability of kernel
5 * sanity checking and crash dumps obtained using different dumping
6 * solutions.
Ankita Garg8bb31b92006-10-02 02:17:36 -07007 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21 *
22 * Copyright (C) IBM Corporation, 2006
23 *
24 * Author: Ankita Garg <ankita@in.ibm.com>
25 *
Ankita Garg8bb31b92006-10-02 02:17:36 -070026 * It is adapted from the Linux Kernel Dump Test Tool by
27 * Fernando Luis Vazquez Cao <http://lkdtt.sourceforge.net>
28 *
Simon Kagstrom0347af42010-03-05 13:42:49 -080029 * Debugfs support added by Simon Kagstrom <simon.kagstrom@netinsight.net>
Ankita Garg8bb31b92006-10-02 02:17:36 -070030 *
Simon Kagstrom0347af42010-03-05 13:42:49 -080031 * See Documentation/fault-injection/provoke-crashes.txt for instructions
Ankita Garg8bb31b92006-10-02 02:17:36 -070032 */
Kees Cook426f3a52016-06-03 11:16:32 -070033#define pr_fmt(fmt) "lkdtm: " fmt
Ankita Garg8bb31b92006-10-02 02:17:36 -070034
35#include <linux/kernel.h>
Randy Dunlap5d861d92006-11-02 22:07:06 -080036#include <linux/fs.h>
Ankita Garg8bb31b92006-10-02 02:17:36 -070037#include <linux/module.h>
Randy Dunlap5d861d92006-11-02 22:07:06 -080038#include <linux/buffer_head.h>
Ankita Garg8bb31b92006-10-02 02:17:36 -070039#include <linux/kprobes.h>
Randy Dunlap5d861d92006-11-02 22:07:06 -080040#include <linux/list.h>
Ankita Garg8bb31b92006-10-02 02:17:36 -070041#include <linux/init.h>
Ankita Garg8bb31b92006-10-02 02:17:36 -070042#include <linux/interrupt.h>
Randy Dunlap5d861d92006-11-02 22:07:06 -080043#include <linux/hrtimer.h>
Tejun Heo5a0e3ad2010-03-24 17:04:11 +090044#include <linux/slab.h>
Ankita Garg8bb31b92006-10-02 02:17:36 -070045#include <scsi/scsi_cmnd.h>
Simon Kagstrom0347af42010-03-05 13:42:49 -080046#include <linux/debugfs.h>
Ankita Garg8bb31b92006-10-02 02:17:36 -070047
48#ifdef CONFIG_IDE
49#include <linux/ide.h>
50#endif
51
Kees Cook9a49a522016-02-22 14:09:29 -080052#include "lkdtm.h"
53
Kees Cookd87c9782016-06-29 08:07:11 -070054#define DEFAULT_COUNT 10
55
56static int lkdtm_parse_commandline(void);
57static void lkdtm_handler(void);
58
Kees Cookf2c6edc2016-06-29 08:10:36 -070059/* jprobe entry point handlers. */
60static unsigned int jp_do_irq(unsigned int irq)
61{
62 lkdtm_handler();
63 jprobe_return();
64 return 0;
65}
66
67static irqreturn_t jp_handle_irq_event(unsigned int irq,
68 struct irqaction *action)
69{
70 lkdtm_handler();
71 jprobe_return();
72 return 0;
73}
74
75static void jp_tasklet_action(struct softirq_action *a)
76{
77 lkdtm_handler();
78 jprobe_return();
79}
80
81static void jp_ll_rw_block(int rw, int nr, struct buffer_head *bhs[])
82{
83 lkdtm_handler();
84 jprobe_return();
85}
86
87struct scan_control;
88
89static unsigned long jp_shrink_inactive_list(unsigned long max_scan,
90 struct zone *zone,
91 struct scan_control *sc)
92{
93 lkdtm_handler();
94 jprobe_return();
95 return 0;
96}
97
98static int jp_hrtimer_start(struct hrtimer *timer, ktime_t tim,
99 const enum hrtimer_mode mode)
100{
101 lkdtm_handler();
102 jprobe_return();
103 return 0;
104}
105
106static int jp_scsi_dispatch_cmd(struct scsi_cmnd *cmd)
107{
108 lkdtm_handler();
109 jprobe_return();
110 return 0;
111}
112
113#ifdef CONFIG_IDE
114static int jp_generic_ide_ioctl(ide_drive_t *drive, struct file *file,
115 struct block_device *bdev, unsigned int cmd,
116 unsigned long arg)
117{
118 lkdtm_handler();
119 jprobe_return();
120 return 0;
121}
122#endif
123
Ankita Garg8bb31b92006-10-02 02:17:36 -0700124enum cname {
Namhyung Kim93e2f582010-10-26 14:22:40 -0700125 CN_INVALID,
126 CN_INT_HARDWARE_ENTRY,
127 CN_INT_HW_IRQ_EN,
128 CN_INT_TASKLET_ENTRY,
129 CN_FS_DEVRW,
130 CN_MEM_SWAPOUT,
131 CN_TIMERADD,
132 CN_SCSI_DISPATCH_CMD,
133 CN_IDE_CORE_CP,
134 CN_DIRECT,
Ankita Garg8bb31b92006-10-02 02:17:36 -0700135};
136
137enum ctype {
Namhyung Kim93e2f582010-10-26 14:22:40 -0700138 CT_NONE,
139 CT_PANIC,
140 CT_BUG,
Kees Cook65892722013-07-08 10:01:31 -0700141 CT_WARNING,
Namhyung Kim93e2f582010-10-26 14:22:40 -0700142 CT_EXCEPTION,
143 CT_LOOP,
144 CT_OVERFLOW,
145 CT_CORRUPT_STACK,
146 CT_UNALIGNED_LOAD_STORE_WRITE,
147 CT_OVERWRITE_ALLOCATION,
148 CT_WRITE_AFTER_FREE,
Laura Abbottbc0b8cc2016-02-25 16:36:42 -0800149 CT_READ_AFTER_FREE,
Laura Abbott920d4512016-02-25 16:36:44 -0800150 CT_WRITE_BUDDY_AFTER_FREE,
151 CT_READ_BUDDY_AFTER_FREE,
Namhyung Kim93e2f582010-10-26 14:22:40 -0700152 CT_SOFTLOCKUP,
153 CT_HARDLOCKUP,
Kees Cook274a5852013-07-08 10:01:32 -0700154 CT_SPINLOCKUP,
Namhyung Kim93e2f582010-10-26 14:22:40 -0700155 CT_HUNG_TASK,
Kees Cookcc33c5372013-07-08 10:01:33 -0700156 CT_EXEC_DATA,
157 CT_EXEC_STACK,
158 CT_EXEC_KMALLOC,
159 CT_EXEC_VMALLOC,
Kees Cook9a49a522016-02-22 14:09:29 -0800160 CT_EXEC_RODATA,
Kees Cook9ae113c2013-10-24 09:25:57 -0700161 CT_EXEC_USERSPACE,
162 CT_ACCESS_USERSPACE,
163 CT_WRITE_RO,
Kees Cook7cca0712016-02-17 14:41:16 -0800164 CT_WRITE_RO_AFTER_INIT,
Kees Cookdc2b9e92014-02-09 13:48:48 -0800165 CT_WRITE_KERN,
Kees Cookb5484522016-06-07 14:27:02 -0700166 CT_ATOMIC_UNDERFLOW,
167 CT_ATOMIC_OVERFLOW,
Kees Cookaa981a62016-06-03 12:06:52 -0700168 CT_USERCOPY_HEAP_SIZE_TO,
169 CT_USERCOPY_HEAP_SIZE_FROM,
170 CT_USERCOPY_HEAP_FLAG_TO,
171 CT_USERCOPY_HEAP_FLAG_FROM,
172 CT_USERCOPY_STACK_FRAME_TO,
173 CT_USERCOPY_STACK_FRAME_FROM,
174 CT_USERCOPY_STACK_BEYOND,
Kees Cook6c352142016-06-23 22:01:26 -0700175 CT_USERCOPY_KERNEL,
Ankita Garg8bb31b92006-10-02 02:17:36 -0700176};
177
178static char* cp_name[] = {
Kees Cook329d4162016-06-26 22:26:11 -0700179 "INVALID",
Ankita Garg8bb31b92006-10-02 02:17:36 -0700180 "INT_HARDWARE_ENTRY",
181 "INT_HW_IRQ_EN",
182 "INT_TASKLET_ENTRY",
183 "FS_DEVRW",
184 "MEM_SWAPOUT",
185 "TIMERADD",
186 "SCSI_DISPATCH_CMD",
Simon Kagstrom0347af42010-03-05 13:42:49 -0800187 "IDE_CORE_CP",
188 "DIRECT",
Ankita Garg8bb31b92006-10-02 02:17:36 -0700189};
190
191static char* cp_type[] = {
Kees Cook329d4162016-06-26 22:26:11 -0700192 "NONE",
Ankita Garg8bb31b92006-10-02 02:17:36 -0700193 "PANIC",
194 "BUG",
Kees Cook65892722013-07-08 10:01:31 -0700195 "WARNING",
Ankita Garg8bb31b92006-10-02 02:17:36 -0700196 "EXCEPTION",
197 "LOOP",
Simon Kagstrom0347af42010-03-05 13:42:49 -0800198 "OVERFLOW",
199 "CORRUPT_STACK",
200 "UNALIGNED_LOAD_STORE_WRITE",
201 "OVERWRITE_ALLOCATION",
202 "WRITE_AFTER_FREE",
Laura Abbottbc0b8cc2016-02-25 16:36:42 -0800203 "READ_AFTER_FREE",
Laura Abbott920d4512016-02-25 16:36:44 -0800204 "WRITE_BUDDY_AFTER_FREE",
205 "READ_BUDDY_AFTER_FREE",
Frederic Weisbeckera48223f2010-05-26 14:44:29 -0700206 "SOFTLOCKUP",
207 "HARDLOCKUP",
Kees Cook274a5852013-07-08 10:01:32 -0700208 "SPINLOCKUP",
Frederic Weisbeckera48223f2010-05-26 14:44:29 -0700209 "HUNG_TASK",
Kees Cookcc33c5372013-07-08 10:01:33 -0700210 "EXEC_DATA",
211 "EXEC_STACK",
212 "EXEC_KMALLOC",
213 "EXEC_VMALLOC",
Kees Cook9a49a522016-02-22 14:09:29 -0800214 "EXEC_RODATA",
Kees Cook9ae113c2013-10-24 09:25:57 -0700215 "EXEC_USERSPACE",
216 "ACCESS_USERSPACE",
217 "WRITE_RO",
Kees Cook7cca0712016-02-17 14:41:16 -0800218 "WRITE_RO_AFTER_INIT",
Kees Cookdc2b9e92014-02-09 13:48:48 -0800219 "WRITE_KERN",
Kees Cookb5484522016-06-07 14:27:02 -0700220 "ATOMIC_UNDERFLOW",
221 "ATOMIC_OVERFLOW",
Kees Cookaa981a62016-06-03 12:06:52 -0700222 "USERCOPY_HEAP_SIZE_TO",
223 "USERCOPY_HEAP_SIZE_FROM",
224 "USERCOPY_HEAP_FLAG_TO",
225 "USERCOPY_HEAP_FLAG_FROM",
226 "USERCOPY_STACK_FRAME_TO",
227 "USERCOPY_STACK_FRAME_FROM",
228 "USERCOPY_STACK_BEYOND",
Kees Cook6c352142016-06-23 22:01:26 -0700229 "USERCOPY_KERNEL",
Ankita Garg8bb31b92006-10-02 02:17:36 -0700230};
231
Kees Cookd87c9782016-06-29 08:07:11 -0700232/* Global jprobe entry and crashtype. */
Kees Cook38f95fe2016-06-29 08:02:32 -0700233static struct jprobe lkdtm_jprobe;
Kees Cook38f95fe2016-06-29 08:02:32 -0700234static enum cname lkdtm_crashpoint = CN_INVALID;
235static enum ctype lkdtm_crashtype = CT_NONE;
Ankita Garg8bb31b92006-10-02 02:17:36 -0700236
Kees Cookd87c9782016-06-29 08:07:11 -0700237/* Global crash counter and spinlock. */
238static int crash_count = DEFAULT_COUNT;
239static DEFINE_SPINLOCK(crash_count_lock);
240
241/* Module parameters */
242static int recur_count = -1;
Ankita Garg8bb31b92006-10-02 02:17:36 -0700243module_param(recur_count, int, 0644);
Kees Cook7d196ac2013-10-24 09:25:39 -0700244MODULE_PARM_DESC(recur_count, " Recursion level for the stack overflow test");
Kees Cookd87c9782016-06-29 08:07:11 -0700245
246static char* cpoint_name;
Rusty Russelldca41302010-08-11 23:04:21 -0600247module_param(cpoint_name, charp, 0444);
Randy Dunlap5d861d92006-11-02 22:07:06 -0800248MODULE_PARM_DESC(cpoint_name, " Crash Point, where kernel is to be crashed");
Kees Cookd87c9782016-06-29 08:07:11 -0700249
250static char* cpoint_type;
Rusty Russelldca41302010-08-11 23:04:21 -0600251module_param(cpoint_type, charp, 0444);
Randy Dunlap5d861d92006-11-02 22:07:06 -0800252MODULE_PARM_DESC(cpoint_type, " Crash Point Type, action to be taken on "\
253 "hitting the crash point");
Kees Cookd87c9782016-06-29 08:07:11 -0700254
255static int cpoint_count = DEFAULT_COUNT;
Randy Dunlap5d861d92006-11-02 22:07:06 -0800256module_param(cpoint_count, int, 0644);
257MODULE_PARM_DESC(cpoint_count, " Crash Point Count, number of times the "\
258 "crash point is to be hit to trigger action");
Ankita Garg8bb31b92006-10-02 02:17:36 -0700259
Simon Kagstrom0347af42010-03-05 13:42:49 -0800260/* Return the crashpoint number or NONE if the name is invalid */
261static enum ctype parse_cp_type(const char *what, size_t count)
262{
263 int i;
264
265 for (i = 0; i < ARRAY_SIZE(cp_type); i++) {
266 if (!strcmp(what, cp_type[i]))
Kees Cook329d4162016-06-26 22:26:11 -0700267 return i;
Simon Kagstrom0347af42010-03-05 13:42:49 -0800268 }
269
Namhyung Kim93e2f582010-10-26 14:22:40 -0700270 return CT_NONE;
Simon Kagstrom0347af42010-03-05 13:42:49 -0800271}
272
273static const char *cp_type_to_str(enum ctype type)
274{
Namhyung Kim93e2f582010-10-26 14:22:40 -0700275 if (type == CT_NONE || type < 0 || type > ARRAY_SIZE(cp_type))
Kees Cook329d4162016-06-26 22:26:11 -0700276 return "NONE";
Simon Kagstrom0347af42010-03-05 13:42:49 -0800277
Kees Cook329d4162016-06-26 22:26:11 -0700278 return cp_type[type];
Simon Kagstrom0347af42010-03-05 13:42:49 -0800279}
280
281static const char *cp_name_to_str(enum cname name)
282{
Namhyung Kim93e2f582010-10-26 14:22:40 -0700283 if (name == CN_INVALID || name < 0 || name > ARRAY_SIZE(cp_name))
Simon Kagstrom0347af42010-03-05 13:42:49 -0800284 return "INVALID";
285
Kees Cook329d4162016-06-26 22:26:11 -0700286 return cp_name[name];
Simon Kagstrom0347af42010-03-05 13:42:49 -0800287}
288
289
Ankita Garg8bb31b92006-10-02 02:17:36 -0700290static int lkdtm_parse_commandline(void)
291{
292 int i;
Josh Huntaa2c96d2011-06-27 16:18:08 -0700293 unsigned long flags;
Ankita Garg8bb31b92006-10-02 02:17:36 -0700294
Simon Kagstrom0347af42010-03-05 13:42:49 -0800295 if (cpoint_count < 1 || recur_count < 1)
Ankita Garg8bb31b92006-10-02 02:17:36 -0700296 return -EINVAL;
297
Kees Cook76a10e22016-06-26 22:40:13 -0700298 spin_lock_irqsave(&crash_count_lock, flags);
299 crash_count = cpoint_count;
300 spin_unlock_irqrestore(&crash_count_lock, flags);
Ankita Garg8bb31b92006-10-02 02:17:36 -0700301
Simon Kagstrom0347af42010-03-05 13:42:49 -0800302 /* No special parameters */
303 if (!cpoint_type && !cpoint_name)
304 return 0;
305
306 /* Neither or both of these need to be set */
307 if (!cpoint_type || !cpoint_name)
308 return -EINVAL;
309
Kees Cook38f95fe2016-06-29 08:02:32 -0700310 lkdtm_crashtype = parse_cp_type(cpoint_type, strlen(cpoint_type));
311 if (lkdtm_crashtype == CT_NONE)
Simon Kagstrom0347af42010-03-05 13:42:49 -0800312 return -EINVAL;
313
Kees Cook329d4162016-06-26 22:26:11 -0700314 /* Refuse INVALID as a selectable crashpoint name. */
315 if (!strcmp(cpoint_name, "INVALID"))
316 return -EINVAL;
317
Simon Kagstrom0347af42010-03-05 13:42:49 -0800318 for (i = 0; i < ARRAY_SIZE(cp_name); i++) {
319 if (!strcmp(cpoint_name, cp_name[i])) {
Kees Cook38f95fe2016-06-29 08:02:32 -0700320 lkdtm_crashpoint = i;
Simon Kagstrom0347af42010-03-05 13:42:49 -0800321 return 0;
322 }
323 }
324
325 /* Could not find a valid crash point */
326 return -EINVAL;
Ankita Garg8bb31b92006-10-02 02:17:36 -0700327}
328
Simon Kagstrom0347af42010-03-05 13:42:49 -0800329static void lkdtm_do_action(enum ctype which)
Ankita Garg8bb31b92006-10-02 02:17:36 -0700330{
Simon Kagstrom0347af42010-03-05 13:42:49 -0800331 switch (which) {
Namhyung Kim93e2f582010-10-26 14:22:40 -0700332 case CT_PANIC:
Kees Cook00f496c2016-06-26 22:17:25 -0700333 lkdtm_PANIC();
Simon Kagstrom0347af42010-03-05 13:42:49 -0800334 break;
Namhyung Kim93e2f582010-10-26 14:22:40 -0700335 case CT_BUG:
Kees Cook00f496c2016-06-26 22:17:25 -0700336 lkdtm_BUG();
Simon Kagstrom0347af42010-03-05 13:42:49 -0800337 break;
Kees Cook65892722013-07-08 10:01:31 -0700338 case CT_WARNING:
Kees Cook00f496c2016-06-26 22:17:25 -0700339 lkdtm_WARNING();
Kees Cook65892722013-07-08 10:01:31 -0700340 break;
Namhyung Kim93e2f582010-10-26 14:22:40 -0700341 case CT_EXCEPTION:
Kees Cook00f496c2016-06-26 22:17:25 -0700342 lkdtm_EXCEPTION();
Simon Kagstrom0347af42010-03-05 13:42:49 -0800343 break;
Namhyung Kim93e2f582010-10-26 14:22:40 -0700344 case CT_LOOP:
Kees Cook00f496c2016-06-26 22:17:25 -0700345 lkdtm_LOOP();
Simon Kagstrom0347af42010-03-05 13:42:49 -0800346 break;
Namhyung Kim93e2f582010-10-26 14:22:40 -0700347 case CT_OVERFLOW:
Kees Cook00f496c2016-06-26 22:17:25 -0700348 lkdtm_OVERFLOW();
Simon Kagstrom0347af42010-03-05 13:42:49 -0800349 break;
Kees Cook629c66a2013-10-24 18:05:42 -0700350 case CT_CORRUPT_STACK:
Kees Cook00f496c2016-06-26 22:17:25 -0700351 lkdtm_CORRUPT_STACK();
Simon Kagstrom0347af42010-03-05 13:42:49 -0800352 break;
Kees Cook00f496c2016-06-26 22:17:25 -0700353 case CT_UNALIGNED_LOAD_STORE_WRITE:
354 lkdtm_UNALIGNED_LOAD_STORE_WRITE();
355 break;
Kees Cookffc514f2016-06-26 21:45:23 -0700356 case CT_OVERWRITE_ALLOCATION:
357 lkdtm_OVERWRITE_ALLOCATION();
Simon Kagstrom0347af42010-03-05 13:42:49 -0800358 break;
Kees Cookffc514f2016-06-26 21:45:23 -0700359 case CT_WRITE_AFTER_FREE:
360 lkdtm_WRITE_AFTER_FREE();
Simon Kagstrom0347af42010-03-05 13:42:49 -0800361 break;
Kees Cookffc514f2016-06-26 21:45:23 -0700362 case CT_READ_AFTER_FREE:
363 lkdtm_READ_AFTER_FREE();
Laura Abbottbc0b8cc2016-02-25 16:36:42 -0800364 break;
Kees Cookffc514f2016-06-26 21:45:23 -0700365 case CT_WRITE_BUDDY_AFTER_FREE:
366 lkdtm_WRITE_BUDDY_AFTER_FREE();
Laura Abbott920d4512016-02-25 16:36:44 -0800367 break;
Kees Cookffc514f2016-06-26 21:45:23 -0700368 case CT_READ_BUDDY_AFTER_FREE:
369 lkdtm_READ_BUDDY_AFTER_FREE();
Simon Kagstrom0347af42010-03-05 13:42:49 -0800370 break;
Namhyung Kim93e2f582010-10-26 14:22:40 -0700371 case CT_SOFTLOCKUP:
Kees Cook00f496c2016-06-26 22:17:25 -0700372 lkdtm_SOFTLOCKUP();
Frederic Weisbeckera48223f2010-05-26 14:44:29 -0700373 break;
Namhyung Kim93e2f582010-10-26 14:22:40 -0700374 case CT_HARDLOCKUP:
Kees Cook00f496c2016-06-26 22:17:25 -0700375 lkdtm_HARDLOCKUP();
Frederic Weisbeckera48223f2010-05-26 14:44:29 -0700376 break;
Kees Cook274a5852013-07-08 10:01:32 -0700377 case CT_SPINLOCKUP:
Kees Cook00f496c2016-06-26 22:17:25 -0700378 lkdtm_SPINLOCKUP();
Kees Cook274a5852013-07-08 10:01:32 -0700379 break;
Namhyung Kim93e2f582010-10-26 14:22:40 -0700380 case CT_HUNG_TASK:
Kees Cook00f496c2016-06-26 22:17:25 -0700381 lkdtm_HUNG_TASK();
Frederic Weisbeckera48223f2010-05-26 14:44:29 -0700382 break;
Kees Cookcc33c5372013-07-08 10:01:33 -0700383 case CT_EXEC_DATA:
Kees Cook0d9eb292016-06-26 15:12:31 -0700384 lkdtm_EXEC_DATA();
Kees Cookcc33c5372013-07-08 10:01:33 -0700385 break;
Kees Cook0d9eb292016-06-26 15:12:31 -0700386 case CT_EXEC_STACK:
387 lkdtm_EXEC_STACK();
Kees Cookcc33c5372013-07-08 10:01:33 -0700388 break;
Kees Cook0d9eb292016-06-26 15:12:31 -0700389 case CT_EXEC_KMALLOC:
390 lkdtm_EXEC_KMALLOC();
Kees Cookcc33c5372013-07-08 10:01:33 -0700391 break;
Kees Cook0d9eb292016-06-26 15:12:31 -0700392 case CT_EXEC_VMALLOC:
393 lkdtm_EXEC_VMALLOC();
Kees Cookcc33c5372013-07-08 10:01:33 -0700394 break;
Kees Cook9a49a522016-02-22 14:09:29 -0800395 case CT_EXEC_RODATA:
Kees Cook0d9eb292016-06-26 15:12:31 -0700396 lkdtm_EXEC_RODATA();
Kees Cook9a49a522016-02-22 14:09:29 -0800397 break;
Kees Cook0d9eb292016-06-26 15:12:31 -0700398 case CT_EXEC_USERSPACE:
399 lkdtm_EXEC_USERSPACE();
Kees Cook9ae113c2013-10-24 09:25:57 -0700400 break;
Kees Cook0d9eb292016-06-26 15:12:31 -0700401 case CT_ACCESS_USERSPACE:
402 lkdtm_ACCESS_USERSPACE();
Kees Cook9ae113c2013-10-24 09:25:57 -0700403 break;
Kees Cook0d9eb292016-06-26 15:12:31 -0700404 case CT_WRITE_RO:
405 lkdtm_WRITE_RO();
Kees Cook7cca0712016-02-17 14:41:16 -0800406 break;
Kees Cook0d9eb292016-06-26 15:12:31 -0700407 case CT_WRITE_RO_AFTER_INIT:
408 lkdtm_WRITE_RO_AFTER_INIT();
Kees Cook9ae113c2013-10-24 09:25:57 -0700409 break;
Kees Cook0d9eb292016-06-26 15:12:31 -0700410 case CT_WRITE_KERN:
411 lkdtm_WRITE_KERN();
Kees Cookdc2b9e92014-02-09 13:48:48 -0800412 break;
Kees Cook00f496c2016-06-26 22:17:25 -0700413 case CT_ATOMIC_UNDERFLOW:
414 lkdtm_ATOMIC_UNDERFLOW();
Kees Cookb5484522016-06-07 14:27:02 -0700415 break;
Kees Cook00f496c2016-06-26 22:17:25 -0700416 case CT_ATOMIC_OVERFLOW:
417 lkdtm_ATOMIC_OVERFLOW();
418 break;
Kees Cookaa981a62016-06-03 12:06:52 -0700419 case CT_USERCOPY_HEAP_SIZE_TO:
Kees Cooka3dff712016-06-26 08:46:23 -0700420 lkdtm_USERCOPY_HEAP_SIZE_TO();
Kees Cookaa981a62016-06-03 12:06:52 -0700421 break;
422 case CT_USERCOPY_HEAP_SIZE_FROM:
Kees Cooka3dff712016-06-26 08:46:23 -0700423 lkdtm_USERCOPY_HEAP_SIZE_FROM();
Kees Cookaa981a62016-06-03 12:06:52 -0700424 break;
425 case CT_USERCOPY_HEAP_FLAG_TO:
Kees Cooka3dff712016-06-26 08:46:23 -0700426 lkdtm_USERCOPY_HEAP_FLAG_TO();
Kees Cookaa981a62016-06-03 12:06:52 -0700427 break;
428 case CT_USERCOPY_HEAP_FLAG_FROM:
Kees Cooka3dff712016-06-26 08:46:23 -0700429 lkdtm_USERCOPY_HEAP_FLAG_FROM();
Kees Cookaa981a62016-06-03 12:06:52 -0700430 break;
431 case CT_USERCOPY_STACK_FRAME_TO:
Kees Cooka3dff712016-06-26 08:46:23 -0700432 lkdtm_USERCOPY_STACK_FRAME_TO();
Kees Cookaa981a62016-06-03 12:06:52 -0700433 break;
434 case CT_USERCOPY_STACK_FRAME_FROM:
Kees Cooka3dff712016-06-26 08:46:23 -0700435 lkdtm_USERCOPY_STACK_FRAME_FROM();
Kees Cookaa981a62016-06-03 12:06:52 -0700436 break;
437 case CT_USERCOPY_STACK_BEYOND:
Kees Cooka3dff712016-06-26 08:46:23 -0700438 lkdtm_USERCOPY_STACK_BEYOND();
Kees Cookaa981a62016-06-03 12:06:52 -0700439 break;
Kees Cook6c352142016-06-23 22:01:26 -0700440 case CT_USERCOPY_KERNEL:
Kees Cooka3dff712016-06-26 08:46:23 -0700441 lkdtm_USERCOPY_KERNEL();
Kees Cook6c352142016-06-23 22:01:26 -0700442 break;
Namhyung Kim93e2f582010-10-26 14:22:40 -0700443 case CT_NONE:
Simon Kagstrom0347af42010-03-05 13:42:49 -0800444 default:
445 break;
446 }
447
448}
449
450static void lkdtm_handler(void)
451{
Josh Huntaa2c96d2011-06-27 16:18:08 -0700452 unsigned long flags;
Cong Wang92618182012-02-03 15:37:15 -0800453 bool do_it = false;
Josh Huntaa2c96d2011-06-27 16:18:08 -0700454
Kees Cook76a10e22016-06-26 22:40:13 -0700455 spin_lock_irqsave(&crash_count_lock, flags);
456 crash_count--;
Kees Cookfeac6e22014-02-09 13:48:46 -0800457 pr_info("Crash point %s of type %s hit, trigger in %d rounds\n",
Kees Cook38f95fe2016-06-29 08:02:32 -0700458 cp_name_to_str(lkdtm_crashpoint),
459 cp_type_to_str(lkdtm_crashtype), crash_count);
Ankita Garg8bb31b92006-10-02 02:17:36 -0700460
Kees Cook76a10e22016-06-26 22:40:13 -0700461 if (crash_count == 0) {
Cong Wang92618182012-02-03 15:37:15 -0800462 do_it = true;
Kees Cook76a10e22016-06-26 22:40:13 -0700463 crash_count = cpoint_count;
Ankita Garg8bb31b92006-10-02 02:17:36 -0700464 }
Kees Cook76a10e22016-06-26 22:40:13 -0700465 spin_unlock_irqrestore(&crash_count_lock, flags);
Cong Wang92618182012-02-03 15:37:15 -0800466
467 if (do_it)
Kees Cook38f95fe2016-06-29 08:02:32 -0700468 lkdtm_do_action(lkdtm_crashtype);
Ankita Garg8bb31b92006-10-02 02:17:36 -0700469}
470
Simon Kagstrom0347af42010-03-05 13:42:49 -0800471static int lkdtm_register_cpoint(enum cname which)
Ankita Garg8bb31b92006-10-02 02:17:36 -0700472{
473 int ret;
474
Kees Cook38f95fe2016-06-29 08:02:32 -0700475 lkdtm_crashpoint = CN_INVALID;
476 if (lkdtm_jprobe.entry != NULL)
477 unregister_jprobe(&lkdtm_jprobe);
Ankita Garg8bb31b92006-10-02 02:17:36 -0700478
Simon Kagstrom0347af42010-03-05 13:42:49 -0800479 switch (which) {
Namhyung Kim93e2f582010-10-26 14:22:40 -0700480 case CN_DIRECT:
Kees Cook38f95fe2016-06-29 08:02:32 -0700481 lkdtm_do_action(lkdtm_crashtype);
Simon Kagstrom0347af42010-03-05 13:42:49 -0800482 return 0;
Namhyung Kim93e2f582010-10-26 14:22:40 -0700483 case CN_INT_HARDWARE_ENTRY:
Kees Cook38f95fe2016-06-29 08:02:32 -0700484 lkdtm_jprobe.kp.symbol_name = "do_IRQ";
485 lkdtm_jprobe.entry = (kprobe_opcode_t*) jp_do_irq;
Ankita Garg8bb31b92006-10-02 02:17:36 -0700486 break;
Namhyung Kim93e2f582010-10-26 14:22:40 -0700487 case CN_INT_HW_IRQ_EN:
Kees Cook38f95fe2016-06-29 08:02:32 -0700488 lkdtm_jprobe.kp.symbol_name = "handle_IRQ_event";
489 lkdtm_jprobe.entry = (kprobe_opcode_t*) jp_handle_irq_event;
Ankita Garg8bb31b92006-10-02 02:17:36 -0700490 break;
Namhyung Kim93e2f582010-10-26 14:22:40 -0700491 case CN_INT_TASKLET_ENTRY:
Kees Cook38f95fe2016-06-29 08:02:32 -0700492 lkdtm_jprobe.kp.symbol_name = "tasklet_action";
493 lkdtm_jprobe.entry = (kprobe_opcode_t*) jp_tasklet_action;
Ankita Garg8bb31b92006-10-02 02:17:36 -0700494 break;
Namhyung Kim93e2f582010-10-26 14:22:40 -0700495 case CN_FS_DEVRW:
Kees Cook38f95fe2016-06-29 08:02:32 -0700496 lkdtm_jprobe.kp.symbol_name = "ll_rw_block";
497 lkdtm_jprobe.entry = (kprobe_opcode_t*) jp_ll_rw_block;
Ankita Garg8bb31b92006-10-02 02:17:36 -0700498 break;
Namhyung Kim93e2f582010-10-26 14:22:40 -0700499 case CN_MEM_SWAPOUT:
Kees Cook38f95fe2016-06-29 08:02:32 -0700500 lkdtm_jprobe.kp.symbol_name = "shrink_inactive_list";
501 lkdtm_jprobe.entry = (kprobe_opcode_t*) jp_shrink_inactive_list;
Ankita Garg8bb31b92006-10-02 02:17:36 -0700502 break;
Namhyung Kim93e2f582010-10-26 14:22:40 -0700503 case CN_TIMERADD:
Kees Cook38f95fe2016-06-29 08:02:32 -0700504 lkdtm_jprobe.kp.symbol_name = "hrtimer_start";
505 lkdtm_jprobe.entry = (kprobe_opcode_t*) jp_hrtimer_start;
Ankita Garg8bb31b92006-10-02 02:17:36 -0700506 break;
Namhyung Kim93e2f582010-10-26 14:22:40 -0700507 case CN_SCSI_DISPATCH_CMD:
Kees Cook38f95fe2016-06-29 08:02:32 -0700508 lkdtm_jprobe.kp.symbol_name = "scsi_dispatch_cmd";
509 lkdtm_jprobe.entry = (kprobe_opcode_t*) jp_scsi_dispatch_cmd;
Ankita Garg8bb31b92006-10-02 02:17:36 -0700510 break;
Namhyung Kim93e2f582010-10-26 14:22:40 -0700511 case CN_IDE_CORE_CP:
Ankita Garg8bb31b92006-10-02 02:17:36 -0700512#ifdef CONFIG_IDE
Kees Cook38f95fe2016-06-29 08:02:32 -0700513 lkdtm_jprobe.kp.symbol_name = "generic_ide_ioctl";
514 lkdtm_jprobe.entry = (kprobe_opcode_t*) jp_generic_ide_ioctl;
Ankita Garg8bb31b92006-10-02 02:17:36 -0700515#else
Kees Cookfeac6e22014-02-09 13:48:46 -0800516 pr_info("Crash point not available\n");
Simon Kagstrom0347af42010-03-05 13:42:49 -0800517 return -EINVAL;
Ankita Garg8bb31b92006-10-02 02:17:36 -0700518#endif
519 break;
520 default:
Kees Cookfeac6e22014-02-09 13:48:46 -0800521 pr_info("Invalid Crash Point\n");
Simon Kagstrom0347af42010-03-05 13:42:49 -0800522 return -EINVAL;
Ankita Garg8bb31b92006-10-02 02:17:36 -0700523 }
524
Kees Cook38f95fe2016-06-29 08:02:32 -0700525 lkdtm_crashpoint = which;
526 if ((ret = register_jprobe(&lkdtm_jprobe)) < 0) {
Kees Cookfeac6e22014-02-09 13:48:46 -0800527 pr_info("Couldn't register jprobe\n");
Kees Cook38f95fe2016-06-29 08:02:32 -0700528 lkdtm_crashpoint = CN_INVALID;
Ankita Garg8bb31b92006-10-02 02:17:36 -0700529 }
530
Simon Kagstrom0347af42010-03-05 13:42:49 -0800531 return ret;
532}
533
534static ssize_t do_register_entry(enum cname which, struct file *f,
535 const char __user *user_buf, size_t count, loff_t *off)
536{
537 char *buf;
538 int err;
539
540 if (count >= PAGE_SIZE)
541 return -EINVAL;
542
543 buf = (char *)__get_free_page(GFP_KERNEL);
544 if (!buf)
545 return -ENOMEM;
546 if (copy_from_user(buf, user_buf, count)) {
547 free_page((unsigned long) buf);
548 return -EFAULT;
549 }
550 /* NULL-terminate and remove enter */
551 buf[count] = '\0';
552 strim(buf);
553
Kees Cook38f95fe2016-06-29 08:02:32 -0700554 lkdtm_crashtype = parse_cp_type(buf, count);
Simon Kagstrom0347af42010-03-05 13:42:49 -0800555 free_page((unsigned long) buf);
556
Kees Cook38f95fe2016-06-29 08:02:32 -0700557 if (lkdtm_crashtype == CT_NONE)
Simon Kagstrom0347af42010-03-05 13:42:49 -0800558 return -EINVAL;
559
560 err = lkdtm_register_cpoint(which);
561 if (err < 0)
562 return err;
563
564 *off += count;
565
566 return count;
567}
568
569/* Generic read callback that just prints out the available crash types */
570static ssize_t lkdtm_debugfs_read(struct file *f, char __user *user_buf,
571 size_t count, loff_t *off)
572{
573 char *buf;
574 int i, n, out;
575
576 buf = (char *)__get_free_page(GFP_KERNEL);
Alan Cox086ff4b2012-07-30 14:43:24 -0700577 if (buf == NULL)
578 return -ENOMEM;
Simon Kagstrom0347af42010-03-05 13:42:49 -0800579
580 n = snprintf(buf, PAGE_SIZE, "Available crash types:\n");
581 for (i = 0; i < ARRAY_SIZE(cp_type); i++)
582 n += snprintf(buf + n, PAGE_SIZE - n, "%s\n", cp_type[i]);
583 buf[n] = '\0';
584
585 out = simple_read_from_buffer(user_buf, count, off,
586 buf, n);
587 free_page((unsigned long) buf);
588
589 return out;
590}
591
592static int lkdtm_debugfs_open(struct inode *inode, struct file *file)
593{
Ankita Garg8bb31b92006-10-02 02:17:36 -0700594 return 0;
595}
596
Simon Kagstrom0347af42010-03-05 13:42:49 -0800597
598static ssize_t int_hardware_entry(struct file *f, const char __user *buf,
599 size_t count, loff_t *off)
600{
Namhyung Kim93e2f582010-10-26 14:22:40 -0700601 return do_register_entry(CN_INT_HARDWARE_ENTRY, f, buf, count, off);
Simon Kagstrom0347af42010-03-05 13:42:49 -0800602}
603
604static ssize_t int_hw_irq_en(struct file *f, const char __user *buf,
605 size_t count, loff_t *off)
606{
Namhyung Kim93e2f582010-10-26 14:22:40 -0700607 return do_register_entry(CN_INT_HW_IRQ_EN, f, buf, count, off);
Simon Kagstrom0347af42010-03-05 13:42:49 -0800608}
609
610static ssize_t int_tasklet_entry(struct file *f, const char __user *buf,
611 size_t count, loff_t *off)
612{
Namhyung Kim93e2f582010-10-26 14:22:40 -0700613 return do_register_entry(CN_INT_TASKLET_ENTRY, f, buf, count, off);
Simon Kagstrom0347af42010-03-05 13:42:49 -0800614}
615
616static ssize_t fs_devrw_entry(struct file *f, const char __user *buf,
617 size_t count, loff_t *off)
618{
Namhyung Kim93e2f582010-10-26 14:22:40 -0700619 return do_register_entry(CN_FS_DEVRW, f, buf, count, off);
Simon Kagstrom0347af42010-03-05 13:42:49 -0800620}
621
622static ssize_t mem_swapout_entry(struct file *f, const char __user *buf,
623 size_t count, loff_t *off)
624{
Namhyung Kim93e2f582010-10-26 14:22:40 -0700625 return do_register_entry(CN_MEM_SWAPOUT, f, buf, count, off);
Simon Kagstrom0347af42010-03-05 13:42:49 -0800626}
627
628static ssize_t timeradd_entry(struct file *f, const char __user *buf,
629 size_t count, loff_t *off)
630{
Namhyung Kim93e2f582010-10-26 14:22:40 -0700631 return do_register_entry(CN_TIMERADD, f, buf, count, off);
Simon Kagstrom0347af42010-03-05 13:42:49 -0800632}
633
634static ssize_t scsi_dispatch_cmd_entry(struct file *f,
635 const char __user *buf, size_t count, loff_t *off)
636{
Namhyung Kim93e2f582010-10-26 14:22:40 -0700637 return do_register_entry(CN_SCSI_DISPATCH_CMD, f, buf, count, off);
Simon Kagstrom0347af42010-03-05 13:42:49 -0800638}
639
640static ssize_t ide_core_cp_entry(struct file *f, const char __user *buf,
641 size_t count, loff_t *off)
642{
Namhyung Kim93e2f582010-10-26 14:22:40 -0700643 return do_register_entry(CN_IDE_CORE_CP, f, buf, count, off);
Simon Kagstrom0347af42010-03-05 13:42:49 -0800644}
645
646/* Special entry to just crash directly. Available without KPROBEs */
647static ssize_t direct_entry(struct file *f, const char __user *user_buf,
648 size_t count, loff_t *off)
649{
650 enum ctype type;
651 char *buf;
652
653 if (count >= PAGE_SIZE)
654 return -EINVAL;
655 if (count < 1)
656 return -EINVAL;
657
658 buf = (char *)__get_free_page(GFP_KERNEL);
659 if (!buf)
660 return -ENOMEM;
661 if (copy_from_user(buf, user_buf, count)) {
662 free_page((unsigned long) buf);
663 return -EFAULT;
664 }
665 /* NULL-terminate and remove enter */
666 buf[count] = '\0';
667 strim(buf);
668
669 type = parse_cp_type(buf, count);
670 free_page((unsigned long) buf);
Namhyung Kim93e2f582010-10-26 14:22:40 -0700671 if (type == CT_NONE)
Simon Kagstrom0347af42010-03-05 13:42:49 -0800672 return -EINVAL;
673
Kees Cookfeac6e22014-02-09 13:48:46 -0800674 pr_info("Performing direct entry %s\n", cp_type_to_str(type));
Simon Kagstrom0347af42010-03-05 13:42:49 -0800675 lkdtm_do_action(type);
676 *off += count;
677
678 return count;
679}
680
681struct crash_entry {
682 const char *name;
683 const struct file_operations fops;
684};
685
686static const struct crash_entry crash_entries[] = {
687 {"DIRECT", {.read = lkdtm_debugfs_read,
Arnd Bergmann05271ec2010-07-06 19:10:26 +0200688 .llseek = generic_file_llseek,
Simon Kagstrom0347af42010-03-05 13:42:49 -0800689 .open = lkdtm_debugfs_open,
690 .write = direct_entry} },
691 {"INT_HARDWARE_ENTRY", {.read = lkdtm_debugfs_read,
Arnd Bergmann05271ec2010-07-06 19:10:26 +0200692 .llseek = generic_file_llseek,
Simon Kagstrom0347af42010-03-05 13:42:49 -0800693 .open = lkdtm_debugfs_open,
694 .write = int_hardware_entry} },
695 {"INT_HW_IRQ_EN", {.read = lkdtm_debugfs_read,
Arnd Bergmann05271ec2010-07-06 19:10:26 +0200696 .llseek = generic_file_llseek,
Simon Kagstrom0347af42010-03-05 13:42:49 -0800697 .open = lkdtm_debugfs_open,
698 .write = int_hw_irq_en} },
699 {"INT_TASKLET_ENTRY", {.read = lkdtm_debugfs_read,
Arnd Bergmann05271ec2010-07-06 19:10:26 +0200700 .llseek = generic_file_llseek,
Simon Kagstrom0347af42010-03-05 13:42:49 -0800701 .open = lkdtm_debugfs_open,
702 .write = int_tasklet_entry} },
703 {"FS_DEVRW", {.read = lkdtm_debugfs_read,
Arnd Bergmann05271ec2010-07-06 19:10:26 +0200704 .llseek = generic_file_llseek,
Simon Kagstrom0347af42010-03-05 13:42:49 -0800705 .open = lkdtm_debugfs_open,
706 .write = fs_devrw_entry} },
707 {"MEM_SWAPOUT", {.read = lkdtm_debugfs_read,
Arnd Bergmann05271ec2010-07-06 19:10:26 +0200708 .llseek = generic_file_llseek,
Simon Kagstrom0347af42010-03-05 13:42:49 -0800709 .open = lkdtm_debugfs_open,
710 .write = mem_swapout_entry} },
711 {"TIMERADD", {.read = lkdtm_debugfs_read,
Arnd Bergmann05271ec2010-07-06 19:10:26 +0200712 .llseek = generic_file_llseek,
Simon Kagstrom0347af42010-03-05 13:42:49 -0800713 .open = lkdtm_debugfs_open,
714 .write = timeradd_entry} },
715 {"SCSI_DISPATCH_CMD", {.read = lkdtm_debugfs_read,
Arnd Bergmann05271ec2010-07-06 19:10:26 +0200716 .llseek = generic_file_llseek,
Simon Kagstrom0347af42010-03-05 13:42:49 -0800717 .open = lkdtm_debugfs_open,
718 .write = scsi_dispatch_cmd_entry} },
719 {"IDE_CORE_CP", {.read = lkdtm_debugfs_read,
Arnd Bergmann05271ec2010-07-06 19:10:26 +0200720 .llseek = generic_file_llseek,
Simon Kagstrom0347af42010-03-05 13:42:49 -0800721 .open = lkdtm_debugfs_open,
722 .write = ide_core_cp_entry} },
723};
724
725static struct dentry *lkdtm_debugfs_root;
726
727static int __init lkdtm_module_init(void)
728{
729 int ret = -EINVAL;
730 int n_debugfs_entries = 1; /* Assume only the direct entry */
731 int i;
732
Kees Cooka3dff712016-06-26 08:46:23 -0700733 /* Handle test-specific initialization. */
Kees Cook00f496c2016-06-26 22:17:25 -0700734 lkdtm_bugs_init(&recur_count);
Kees Cook0d9eb292016-06-26 15:12:31 -0700735 lkdtm_perms_init();
Kees Cooka3dff712016-06-26 08:46:23 -0700736 lkdtm_usercopy_init();
737
Simon Kagstrom0347af42010-03-05 13:42:49 -0800738 /* Register debugfs interface */
739 lkdtm_debugfs_root = debugfs_create_dir("provoke-crash", NULL);
740 if (!lkdtm_debugfs_root) {
Kees Cookfeac6e22014-02-09 13:48:46 -0800741 pr_err("creating root dir failed\n");
Simon Kagstrom0347af42010-03-05 13:42:49 -0800742 return -ENODEV;
743 }
744
745#ifdef CONFIG_KPROBES
746 n_debugfs_entries = ARRAY_SIZE(crash_entries);
747#endif
748
749 for (i = 0; i < n_debugfs_entries; i++) {
750 const struct crash_entry *cur = &crash_entries[i];
751 struct dentry *de;
752
753 de = debugfs_create_file(cur->name, 0644, lkdtm_debugfs_root,
754 NULL, &cur->fops);
755 if (de == NULL) {
Kees Cookfeac6e22014-02-09 13:48:46 -0800756 pr_err("could not create %s\n", cur->name);
Simon Kagstrom0347af42010-03-05 13:42:49 -0800757 goto out_err;
758 }
759 }
760
761 if (lkdtm_parse_commandline() == -EINVAL) {
Kees Cookfeac6e22014-02-09 13:48:46 -0800762 pr_info("Invalid command\n");
Simon Kagstrom0347af42010-03-05 13:42:49 -0800763 goto out_err;
764 }
765
Kees Cook38f95fe2016-06-29 08:02:32 -0700766 if (lkdtm_crashpoint != CN_INVALID && lkdtm_crashtype != CT_NONE) {
767 ret = lkdtm_register_cpoint(lkdtm_crashpoint);
Simon Kagstrom0347af42010-03-05 13:42:49 -0800768 if (ret < 0) {
Kees Cook38f95fe2016-06-29 08:02:32 -0700769 pr_info("Invalid crash point %d\n", lkdtm_crashpoint);
Simon Kagstrom0347af42010-03-05 13:42:49 -0800770 goto out_err;
771 }
Kees Cookfeac6e22014-02-09 13:48:46 -0800772 pr_info("Crash point %s of type %s registered\n",
773 cpoint_name, cpoint_type);
Simon Kagstrom0347af42010-03-05 13:42:49 -0800774 } else {
Kees Cookfeac6e22014-02-09 13:48:46 -0800775 pr_info("No crash points registered, enable through debugfs\n");
Simon Kagstrom0347af42010-03-05 13:42:49 -0800776 }
777
778 return 0;
779
780out_err:
781 debugfs_remove_recursive(lkdtm_debugfs_root);
782 return ret;
783}
784
Adrian Bunk21181162008-02-06 01:36:50 -0800785static void __exit lkdtm_module_exit(void)
Ankita Garg8bb31b92006-10-02 02:17:36 -0700786{
Simon Kagstrom0347af42010-03-05 13:42:49 -0800787 debugfs_remove_recursive(lkdtm_debugfs_root);
788
Kees Cooka3dff712016-06-26 08:46:23 -0700789 /* Handle test-specific clean-up. */
790 lkdtm_usercopy_exit();
Kees Cookaa981a62016-06-03 12:06:52 -0700791
Kees Cook38f95fe2016-06-29 08:02:32 -0700792 unregister_jprobe(&lkdtm_jprobe);
Kees Cookfeac6e22014-02-09 13:48:46 -0800793 pr_info("Crash point unregistered\n");
Ankita Garg8bb31b92006-10-02 02:17:36 -0700794}
795
796module_init(lkdtm_module_init);
797module_exit(lkdtm_module_exit);
798
799MODULE_LICENSE("GPL");
Terry Chiada869202014-07-02 21:02:25 +0800800MODULE_DESCRIPTION("Kprobe module for testing crash dumps");