aboutsummaryrefslogtreecommitdiff
path: root/lib/fault-inject.c
AgeCommit message (Collapse)AuthorFilesLines
2017-07-14fault-inject: simplify access check for fail-nthAkinobu Mita1-2/+5
The fail-nth file is created with 0666 and the access is permitted if and only if the task is current. This file is owned by the currnet user. So we can create it with 0644 and allow the owner to write it. This enables to watch the status of task->fail_nth from another processes. [[email protected]: don't convert unsigned type value as signed int] Link: http://lkml.kernel.org/r/[email protected] [[email protected]: avoid unwanted data race to task->fail_nth] Link: http://lkml.kernel.org/r/[email protected] Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Akinobu Mita <[email protected]> Acked-by: Dmitry Vyukov <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
2017-07-12fault-inject: support systematic fault injectionDmitry Vyukov1-0/+7
Add /proc/self/task/<current-tid>/fail-nth file that allows failing 0-th, 1-st, 2-nd and so on calls systematically. Excerpt from the added documentation: "Write to this file of integer N makes N-th call in the current task fail (N is 0-based). Read from this file returns a single char 'Y' or 'N' that says if the fault setup with a previous write to this file was injected or not, and disables the fault if it wasn't yet injected. Note that this file enables all types of faults (slab, futex, etc). This setting takes precedence over all other generic settings like probability, interval, times, etc. But per-capability settings (e.g. fail_futex/ignore-private) take precedence over it. This feature is intended for systematic testing of faults in a single system call. See an example below" Why add a new setting: 1. Existing settings are global rather than per-task. So parallel testing is not possible. 2. attr->interval is close but it depends on attr->count which is non reset to 0, so interval does not work as expected. 3. Trying to model this with existing settings requires manipulations of all of probability, interval, times, space, task-filter and unexposed count and per-task make-it-fail files. 4. Existing settings are per-failure-type, and the set of failure types is potentially expanding. 5. make-it-fail can't be changed by unprivileged user and aggressive stress testing better be done from an unprivileged user. Similarly, this would require opening the debugfs files to the unprivileged user, as he would need to reopen at least times file (not possible to pre-open before dropping privs). The proposed interface solves all of the above (see the example). We want to integrate this into syzkaller fuzzer. A prototype has found 10 bugs in kernel in first day of usage: https://groups.google.com/forum/#!searchin/syzkaller/%22FAULT_INJECTION%22%7Csort:relevance I've made the current interface work with all types of our sandboxes. For setuid the secret sauce was prctl(PR_SET_DUMPABLE, 1, 0, 0, 0) to make /proc entries non-root owned. So I am fine with the current version of the code. [[email protected]: fix build] Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Dmitry Vyukov <[email protected]> Cc: Akinobu Mita <[email protected]> Cc: Michal Hocko <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
2017-05-08lib/fault-inject.c: use correct check for interruptsDmitry Vyukov1-1/+1
in_interrupt() also returns true when bh is disabled in task context. That's not what fail_task() wants to check. Use the new in_task() predicate that does the right thing. Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Dmitry Vyukov <[email protected]> Reviewed-by: Akinobu Mita <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
2015-10-23fault-inject: fix inverted interval/probability values in printkFlorian Westphal1-1/+1
interval displays the probability and vice versa. Fixes: 6adc4a22f20bb ("fault-inject: add ratelimit option") Acked-by: Akinobu Mita <[email protected]> Cc: <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
2014-12-13fault-inject: add ratelimit optionDmitry Monakhov1-4/+17
Current debug levels are not optimal. Especially if one want to provoke big numbers of faults(broken device simulator) then any verbose level will produce giant numbers of identical logging messages. Let's add ratelimit parameter for that purpose. Signed-off-by: Dmitry Monakhov <[email protected]> Acked-by: Akinobu Mita <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
2013-06-03debugfs: add get/set for atomic typesSeth Jennings1-21/+0
debugfs currently lack the ability to create attributes that set/get atomic_t values. This patch adds support for this through a new debugfs_create_atomic_t() function. Signed-off-by: Seth Jennings <[email protected]> Acked-by: Greg Kroah-Hartman <[email protected]> Acked-by: Mel Gorman <[email protected]> Acked-by: Rik van Riel <[email protected]> Acked-by: Konrad Rzeszutek Wilk <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
2013-04-29lib/: rename random32() to prandom_u32()Akinobu Mita1-1/+1
Use preferable function name which implies using a pseudo-random number generator. Signed-off-by: Akinobu Mita <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
2012-06-20fault-inject: avoid call to random32() if fault injection is disabledAnton Blanchard1-0/+4
After enabling CONFIG_FAILSLAB I noticed random32 in profiles even if slub fault injection wasn't enabled at runtime. should_fail forces a comparison against random32() even if probability is 0: if (attr->probability <= random32() % 100) return false; Add a check up front for probability == 0 and avoid all of the more complicated checks. Signed-off-by: Anton Blanchard <[email protected]> Acked-by: Akinobu Mita <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
2012-03-07lib: reduce the use of module.h wherever possiblePaul Gortmaker1-1/+1
For files only using THIS_MODULE and/or EXPORT_SYMBOL, map them onto including export.h -- or if the file isn't even using those, then just delete the include. Fix up any implicit include dependencies that were being masked by module.h along the way. Signed-off-by: Paul Gortmaker <[email protected]>
2012-01-03switch debugfs to umode_tAl Viro1-4/+4
Signed-off-by: Al Viro <[email protected]>
2011-10-26fault-inject: export setup_fault_attr()Per Forlin1-1/+2
mmc_core module needs to use setup_fault_attr() in order to set fault injection attributes during module load time. Signed-off-by: Per Forlin <[email protected]> Reviewed-by: Akinobu Mita <[email protected]> Signed-off-by: Chris Ball <[email protected]>
2011-10-26fault-inject: export fault injection functionsPer Forlin1-0/+2
Export symbols should_fail() and fault_create_debugfs_attr() in order to let modules utilize the fault injection framework. Signed-off-by: Per Forlin <[email protected]> Acked-by: Akinobu Mita <[email protected]> Signed-off-by: Chris Ball <[email protected]>
2011-08-03fault-injection: add ability to export fault_attr in arbitrary directoryAkinobu Mita1-13/+7
init_fault_attr_dentries() is used to export fault_attr via debugfs. But it can only export it in debugfs root directory. Per Forlin is working on mmc_fail_request which adds support to inject data errors after a completed host transfer in MMC subsystem. The fault_attr for mmc_fail_request should be defined per mmc host and export it in debugfs directory per mmc host like /sys/kernel/debug/mmc0/mmc_fail_request. init_fault_attr_dentries() doesn't help for mmc_fail_request. So this introduces fault_create_debugfs_attr() which is able to create a directory in the arbitrary directory and replace init_fault_attr_dentries(). [[email protected]: extraneous semicolon, per Randy] Signed-off-by: Akinobu Mita <[email protected]> Tested-by: Per Forlin <[email protected]> Cc: Jens Axboe <[email protected]> Cc: Christoph Lameter <[email protected]> Cc: Pekka Enberg <[email protected]> Cc: Matt Mackall <[email protected]> Cc: Randy Dunlap <[email protected]> Cc: Stephen Rothwell <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
2011-07-26fault-injection: use debugfs_remove_recursiveAkinobu Mita1-88/+27
Use debugfs_remove_recursive() to simplify initialization and deinitialization of fault injection debugfs files. Signed-off-by: Akinobu Mita <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
2011-07-26fault-injection: cleanup simple attribute of stacktrace_depthAkinobu Mita1-15/+15
Minor cosmetic changes for simple attribute of stacktrace_depth: - use min_t() - reduce #ifdef by moving a function - do not use partly capitalized function name Signed-off-by: Akinobu Mita <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
2011-07-26fault-injection: do not include unneeded headerAkinobu Mita1-1/+0
No need to include linux/kallsyms.h. Signed-off-by: Akinobu Mita <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
2009-10-11headers: remove sched.h from interrupt.hAlexey Dobriyan1-0/+1
After m68k's task_thread_info() doesn't refer to current, it's possible to remove sched.h from interrupt.h and not break m68k! Many thanks to Heiko Carstens for allowing this. Signed-off-by: Alexey Dobriyan <[email protected]>
2009-01-06Remove remaining unwinder codeAlexey Dobriyan1-1/+0
Signed-off-by: Alexey Dobriyan <[email protected]> Cc: Gabor Gombas <[email protected]> Cc: Jan Beulich <[email protected]> Cc: Andi Kleen <[email protected]> Cc: Ingo Molnar <[email protected]>, Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
2008-02-08libfs: allow error return from simple attributesChristoph Hellwig1-7/+12
Sometimes simple attributes might need to return an error, e.g. for acquiring a mutex interruptibly. In fact we have that situation in spufs already which is the original user of the simple attributes. This patch merged the temporarily forked attributes in spufs back into the main ones and allows to return errors. [[email protected]: build fix] Signed-off-by: Christoph Hellwig <[email protected]> Cc: <[email protected]> Cc: Arnd Bergmann <[email protected]> Cc: Greg KH <[email protected]> Cc: Al Viro <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
2007-07-24fault_inject: silence a warningStephen Rothwell1-0/+4
lib/fault-inject.c:168: warning: 'debugfs_create_ul_MAX_STACK_TRACE_DEPTH' defined but not used Signed-off-by: Stephen Rothwell <[email protected]> Cc: Akinobu Mita <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
2007-05-08simplify the stacktrace codeChristoph Hellwig1-2/+1
Simplify the stacktrace code: - remove the unused task argument to save_stack_trace, it's always current - remove the all_contexts flag, it's alwasy 0 Signed-off-by: Christoph Hellwig <[email protected]> Cc: Paul Mundt <[email protected]> Cc: Ralf Baechle <[email protected]> Cc: Martin Schwidefsky <[email protected]> Cc: "David S. Miller" <[email protected]> Cc: Andi Kleen <[email protected]> Cc: Akinobu Mita <[email protected]> Acked-by: Ingo Molnar <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
2007-02-20[PATCH] fault injection: split up stacktrace filter Kconfig optionAkinobu Mita1-20/+21
There is no prompt for CONFIG_STACKTRACE, so FAULT_INJECTION cannot be selected without LOCKDEP enabled. (found by Paolo 'Blaisorblade' Giarrusso) In order to fix such broken Kconfig dependency, this patch splits up the stacktrace filter support for fault injection by new Kconfig option, which enables to use fault injection on the architecture which doesn't have general stacktrace support. Cc: "Paolo 'Blaisorblade' Giarrusso" <[email protected]> Signed-off-by: Akinobu Mita <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
2006-12-15Remove stack unwinder for nowLinus Torvalds1-31/+1
It has caused more problems than it ever really solved, and is apparently not getting cleaned up and fixed. We can put it back when it's stable and isn't likely to make warning or bug events worse. In the meantime, enable frame pointers for more readable stack traces. Signed-off-by: Linus Torvalds <[email protected]>
2006-12-08[PATCH] fault-injection: optimize and simplify should_fail()Don Mullis1-7/+4
Trivial optimization and simplification of should_fail(). Do cheaper disqualification tests first (performance gain not quantified). Simplify logic; eliminate goto. Signed-off-by: Don Mullis <[email protected]> Cc: Akinobu Mita <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
2006-12-08[PATCH] fault-injection: Clamp debugfs stacktrace-depth to MAX_STACK_TRACE_DEPTHDon Mullis1-4/+23
Clamp /debug/fail*/stacktrace-depth to MAX_STACK_TRACE_DEPTH. Ensures that a read of /debug/fail*/stacktrace-depth always returns a truthful answer. Signed-off-by: Don Mullis <[email protected]> Cc: Akinobu Mita <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
2006-12-08[PATCH] fault-injection: Use bool-true-false throughoutDon Mullis1-21/+19
Use bool-true-false throughout. Signed-off-by: Don Mullis <[email protected]> Cc: Akinobu Mita <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
2006-12-08[PATCH] fault injection: stacktrace filteringAkinobu Mita1-1/+125
This patch provides stacktrace filtering feature. The stacktrace filter allows failing only for the caller you are interested in. For example someone may want to inject kmalloc() failures into only e100 module. they want to inject not only direct kmalloc() call, but also indirect allocation, too. - e100_poll --> netif_receive_skb --> packet_rcv_spkt --> skb_clone --> kmem_cache_alloc This patch enables to detect function calls like this by stacktrace and inject failures. The script Documentaion/fault-injection/failmodule.sh helps it. The range of text section of loaded e100 is expected to be [/sys/module/e100/sections/.text, /sys/module/e100/sections/.exit.text) So failmodule.sh stores these values into /debug/failslab/address-start and /debug/failslab/address-end. The maximum stacktrace depth is specified by /debug/failslab/stacktrace-depth. Please see the example that demonstrates how to inject slab allocation failures only for a specific module in Documentation/fault-injection/fault-injection.txt [[email protected]: reject failure if any caller lies within specified range] Signed-off-by: Akinobu Mita <[email protected]> Signed-off-by: Don Mullis <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
2006-12-08[PATCH] fault injection: process filtering for fault-injection capabilitiesAkinobu Mita1-1/+16
This patch provides process filtering feature. The process filter allows failing only permitted processes by /proc/<pid>/make-it-fail Please see the example that demostrates how to inject slab allocation failures into module init/cleanup code in Documentation/fault-injection/fault-injection.txt Signed-off-by: Akinobu Mita <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
2006-12-08[PATCH] fault-injection capabilities infrastructureAkinobu Mita1-0/+183
This patch provides base functions implement to fault-injection capabilities. - The function should_fail() is taken from failmalloc-1.0 (http://www.nongnu.org/failmalloc/) [[email protected]: cleanups, comments, add __init] Cc: <[email protected]> Signed-off-by: Akinobu Mita <[email protected]> Signed-off-by: Don Mullis <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>