sphinx.addnodesdocument)}( rawsourcechildren]( translations LanguagesNode)}(hhh](h pending_xref)}(hhh]docutils.nodesTextChinese (Simplified)}parenthsba attributes}(ids]classes]names]dupnames]backrefs] refdomainstdreftypedoc reftarget3/translations/zh_CN/fault-injection/fault-injectionmodnameN classnameN refexplicitutagnamehhh ubh)}(hhh]hChinese (Traditional)}hh2sbah}(h]h ]h"]h$]h&] refdomainh)reftypeh+ reftarget3/translations/zh_TW/fault-injection/fault-injectionmodnameN classnameN refexplicituh1hhh ubh)}(hhh]hItalian}hhFsbah}(h]h ]h"]h$]h&] refdomainh)reftypeh+ reftarget3/translations/it_IT/fault-injection/fault-injectionmodnameN classnameN refexplicituh1hhh ubh)}(hhh]hJapanese}hhZsbah}(h]h ]h"]h$]h&] refdomainh)reftypeh+ reftarget3/translations/ja_JP/fault-injection/fault-injectionmodnameN classnameN refexplicituh1hhh ubh)}(hhh]hKorean}hhnsbah}(h]h ]h"]h$]h&] refdomainh)reftypeh+ reftarget3/translations/ko_KR/fault-injection/fault-injectionmodnameN classnameN refexplicituh1hhh ubh)}(hhh]hSpanish}hhsbah}(h]h ]h"]h$]h&] refdomainh)reftypeh+ reftarget3/translations/sp_SP/fault-injection/fault-injectionmodnameN classnameN refexplicituh1hhh ubeh}(h]h ]h"]h$]h&]current_languageEnglishuh1h hh _documenthsourceNlineNubhsection)}(hhh](htitle)}(h+Fault injection capabilities infrastructureh]h+Fault injection capabilities infrastructure}(hhhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhhhM/var/lib/git/docbuild/linux/Documentation/fault-injection/fault-injection.rsthKubh paragraph)}(hMSee also drivers/md/md-faulty.c and "every_nth" module option for scsi_debug.h]hQSee also drivers/md/md-faulty.c and “every_nth” module option for scsi_debug.}(hhhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhhhhubh)}(hhh](h)}(h&Available fault injection capabilitiesh]h&Available fault injection capabilities}(hhhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhhhhhK ubh bullet_list)}(hhh](h list_item)}(hQfailslab injects slab allocation failures. (kmalloc(), kmem_cache_alloc(), ...) h](h)}(hfailslabh]hfailslab}(hhhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK hhubh)}(hFinjects slab allocation failures. (kmalloc(), kmem_cache_alloc(), ...)h]hFinjects slab allocation failures. (kmalloc(), kmem_cache_alloc(), ...)}(hhhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK hhubeh}(h]h ]h"]h$]h&]uh1hhhhhhhhNubh)}(hZfail_page_alloc injects page allocation failures. (alloc_pages(), get_free_pages(), ...) h](h)}(hfail_page_alloch]hfail_page_alloc}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubh)}(hHinjects page allocation failures. (alloc_pages(), get_free_pages(), ...)h]hHinjects page allocation failures. (alloc_pages(), get_free_pages(), ...)}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubeh}(h]h ]h"]h$]h&]uh1hhhhhhhhNubh)}(hefail_usercopy injects failures in user memory access functions. (copy_from_user(), get_user(), ...) h](h)}(h fail_usercopyh]h fail_usercopy}(hj/hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhj+ubh)}(hUinjects failures in user memory access functions. (copy_from_user(), get_user(), ...)h]hUinjects failures in user memory access functions. (copy_from_user(), get_user(), ...)}(hj=hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhj+ubeh}(h]h ]h"]h$]h&]uh1hhhhhhhhNubh)}(h;fail_futex injects futex deadlock and uaddr fault errors. h](h)}(h fail_futexh]h fail_futex}(hjUhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjQubh)}(h.injects futex deadlock and uaddr fault errors.h]h.injects futex deadlock and uaddr fault errors.}(hjchhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjQubeh}(h]h ]h"]h$]h&]uh1hhhhhhhhNubh)}(h/make-it-fail or /sys/block///make-it-fail. (submit_bio_noacct()) h](h)}(hfail_make_requesth]hfail_make_request}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubh)}(hinjects disk IO errors on devices permitted by setting /sys/block//make-it-fail or /sys/block///make-it-fail. (submit_bio_noacct())h]hinjects disk IO errors on devices permitted by setting /sys/block//make-it-fail or /sys/block///make-it-fail. (submit_bio_noacct())}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK!hjubeh}(h]h ]h"]h$]h&]uh1hhhhhhhhNubh)}(hfail_mmc_request injects MMC data errors on devices permitted by setting debugfs entries under /sys/kernel/debug/mmc0/fail_mmc_request h](h)}(hfail_mmc_requesth]hfail_mmc_request}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK%hjubh)}(huinjects MMC data errors on devices permitted by setting debugfs entries under /sys/kernel/debug/mmc0/fail_mmc_requesth]huinjects MMC data errors on devices permitted by setting debugfs entries under /sys/kernel/debug/mmc0/fail_mmc_request}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK'hjubeh}(h]h ]h"]h$]h&]uh1hhhhhhhhNubh)}(hfail_function injects error return on specific functions, which are marked by ALLOW_ERROR_INJECTION() macro, by setting debugfs entries under /sys/kernel/debug/fail_function. No boot option supported. h](h)}(h fail_functionh]h fail_function}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK*hjubh)}(hinjects error return on specific functions, which are marked by ALLOW_ERROR_INJECTION() macro, by setting debugfs entries under /sys/kernel/debug/fail_function. No boot option supported.h]hinjects error return on specific functions, which are marked by ALLOW_ERROR_INJECTION() macro, by setting debugfs entries under /sys/kernel/debug/fail_function. No boot option supported.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK,hjubeh}(h]h ]h"]h$]h&]uh1hhhhhhhhNubh)}(hXfail_skb_realloc inject skb (socket buffer) reallocation events into the network path. The primary goal is to identify and prevent issues related to pointer mismanagement in the network subsystem. By forcing skb reallocation at strategic points, this feature creates scenarios where existing pointers to skb headers become invalid. When the fault is injected and the reallocation is triggered, cached pointers to skb headers and data no longer reference valid memory locations. This deliberate invalidation helps expose code paths where proper pointer updating is neglected after a reallocation event. By creating these controlled fault scenarios, the system can catch instances where stale pointers are used, potentially leading to memory corruption or system instability. To select the interface to act on, write the network name to /sys/kernel/debug/fail_skb_realloc/devname. If this field is left empty (which is the default value), skb reallocation will be forced on all network interfaces. The effectiveness of this fault detection is enhanced when KASAN is enabled, as it helps identify invalid memory references and use-after-free (UAF) issues. h](h)}(hfail_skb_realloch]hfail_skb_realloc}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK0hjubh)}(hX;inject skb (socket buffer) reallocation events into the network path. The primary goal is to identify and prevent issues related to pointer mismanagement in the network subsystem. By forcing skb reallocation at strategic points, this feature creates scenarios where existing pointers to skb headers become invalid.h]hX;inject skb (socket buffer) reallocation events into the network path. The primary goal is to identify and prevent issues related to pointer mismanagement in the network subsystem. By forcing skb reallocation at strategic points, this feature creates scenarios where existing pointers to skb headers become invalid.}(hj!hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK2hjubh)}(hX When the fault is injected and the reallocation is triggered, cached pointers to skb headers and data no longer reference valid memory locations. This deliberate invalidation helps expose code paths where proper pointer updating is neglected after a reallocation event.h]hX When the fault is injected and the reallocation is triggered, cached pointers to skb headers and data no longer reference valid memory locations. This deliberate invalidation helps expose code paths where proper pointer updating is neglected after a reallocation event.}(hj/hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK8hjubh)}(hBy creating these controlled fault scenarios, the system can catch instances where stale pointers are used, potentially leading to memory corruption or system instability.h]hBy creating these controlled fault scenarios, the system can catch instances where stale pointers are used, potentially leading to memory corruption or system instability.}(hj=hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK=hjubh)}(hTo select the interface to act on, write the network name to /sys/kernel/debug/fail_skb_realloc/devname. If this field is left empty (which is the default value), skb reallocation will be forced on all network interfaces.h]hTo select the interface to act on, write the network name to /sys/kernel/debug/fail_skb_realloc/devname. If this field is left empty (which is the default value), skb reallocation will be forced on all network interfaces.}(hjKhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKAhjubh)}(hThe effectiveness of this fault detection is enhanced when KASAN is enabled, as it helps identify invalid memory references and use-after-free (UAF) issues.h]hThe effectiveness of this fault detection is enhanced when KASAN is enabled, as it helps identify invalid memory references and use-after-free (UAF) issues.}(hjYhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKFhjubeh}(h]h ]h"]h$]h&]uh1hhhhhhhhNubh)}(hXNVMe fault injection inject NVMe status code and retry flag on devices permitted by setting debugfs entries under /sys/kernel/debug/nvme*/fault_inject. The default status code is NVME_SC_INVALID_OPCODE with no retry. The status code and retry flag can be set via the debugfs. h](h)}(hNVMe fault injectionh]hNVMe fault injection}(hjqhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKJhjmubh)}(hinject NVMe status code and retry flag on devices permitted by setting debugfs entries under /sys/kernel/debug/nvme*/fault_inject. The default status code is NVME_SC_INVALID_OPCODE with no retry. The status code and retry flag can be set via the debugfs.h]hinject NVMe status code and retry flag on devices permitted by setting debugfs entries under /sys/kernel/debug/nvme*/fault_inject. The default status code is NVME_SC_INVALID_OPCODE with no retry. The status code and retry flag can be set via the debugfs.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKLhjmubeh}(h]h ]h"]h$]h&]uh1hhhhhhhhNubh)}(hXcNull test block driver fault injection inject IO timeouts by setting config items under /sys/kernel/config/nullb//timeout_inject, inject requeue requests by setting config items under /sys/kernel/config/nullb//requeue_inject, and inject init_hctx() errors by setting config items under /sys/kernel/config/nullb//init_hctx_fault_inject. h](h)}(h&Null test block driver fault injectionh]h&Null test block driver fault injection}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKQhjubh)}(hX:inject IO timeouts by setting config items under /sys/kernel/config/nullb//timeout_inject, inject requeue requests by setting config items under /sys/kernel/config/nullb//requeue_inject, and inject init_hctx() errors by setting config items under /sys/kernel/config/nullb//init_hctx_fault_inject.h]hX:inject IO timeouts by setting config items under /sys/kernel/config/nullb//timeout_inject, inject requeue requests by setting config items under /sys/kernel/config/nullb//requeue_inject, and inject init_hctx() errors by setting config items under /sys/kernel/config/nullb//init_hctx_fault_inject.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKShjubeh}(h]h ]h"]h$]h&]uh1hhhhhhhhNubeh}(h]h ]h"]h$]h&]bullet-uh1hhhhK hhhhubeh}(h]&available-fault-injection-capabilitiesah ]h"]&available fault injection capabilitiesah$]h&]uh1hhhhhhhhK ubh)}(hhh](h)}(h/Configure fault-injection capabilities behaviorh]h/Configure fault-injection capabilities behavior}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjhhhhhK[ubh)}(hhh](h)}(hdebugfs entriesh]hdebugfs entries}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjhhhhhK^ubh)}(h{fault-inject-debugfs kernel module provides some debugfs entries for runtime configuration of fault-injection capabilities.h]h{fault-inject-debugfs kernel module provides some debugfs entries for runtime configuration of fault-injection capabilities.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK`hjhhubh)}(hhh](h)}(hX:/sys/kernel/debug/fail*/probability: likelihood of failure injection, in percent. Format: Note that one-failure-per-hundred is a very high error rate for some testcases. Consider setting probability=100 and configure /sys/kernel/debug/fail*/interval for such testcases. h](h)}(h$/sys/kernel/debug/fail*/probability:h]h$/sys/kernel/debug/fail*/probability:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKchjubh block_quote)}(hlikelihood of failure injection, in percent. Format: Note that one-failure-per-hundred is a very high error rate for some testcases. Consider setting probability=100 and configure /sys/kernel/debug/fail*/interval for such testcases. h](h)}(h,likelihood of failure injection, in percent.h]h,likelihood of failure injection, in percent.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKehjubh)}(hFormat: h]hFormat: }(hj"hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKghjubh)}(hNote that one-failure-per-hundred is a very high error rate for some testcases. Consider setting probability=100 and configure /sys/kernel/debug/fail*/interval for such testcases.h]hNote that one-failure-per-hundred is a very high error rate for some testcases. Consider setting probability=100 and configure /sys/kernel/debug/fail*/interval for such testcases.}(hj0hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKihjubeh}(h]h ]h"]h$]h&]uh1jhhhKehjubeh}(h]h ]h"]h$]h&]uh1hhjhhhhhNubh)}(hX/sys/kernel/debug/fail*/interval: specifies the interval between failures, for calls to should_fail() that pass all the other tests. Note that if you enable this, by setting interval>1, you will probably want to set probability=100. h](h)}(h!/sys/kernel/debug/fail*/interval:h]h!/sys/kernel/debug/fail*/interval:}(hjNhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKmhjJubj)}(hspecifies the interval between failures, for calls to should_fail() that pass all the other tests. Note that if you enable this, by setting interval>1, you will probably want to set probability=100. h](h)}(hbspecifies the interval between failures, for calls to should_fail() that pass all the other tests.h]hbspecifies the interval between failures, for calls to should_fail() that pass all the other tests.}(hj`hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKohj\ubh)}(hcNote that if you enable this, by setting interval>1, you will probably want to set probability=100.h]hcNote that if you enable this, by setting interval>1, you will probably want to set probability=100.}(hjnhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKrhj\ubeh}(h]h ]h"]h$]h&]uh1jhhhKohjJubeh}(h]h ]h"]h$]h&]uh1hhjhhhhhNubh)}(h/sys/kernel/debug/fail*/times: specifies how many times failures may happen at most. A value of -1 means "no limit". h](h)}(h/sys/kernel/debug/fail*/times:h]h/sys/kernel/debug/fail*/times:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKuhjubj)}(hVspecifies how many times failures may happen at most. A value of -1 means "no limit". h]h)}(hUspecifies how many times failures may happen at most. A value of -1 means "no limit".h]hYspecifies how many times failures may happen at most. A value of -1 means “no limit”.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKwhjubah}(h]h ]h"]h$]h&]uh1jhhhKwhjubeh}(h]h ]h"]h$]h&]uh1hhjhhhhhNubh)}(h/sys/kernel/debug/fail*/space: specifies an initial resource "budget", decremented by "size" on each call to should_fail(,size). Failure injection is suppressed until "space" reaches zero. h](h)}(h/sys/kernel/debug/fail*/space:h]h/sys/kernel/debug/fail*/space:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKzhjubj)}(hspecifies an initial resource "budget", decremented by "size" on each call to should_fail(,size). Failure injection is suppressed until "space" reaches zero. h]h)}(hspecifies an initial resource "budget", decremented by "size" on each call to should_fail(,size). Failure injection is suppressed until "space" reaches zero.h]hspecifies an initial resource “budget”, decremented by “size” on each call to should_fail(,size). Failure injection is suppressed until “space” reaches zero.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK|hjubah}(h]h ]h"]h$]h&]uh1jhhhK|hjubeh}(h]h ]h"]h$]h&]uh1hhjhhhhhNubh)}(hX@/sys/kernel/debug/fail*/verbose Format: { 0 | 1 | 2 } specifies the verbosity of the messages when failure is injected. '0' means no messages; '1' will print only a single log line per failure; '2' will print a call trace too -- useful to debug the problems revealed by fault injection. h](h)}(h/sys/kernel/debug/fail*/verboseh]h/sys/kernel/debug/fail*/verbose}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubj)}(hXFormat: { 0 | 1 | 2 } specifies the verbosity of the messages when failure is injected. '0' means no messages; '1' will print only a single log line per failure; '2' will print a call trace too -- useful to debug the problems revealed by fault injection. h](h)}(hFormat: { 0 | 1 | 2 }h]hFormat: { 0 | 1 | 2 }}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubh)}(hspecifies the verbosity of the messages when failure is injected. '0' means no messages; '1' will print only a single log line per failure; '2' will print a call trace too -- useful to debug the problems revealed by fault injection.h]hspecifies the verbosity of the messages when failure is injected. ‘0’ means no messages; ‘1’ will print only a single log line per failure; ‘2’ will print a call trace too -- useful to debug the problems revealed by fault injection.}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubeh}(h]h ]h"]h$]h&]uh1jhhhKhjubeh}(h]h ]h"]h$]h&]uh1hhjhhhhhNubh)}(h/sys/kernel/debug/fail*/task-filter: Format: { 'Y' | 'N' } A value of 'N' disables filtering by process (default). Any positive value limits failures to only processes indicated by /proc//make-it-fail==1. h](h)}(h$/sys/kernel/debug/fail*/task-filter:h]h$/sys/kernel/debug/fail*/task-filter:}(hj*hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhj&ubj)}(hFormat: { 'Y' | 'N' } A value of 'N' disables filtering by process (default). Any positive value limits failures to only processes indicated by /proc//make-it-fail==1. h](h)}(hFormat: { 'Y' | 'N' }h]hFormat: { ‘Y’ | ‘N’ }}(hj<hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhj8ubh)}(hA value of 'N' disables filtering by process (default). Any positive value limits failures to only processes indicated by /proc//make-it-fail==1.h]hA value of ‘N’ disables filtering by process (default). Any positive value limits failures to only processes indicated by /proc//make-it-fail==1.}(hjJhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhj8ubeh}(h]h ]h"]h$]h&]uh1jhhhKhj&ubeh}(h]h ]h"]h$]h&]uh1hhjhhhhhNubh)}(hX/sys/kernel/debug/fail*/require-start, /sys/kernel/debug/fail*/require-end, /sys/kernel/debug/fail*/reject-start, /sys/kernel/debug/fail*/reject-end: specifies the range of virtual addresses tested during stacktrace walking. Failure is injected only if some caller in the walked stacktrace lies within the required range, and none lies within the rejected range. Default required range is [0,ULONG_MAX) (whole of virtual address space). Default rejected range is [0,0). h](h)}(h/sys/kernel/debug/fail*/require-start, /sys/kernel/debug/fail*/require-end, /sys/kernel/debug/fail*/reject-start, /sys/kernel/debug/fail*/reject-end:h]h/sys/kernel/debug/fail*/require-start, /sys/kernel/debug/fail*/require-end, /sys/kernel/debug/fail*/reject-start, /sys/kernel/debug/fail*/reject-end:}(hjhhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjdubj)}(hXAspecifies the range of virtual addresses tested during stacktrace walking. Failure is injected only if some caller in the walked stacktrace lies within the required range, and none lies within the rejected range. Default required range is [0,ULONG_MAX) (whole of virtual address space). Default rejected range is [0,0). h]h)}(hX@specifies the range of virtual addresses tested during stacktrace walking. Failure is injected only if some caller in the walked stacktrace lies within the required range, and none lies within the rejected range. Default required range is [0,ULONG_MAX) (whole of virtual address space). Default rejected range is [0,0).h]hX@specifies the range of virtual addresses tested during stacktrace walking. Failure is injected only if some caller in the walked stacktrace lies within the required range, and none lies within the rejected range. Default required range is [0,ULONG_MAX) (whole of virtual address space). Default rejected range is [0,0).}(hjzhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjvubah}(h]h ]h"]h$]h&]uh1jhhhKhjdubeh}(h]h ]h"]h$]h&]uh1hhjhhhhhNubh)}(h/sys/kernel/debug/fail*/stacktrace-depth: specifies the maximum stacktrace depth walked during search for a caller within [require-start,require-end) OR [reject-start,reject-end). h](h)}(h)/sys/kernel/debug/fail*/stacktrace-depth:h]h)/sys/kernel/debug/fail*/stacktrace-depth:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubj)}(hspecifies the maximum stacktrace depth walked during search for a caller within [require-start,require-end) OR [reject-start,reject-end). h]h)}(hspecifies the maximum stacktrace depth walked during search for a caller within [require-start,require-end) OR [reject-start,reject-end).h]hspecifies the maximum stacktrace depth walked during search for a caller within [require-start,require-end) OR [reject-start,reject-end).}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubah}(h]h ]h"]h$]h&]uh1jhhhKhjubeh}(h]h ]h"]h$]h&]uh1hhjhhhhhNubh)}(h/sys/kernel/debug/fail_page_alloc/ignore-gfp-highmem: Format: { 'Y' | 'N' } default is 'Y', setting it to 'N' will also inject failures into highmem/user allocations (__GFP_HIGHMEM allocations). h](h)}(h5/sys/kernel/debug/fail_page_alloc/ignore-gfp-highmem:h]h5/sys/kernel/debug/fail_page_alloc/ignore-gfp-highmem:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubj)}(hFormat: { 'Y' | 'N' } default is 'Y', setting it to 'N' will also inject failures into highmem/user allocations (__GFP_HIGHMEM allocations). h](h)}(hFormat: { 'Y' | 'N' }h]hFormat: { ‘Y’ | ‘N’ }}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubh)}(hvdefault is 'Y', setting it to 'N' will also inject failures into highmem/user allocations (__GFP_HIGHMEM allocations).h]h~default is ‘Y’, setting it to ‘N’ will also inject failures into highmem/user allocations (__GFP_HIGHMEM allocations).}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubeh}(h]h ]h"]h$]h&]uh1jhhhKhjubeh}(h]h ]h"]h$]h&]uh1hhjhhhhhNubh)}(hX /sys/kernel/debug/failslab/cache-filter Format: { 'Y' | 'N' } default is 'N', setting it to 'Y' will only inject failures when objects are requests from certain caches. Select the cache by writing '1' to /sys/kernel/slab//failslab: h]hdefinition_list)}(hhh]hdefinition_list_item)}(h/sys/kernel/debug/failslab/cache-filter Format: { 'Y' | 'N' } default is 'N', setting it to 'Y' will only inject failures when objects are requests from certain caches. Select the cache by writing '1' to /sys/kernel/slab//failslab: h](hterm)}(h'/sys/kernel/debug/failslab/cache-filterh]h'/sys/kernel/debug/failslab/cache-filter}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhhhKhj ubh definition)}(hhh](h)}(hFormat: { 'Y' | 'N' }h]hFormat: { ‘Y’ | ‘N’ }}(hj&hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhj#ubh)}(hjdefault is 'N', setting it to 'Y' will only inject failures when objects are requests from certain caches.h]hrdefault is ‘N’, setting it to ‘Y’ will only inject failures when objects are requests from certain caches.}(hj4hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhj#ubh)}(hESelect the cache by writing '1' to /sys/kernel/slab//failslab:h]hISelect the cache by writing ‘1’ to /sys/kernel/slab//failslab:}(hjBhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhj#ubeh}(h]h ]h"]h$]h&]uh1j!hj ubeh}(h]h ]h"]h$]h&]uh1j hhhKhjubah}(h]h ]h"]h$]h&]uh1jhjubah}(h]h ]h"]h$]h&]uh1hhjhhhNhNubh)}(h+/sys/kernel/debug/failslab/ignore-gfp-wait:h]h)}(hjjh]h+/sys/kernel/debug/failslab/ignore-gfp-wait:}(hjlhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjhubah}(h]h ]h"]h$]h&]uh1hhjhhhhhNubh)}(h/sys/kernel/debug/fail_page_alloc/ignore-gfp-wait: Format: { 'Y' | 'N' } default is 'Y', setting it to 'N' will also inject failures into allocations that can sleep (__GFP_DIRECT_RECLAIM allocations). h](h)}(h2/sys/kernel/debug/fail_page_alloc/ignore-gfp-wait:h]h2/sys/kernel/debug/fail_page_alloc/ignore-gfp-wait:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubj)}(hFormat: { 'Y' | 'N' } default is 'Y', setting it to 'N' will also inject failures into allocations that can sleep (__GFP_DIRECT_RECLAIM allocations). h](h)}(hFormat: { 'Y' | 'N' }h]hFormat: { ‘Y’ | ‘N’ }}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubh)}(hdefault is 'Y', setting it to 'N' will also inject failures into allocations that can sleep (__GFP_DIRECT_RECLAIM allocations).h]hdefault is ‘Y’, setting it to ‘N’ will also inject failures into allocations that can sleep (__GFP_DIRECT_RECLAIM allocations).}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubeh}(h]h ]h"]h$]h&]uh1jhhhKhjubeh}(h]h ]h"]h$]h&]uh1hhjhhhhhNubh)}(h/sys/kernel/debug/fail_page_alloc/min-order: specifies the minimum page allocation order to be injected failures. h](h)}(h,/sys/kernel/debug/fail_page_alloc/min-order:h]h,/sys/kernel/debug/fail_page_alloc/min-order:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubj)}(hEspecifies the minimum page allocation order to be injected failures. h]h)}(hDspecifies the minimum page allocation order to be injected failures.h]hDspecifies the minimum page allocation order to be injected failures.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubah}(h]h ]h"]h$]h&]uh1jhhhKhjubeh}(h]h ]h"]h$]h&]uh1hhjhhhhhNubh)}(h/sys/kernel/debug/fail_futex/ignore-private: Format: { 'Y' | 'N' } default is 'N', setting it to 'Y' will disable failure injections when dealing with private (address space) futexes. h](h)}(h,/sys/kernel/debug/fail_futex/ignore-private:h]h,/sys/kernel/debug/fail_futex/ignore-private:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubj)}(hFormat: { 'Y' | 'N' } default is 'N', setting it to 'Y' will disable failure injections when dealing with private (address space) futexes. h](h)}(hFormat: { 'Y' | 'N' }h]hFormat: { ‘Y’ | ‘N’ }}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubh)}(htdefault is 'N', setting it to 'Y' will disable failure injections when dealing with private (address space) futexes.h]h|default is ‘N’, setting it to ‘Y’ will disable failure injections when dealing with private (address space) futexes.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubeh}(h]h ]h"]h$]h&]uh1jhhhKhjubeh}(h]h ]h"]h$]h&]uh1hhjhhhhhNubh)}(h/sys/kernel/debug/fail_sunrpc/ignore-client-disconnect: Format: { 'Y' | 'N' } default is 'N', setting it to 'Y' will disable disconnect injection on the RPC client. h](h)}(h7/sys/kernel/debug/fail_sunrpc/ignore-client-disconnect:h]h7/sys/kernel/debug/fail_sunrpc/ignore-client-disconnect:}(hj/hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhj+ubj)}(hnFormat: { 'Y' | 'N' } default is 'N', setting it to 'Y' will disable disconnect injection on the RPC client. h](h)}(hFormat: { 'Y' | 'N' }h]hFormat: { ‘Y’ | ‘N’ }}(hjAhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhj=ubh)}(hVdefault is 'N', setting it to 'Y' will disable disconnect injection on the RPC client.h]h^default is ‘N’, setting it to ‘Y’ will disable disconnect injection on the RPC client.}(hjOhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhj=ubeh}(h]h ]h"]h$]h&]uh1jhhhKhj+ubeh}(h]h ]h"]h$]h&]uh1hhjhhhhhNubh)}(h/sys/kernel/debug/fail_sunrpc/ignore-server-disconnect: Format: { 'Y' | 'N' } default is 'N', setting it to 'Y' will disable disconnect injection on the RPC server. h](h)}(h7/sys/kernel/debug/fail_sunrpc/ignore-server-disconnect:h]h7/sys/kernel/debug/fail_sunrpc/ignore-server-disconnect:}(hjmhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjiubj)}(hnFormat: { 'Y' | 'N' } default is 'N', setting it to 'Y' will disable disconnect injection on the RPC server. h](h)}(hFormat: { 'Y' | 'N' }h]hFormat: { ‘Y’ | ‘N’ }}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhj{ubh)}(hVdefault is 'N', setting it to 'Y' will disable disconnect injection on the RPC server.h]h^default is ‘N’, setting it to ‘Y’ will disable disconnect injection on the RPC server.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhj{ubeh}(h]h ]h"]h$]h&]uh1jhhhKhjiubeh}(h]h ]h"]h$]h&]uh1hhjhhhhhNubh)}(h/sys/kernel/debug/fail_sunrpc/ignore-cache-wait: Format: { 'Y' | 'N' } default is 'N', setting it to 'Y' will disable cache wait injection on the RPC server. h](h)}(h0/sys/kernel/debug/fail_sunrpc/ignore-cache-wait:h]h0/sys/kernel/debug/fail_sunrpc/ignore-cache-wait:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubj)}(hnFormat: { 'Y' | 'N' } default is 'N', setting it to 'Y' will disable cache wait injection on the RPC server. h](h)}(hFormat: { 'Y' | 'N' }h]hFormat: { ‘Y’ | ‘N’ }}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubh)}(hVdefault is 'N', setting it to 'Y' will disable cache wait injection on the RPC server.h]h^default is ‘N’, setting it to ‘Y’ will disable cache wait injection on the RPC server.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubeh}(h]h ]h"]h$]h&]uh1jhhhKhjubeh}(h]h ]h"]h$]h&]uh1hhjhhhhhNubh)}(hXA/sys/kernel/debug/fail_function/inject: Format: { 'function-name' | '!function-name' | '' } specifies the target function of error injection by name. If the function name leads '!' prefix, given function is removed from injection list. If nothing specified ('') injection list is cleared. h](h)}(h'/sys/kernel/debug/fail_function/inject:h]h'/sys/kernel/debug/fail_function/inject:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubj)}(hFormat: { 'function-name' | '!function-name' | '' } specifies the target function of error injection by name. If the function name leads '!' prefix, given function is removed from injection list. If nothing specified ('') injection list is cleared. h](h)}(h3Format: { 'function-name' | '!function-name' | '' }h]h?Format: { ‘function-name’ | ‘!function-name’ | ‘’ }}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubh)}(hspecifies the target function of error injection by name. If the function name leads '!' prefix, given function is removed from injection list. If nothing specified ('') injection list is cleared.h]hspecifies the target function of error injection by name. If the function name leads ‘!’ prefix, given function is removed from injection list. If nothing specified (‘’) injection list is cleared.}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubeh}(h]h ]h"]h$]h&]uh1jhhhKhjubeh}(h]h ]h"]h$]h&]uh1hhjhhhhhNubh)}(hXY/sys/kernel/debug/fail_function/injectable: (read only) shows error injectable functions and what type of error values can be specified. The error type will be one of below; - NULL: retval must be 0. - ERRNO: retval must be -1 to -MAX_ERRNO (-4096). - ERR_NULL: retval must be 0 or -1 to -MAX_ERRNO (-4096). h](h)}(h+/sys/kernel/debug/fail_function/injectable:h]h+/sys/kernel/debug/fail_function/injectable:}(hj'hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhj#ubj)}(hX(read only) shows error injectable functions and what type of error values can be specified. The error type will be one of below; - NULL: retval must be 0. - ERRNO: retval must be -1 to -MAX_ERRNO (-4096). - ERR_NULL: retval must be 0 or -1 to -MAX_ERRNO (-4096). h]h)}(hX(read only) shows error injectable functions and what type of error values can be specified. The error type will be one of below; - NULL: retval must be 0. - ERRNO: retval must be -1 to -MAX_ERRNO (-4096). - ERR_NULL: retval must be 0 or -1 to -MAX_ERRNO (-4096).h]hX(read only) shows error injectable functions and what type of error values can be specified. The error type will be one of below; - NULL: retval must be 0. - ERRNO: retval must be -1 to -MAX_ERRNO (-4096). - ERR_NULL: retval must be 0 or -1 to -MAX_ERRNO (-4096).}(hj9hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhj5ubah}(h]h ]h"]h$]h&]uh1jhhhKhj#ubeh}(h]h ]h"]h$]h&]uh1hhjhhhhhNubh)}(hX/sys/kernel/debug/fail_function//retval: specifies the "error" return value to inject to the given function. This will be created when the user specifies a new injection entry. Note that this file only accepts unsigned values. So, if you want to use a negative errno, you better use 'printf' instead of 'echo', e.g.: $ printf %#x -12 > retval h](h)}(h7/sys/kernel/debug/fail_function//retval:h]h7/sys/kernel/debug/fail_function//retval:}(hjWhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjSubj)}(hX.specifies the "error" return value to inject to the given function. This will be created when the user specifies a new injection entry. Note that this file only accepts unsigned values. So, if you want to use a negative errno, you better use 'printf' instead of 'echo', e.g.: $ printf %#x -12 > retval h]h)}(hX-specifies the "error" return value to inject to the given function. This will be created when the user specifies a new injection entry. Note that this file only accepts unsigned values. So, if you want to use a negative errno, you better use 'printf' instead of 'echo', e.g.: $ printf %#x -12 > retvalh]hX9specifies the “error” return value to inject to the given function. This will be created when the user specifies a new injection entry. Note that this file only accepts unsigned values. So, if you want to use a negative errno, you better use ‘printf’ instead of ‘echo’, e.g.: $ printf %#x -12 > retval}(hjihhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjeubah}(h]h ]h"]h$]h&]uh1jhhhKhjSubeh}(h]h ]h"]h$]h&]uh1hhjhhhhhNubh)}(hX/sys/kernel/debug/fail_skb_realloc/devname: Specifies the network interface on which to force SKB reallocation. If left empty, SKB reallocation will be applied to all network interfaces. Example usage:: # Force skb reallocation on eth0 echo "eth0" > /sys/kernel/debug/fail_skb_realloc/devname # Clear the selection and force skb reallocation on all interfaces echo "" > /sys/kernel/debug/fail_skb_realloc/devname h](h)}(h+/sys/kernel/debug/fail_skb_realloc/devname:h]h+/sys/kernel/debug/fail_skb_realloc/devname:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubj)}(hX}Specifies the network interface on which to force SKB reallocation. If left empty, SKB reallocation will be applied to all network interfaces. Example usage:: # Force skb reallocation on eth0 echo "eth0" > /sys/kernel/debug/fail_skb_realloc/devname # Clear the selection and force skb reallocation on all interfaces echo "" > /sys/kernel/debug/fail_skb_realloc/devname h](h)}(hSpecifies the network interface on which to force SKB reallocation. If left empty, SKB reallocation will be applied to all network interfaces.h]hSpecifies the network interface on which to force SKB reallocation. If left empty, SKB reallocation will be applied to all network interfaces.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubh)}(hExample usage::h]hExample usage:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubh literal_block)}(h# Force skb reallocation on eth0 echo "eth0" > /sys/kernel/debug/fail_skb_realloc/devname # Clear the selection and force skb reallocation on all interfaces echo "" > /sys/kernel/debug/fail_skb_realloc/devnameh]h# Force skb reallocation on eth0 echo "eth0" > /sys/kernel/debug/fail_skb_realloc/devname # Clear the selection and force skb reallocation on all interfaces echo "" > /sys/kernel/debug/fail_skb_realloc/devname}hjsbah}(h]h ]h"]h$]h&] xml:spacepreserveuh1jhhhKhjubeh}(h]h ]h"]h$]h&]uh1jhhhKhjubeh}(h]h ]h"]h$]h&]uh1hhjhhhhhNubeh}(h]h ]h"]h$]h&]jjuh1hhhhKchjhhubeh}(h]debugfs-entriesah ]h"]debugfs entriesah$]h&]uh1hhjhhhhhK^ubh)}(hhh](h)}(h Boot optionh]h Boot option}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjhhhhhMubh)}(haIn order to inject faults while debugfs is not available (early boot time), use the boot option::h]h`In order to inject faults while debugfs is not available (early boot time), use the boot option:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjhhubj)}(hfailslab= fail_page_alloc= fail_usercopy= fail_make_request= fail_futex= fail_skb_realloc= mmc_core.fail_request=,,,h]hfailslab= fail_page_alloc= fail_usercopy= fail_make_request= fail_futex= fail_skb_realloc= mmc_core.fail_request=,,,}hjsbah}(h]h ]h"]h$]h&]jjuh1jhhhMhjhhubeh}(h] boot-optionah ]h"] boot optionah$]h&]uh1hhjhhhhhMubh)}(hhh](h)}(h proc entriesh]h proc entries}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjhhhhhMubh)}(hhh]h)}(hX/proc//fail-nth, /proc/self/task//fail-nth: Write to this file of integer N makes N-th call in the task fail. Read from this file returns a integer value. A value of '0' indicates that the fault setup with a previous write to this file was injected. A positive integer N indicates that the fault wasn't yet injected. Note that this file enables all types of faults (slab, futex, etc). This setting takes precedence over all other generic debugfs 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. h](h)}(h5/proc//fail-nth, /proc/self/task//fail-nth:h]h5/proc//fail-nth, /proc/self/task//fail-nth:}(hj.hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj*ubj)}(hXWrite to this file of integer N makes N-th call in the task fail. Read from this file returns a integer value. A value of '0' indicates that the fault setup with a previous write to this file was injected. A positive integer N indicates that the fault wasn't yet injected. Note that this file enables all types of faults (slab, futex, etc). This setting takes precedence over all other generic debugfs 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. h](h)}(hXWrite to this file of integer N makes N-th call in the task fail. Read from this file returns a integer value. A value of '0' indicates that the fault setup with a previous write to this file was injected. A positive integer N indicates that the fault wasn't yet injected. Note that this file enables all types of faults (slab, futex, etc). This setting takes precedence over all other generic debugfs settings like probability, interval, times, etc. But per-capability settings (e.g. fail_futex/ignore-private) take precedence over it.h]hXWrite to this file of integer N makes N-th call in the task fail. Read from this file returns a integer value. A value of ‘0’ indicates that the fault setup with a previous write to this file was injected. A positive integer N indicates that the fault wasn’t yet injected. Note that this file enables all types of faults (slab, futex, etc). This setting takes precedence over all other generic debugfs settings like probability, interval, times, etc. But per-capability settings (e.g. fail_futex/ignore-private) take precedence over it.}(hj@hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj<ubh)}(hhThis feature is intended for systematic testing of faults in a single system call. See an example below.h]hhThis feature is intended for systematic testing of faults in a single system call. See an example below.}(hjNhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj<ubeh}(h]h ]h"]h$]h&]uh1jhhhMhj*ubeh}(h]h ]h"]h$]h&]uh1hhj'hhhhhNubah}(h]h ]h"]h$]h&]jjuh1hhhhMhjhhubeh}(h] proc-entriesah ]h"] proc entriesah$]h&]uh1hhjhhhhhMubeh}(h]/configure-fault-injection-capabilities-behaviorah ]h"]/configure fault-injection capabilities behaviorah$]h&]uh1hhhhhhhhK[ubh)}(hhh](h)}(hError Injectable Functionsh]hError Injectable Functions}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhj~hhhhhM$ubh)}(hfThis part is for the kernel developers considering to add a function to ALLOW_ERROR_INJECTION() macro.h]hfThis part is for the kernel developers considering to add a function to ALLOW_ERROR_INJECTION() macro.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhM&hj~hhubh)}(hhh](h)}(h/Requirements for the Error Injectable Functionsh]h/Requirements for the Error Injectable Functions}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjhhhhhM*ubh)}(hX#Since the function-level error injection forcibly changes the code path and returns an error even if the input and conditions are proper, this can cause unexpected kernel crash if you allow error injection on the function which is NOT error injectable. Thus, you (and reviewers) must ensure;h]hX#Since the function-level error injection forcibly changes the code path and returns an error even if the input and conditions are proper, this can cause unexpected kernel crash if you allow error injection on the function which is NOT error injectable. Thus, you (and reviewers) must ensure;}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhM,hjhhubh)}(hhh](h)}(hsThe function returns an error code if it fails, and the callers must check it correctly (need to recover from it). h]h)}(hrThe function returns an error code if it fails, and the callers must check it correctly (need to recover from it).h]hrThe function returns an error code if it fails, and the callers must check it correctly (need to recover from it).}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhM1hjubah}(h]h ]h"]h$]h&]uh1hhjhhhhhNubh)}(hXgThe function does not execute any code which can change any state before the first error return. The state includes global or local, or input variable. For example, clear output address storage (e.g. `*ret = NULL`), increments/decrements counter, set a flag, preempt/irq disable or get a lock (if those are recovered before returning error, that will be OK.) h]h)}(hXfThe function does not execute any code which can change any state before the first error return. The state includes global or local, or input variable. For example, clear output address storage (e.g. `*ret = NULL`), increments/decrements counter, set a flag, preempt/irq disable or get a lock (if those are recovered before returning error, that will be OK.)h](hThe function does not execute any code which can change any state before the first error return. The state includes global or local, or input variable. For example, clear output address storage (e.g. }(hjhhhNhNubhtitle_reference)}(h `*ret = NULL`h]h *ret = NULL}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhjubh), increments/decrements counter, set a flag, preempt/irq disable or get a lock (if those are recovered before returning error, that will be OK.)}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhM4hjubah}(h]h ]h"]h$]h&]uh1hhjhhhhhNubeh}(h]h ]h"]h$]h&]jjuh1hhhhM1hjhhubh)}(hXKThe first requirement is important, and it will result in that the release (free objects) functions are usually harder to inject errors than allocate functions. If errors of such release functions are not correctly handled it will cause a memory leak easily (the caller will confuse that the object has been released or corrupted.)h]hXKThe first requirement is important, and it will result in that the release (free objects) functions are usually harder to inject errors than allocate functions. If errors of such release functions are not correctly handled it will cause a memory leak easily (the caller will confuse that the object has been released or corrupted.)}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhM:hjhhubh)}(hThe second one is for the caller which expects the function should always does something. Thus if the function error injection skips whole of the function, the expectation is betrayed and causes an unexpected error.h]hThe second one is for the caller which expects the function should always does something. Thus if the function error injection skips whole of the function, the expectation is betrayed and causes an unexpected error.}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhM@hjhhubeh}(h]/requirements-for-the-error-injectable-functionsah ]h"]/requirements for the error injectable functionsah$]h&]uh1hhj~hhhhhM*ubh)}(hhh](h)}(h&Type of the Error Injectable Functionsh]h&Type of the Error Injectable Functions}(hj0 hhhNhNubah}(h]h ]h"]h$]h&]uh1hhj- hhhhhMEubh)}(hXiEach error injectable functions will have the error type specified by the ALLOW_ERROR_INJECTION() macro. You have to choose it carefully if you add a new error injectable function. If the wrong error type is chosen, the kernel may crash because it may not be able to handle the error. There are 4 types of errors defined in include/asm-generic/error-injection.hh]hXiEach error injectable functions will have the error type specified by the ALLOW_ERROR_INJECTION() macro. You have to choose it carefully if you add a new error injectable function. If the wrong error type is chosen, the kernel may crash because it may not be able to handle the error. There are 4 types of errors defined in include/asm-generic/error-injection.h}(hj> hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMGhj- hhubj)}(hhh](j )}(heEI_ETYPE_NULL This function will return `NULL` if it fails. e.g. return an allocated object address. h](j)}(h EI_ETYPE_NULLh]h EI_ETYPE_NULL}(hjS hhhNhNubah}(h]h ]h"]h$]h&]uh1jhhhMOhjO ubj")}(hhh]h)}(hVThis function will return `NULL` if it fails. e.g. return an allocated object address.h](hThis function will return }(hjd hhhNhNubj)}(h`NULL`h]hNULL}(hjl hhhNhNubah}(h]h ]h"]h$]h&]uh1jhjd ubh6 if it fails. e.g. return an allocated object address.}(hjd hhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhMNhja ubah}(h]h ]h"]h$]h&]uh1j!hjO ubeh}(h]h ]h"]h$]h&]uh1j hhhMOhjL ubj )}(hEI_ETYPE_ERRNO This function will return an `-errno` error code if it fails. e.g. return -EINVAL if the input is wrong. This will include the functions which will return an address which encodes `-errno` by ERR_PTR() macro. h](j)}(hEI_ETYPE_ERRNOh]hEI_ETYPE_ERRNO}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1jhhhMThj ubj")}(hhh]h)}(hThis function will return an `-errno` error code if it fails. e.g. return -EINVAL if the input is wrong. This will include the functions which will return an address which encodes `-errno` by ERR_PTR() macro.h](hThis function will return an }(hj hhhNhNubj)}(h`-errno`h]h-errno}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1jhj ubh error code if it fails. e.g. return -EINVAL if the input is wrong. This will include the functions which will return an address which encodes }(hj hhhNhNubj)}(h`-errno`h]h-errno}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1jhj ubh by ERR_PTR() macro.}(hj hhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhMRhj ubah}(h]h ]h"]h$]h&]uh1j!hj ubeh}(h]h ]h"]h$]h&]uh1j hhhMThjL hhubj )}(hEI_ETYPE_ERRNO_NULL This function will return an `-errno` or `NULL` if it fails. If the caller of this function checks the return value with IS_ERR_OR_NULL() macro, this type will be appropriate. h](j)}(hEI_ETYPE_ERRNO_NULLh]hEI_ETYPE_ERRNO_NULL}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1jhhhMYhj ubj")}(hhh]h)}(hThis function will return an `-errno` or `NULL` if it fails. If the caller of this function checks the return value with IS_ERR_OR_NULL() macro, this type will be appropriate.h](hThis function will return an }(hj hhhNhNubj)}(h`-errno`h]h-errno}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1jhj ubh or }(hj hhhNhNubj)}(h`NULL`h]hNULL}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1jhj ubh if it fails. If the caller of this function checks the return value with IS_ERR_OR_NULL() macro, this type will be appropriate.}(hj hhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhMWhj ubah}(h]h ]h"]h$]h&]uh1j!hj ubeh}(h]h ]h"]h$]h&]uh1j hhhMYhjL hhubj )}(hVEI_ETYPE_TRUE This function will return `true` (non-zero positive value) if it fails. h](j)}(h EI_ETYPE_TRUEh]h EI_ETYPE_TRUE}(hj: hhhNhNubah}(h]h ]h"]h$]h&]uh1jhhhM\hj6 ubj")}(hhh]h)}(hGThis function will return `true` (non-zero positive value) if it fails.h](hThis function will return }(hjK hhhNhNubj)}(h`true`h]htrue}(hjS hhhNhNubah}(h]h ]h"]h$]h&]uh1jhjK ubh' (non-zero positive value) if it fails.}(hjK hhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhM\hjH ubah}(h]h ]h"]h$]h&]uh1j!hj6 ubeh}(h]h ]h"]h$]h&]uh1j hhhM\hjL hhubeh}(h]h ]h"]h$]h&]uh1jhj- hhhhhNubh)}(hIf you specifies a wrong type, for example, EI_TYPE_ERRNO for the function which returns an allocated object, it may cause a problem because the returned value is not an object address and the caller can not access to the address.h]hIf you specifies a wrong type, for example, EI_TYPE_ERRNO for the function which returns an allocated object, it may cause a problem because the returned value is not an object address and the caller can not access to the address.}(hj} hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhM^hj- hhubeh}(h]&type-of-the-error-injectable-functionsah ]h"]&type of the error injectable functionsah$]h&]uh1hhj~hhhhhMEubeh}(h]error-injectable-functionsah ]h"]error injectable functionsah$]h&]uh1hhhhhhhhM$ubh)}(hhh](h)}(h)How to add new fault injection capabilityh]h)How to add new fault injection capability}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhj hhhhhMdubh)}(hhh](h)}(h #include h]h)}(h#include h]h#include }(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMfhj ubah}(h]h ]h"]h$]h&]uh1hhj hhhhhNubh)}(hdefine the fault attributes DECLARE_FAULT_ATTR(name); Please see the definition of struct fault_attr in fault-inject.h for details. h](h)}(hdefine the fault attributesh]hdefine the fault attributes}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhhj ubh)}(hDECLARE_FAULT_ATTR(name);h]hDECLARE_FAULT_ATTR(name);}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMjhj ubh)}(hMPlease see the definition of struct fault_attr in fault-inject.h for details.h]hMPlease see the definition of struct fault_attr in fault-inject.h for details.}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMlhj ubeh}(h]h ]h"]h$]h&]uh1hhj hhhhhNubh)}(h,provide a way to configure fault attributes h]h)}(h+provide a way to configure fault attributesh]h+provide a way to configure fault attributes}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMohj ubah}(h]h ]h"]h$]h&]uh1hhj hhhhhNubh)}(hboot option If you need to enable the fault injection capability from boot time, you can provide boot option to configure it. There is a helper function for it: setup_fault_attr(attr, str); h](h)}(h boot optionh]h boot option}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMqhj ubh)}(hIf you need to enable the fault injection capability from boot time, you can provide boot option to configure it. There is a helper function for it:h]hIf you need to enable the fault injection capability from boot time, you can provide boot option to configure it. There is a helper function for it:}(hj% hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMshj ubj)}(hsetup_fault_attr(attr, str); h]h)}(hsetup_fault_attr(attr, str);h]hsetup_fault_attr(attr, str);}(hj7 hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMvhj3 ubah}(h]h ]h"]h$]h&]uh1jhhhMvhj ubeh}(h]h ]h"]h$]h&]uh1hhj hhhhhNubh)}(hdebugfs entries failslab, fail_page_alloc, fail_usercopy, and fail_make_request use this way. Helper functions: fault_create_debugfs_attr(name, parent, attr); h](h)}(hdebugfs entriesh]hdebugfs entries}(hjU hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMxhjQ ubh)}(h_failslab, fail_page_alloc, fail_usercopy, and fail_make_request use this way. Helper functions:h]h_failslab, fail_page_alloc, fail_usercopy, and fail_make_request use this way. Helper functions:}(hjc hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMzhjQ ubj)}(h/fault_create_debugfs_attr(name, parent, attr); h]h)}(h.fault_create_debugfs_attr(name, parent, attr);h]h.fault_create_debugfs_attr(name, parent, attr);}(hju hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhM}hjq ubah}(h]h ]h"]h$]h&]uh1jhhhM}hjQ ubeh}(h]h ]h"]h$]h&]uh1hhj hhhhhNubh)}(hmodule parameters If the scope of the fault injection capability is limited to a single kernel module, it is better to provide module parameters to configure the fault attributes. h](h)}(hmodule parametersh]hmodule parameters}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj ubh)}(hIf the scope of the fault injection capability is limited to a single kernel module, it is better to provide module parameters to configure the fault attributes.h]hIf the scope of the fault injection capability is limited to a single kernel module, it is better to provide module parameters to configure the fault attributes.}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj ubeh}(h]h ]h"]h$]h&]uh1hhj hhhhhNubh)}(hadd a hook to insert failures Upon should_fail() returning true, client code should inject a failure: should_fail(attr, size); h](h)}(hadd a hook to insert failuresh]hadd a hook to insert failures}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj ubh)}(hGUpon should_fail() returning true, client code should inject a failure:h]hGUpon should_fail() returning true, client code should inject a failure:}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj ubj)}(hshould_fail(attr, size); h]h)}(hshould_fail(attr, size);h]hshould_fail(attr, size);}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj ubah}(h]h ]h"]h$]h&]uh1jhhhMhj ubeh}(h]h ]h"]h$]h&]uh1hhj hhhhhNubeh}(h]h ]h"]h$]h&]jjuh1hhhhMfhj hhubeh}(h])how-to-add-new-fault-injection-capabilityah ]h"])how to add new fault injection capabilityah$]h&]uh1hhhhhhhhMdubh)}(hhh](h)}(hApplication Examplesh]hApplication Examples}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhj hhhhhMubh)}(hhh]h)}(hXInject slab allocation failures into module init/exit code:: #!/bin/bash FAILTYPE=failslab echo Y > /sys/kernel/debug/$FAILTYPE/task-filter echo 10 > /sys/kernel/debug/$FAILTYPE/probability echo 100 > /sys/kernel/debug/$FAILTYPE/interval echo -1 > /sys/kernel/debug/$FAILTYPE/times echo 0 > /sys/kernel/debug/$FAILTYPE/space echo 2 > /sys/kernel/debug/$FAILTYPE/verbose echo Y > /sys/kernel/debug/$FAILTYPE/ignore-gfp-wait faulty_system() { bash -c "echo 1 > /proc/self/make-it-fail && exec $*" } if [ $# -eq 0 ] then echo "Usage: $0 modulename [ modulename ... ]" exit 1 fi for m in $* do echo inserting $m... faulty_system modprobe $m echo removing $m... faulty_system modprobe -r $m done h](h)}(h /sys/kernel/debug/$FAILTYPE/task-filter echo 10 > /sys/kernel/debug/$FAILTYPE/probability echo 100 > /sys/kernel/debug/$FAILTYPE/interval echo -1 > /sys/kernel/debug/$FAILTYPE/times echo 0 > /sys/kernel/debug/$FAILTYPE/space echo 2 > /sys/kernel/debug/$FAILTYPE/verbose echo Y > /sys/kernel/debug/$FAILTYPE/ignore-gfp-wait faulty_system() { bash -c "echo 1 > /proc/self/make-it-fail && exec $*" } if [ $# -eq 0 ] then echo "Usage: $0 modulename [ modulename ... ]" exit 1 fi for m in $* do echo inserting $m... faulty_system modprobe $m echo removing $m... faulty_system modprobe -r $m doneh]hX#!/bin/bash FAILTYPE=failslab echo Y > /sys/kernel/debug/$FAILTYPE/task-filter echo 10 > /sys/kernel/debug/$FAILTYPE/probability echo 100 > /sys/kernel/debug/$FAILTYPE/interval echo -1 > /sys/kernel/debug/$FAILTYPE/times echo 0 > /sys/kernel/debug/$FAILTYPE/space echo 2 > /sys/kernel/debug/$FAILTYPE/verbose echo Y > /sys/kernel/debug/$FAILTYPE/ignore-gfp-wait faulty_system() { bash -c "echo 1 > /proc/self/make-it-fail && exec $*" } if [ $# -eq 0 ] then echo "Usage: $0 modulename [ modulename ... ]" exit 1 fi for m in $* do echo inserting $m... faulty_system modprobe $m echo removing $m... faulty_system modprobe -r $m done}hj' sbah}(h]h ]h"]h$]h&]jjuh1jhhhMhj ubeh}(h]h ]h"]h$]h&]uh1hhj hhhhhNubah}(h]h ]h"]h$]h&]jjuh1hhhhMEhj hhubh transition)}(hN------------------------------------------------------------------------------h]h}(h]h ]h"]h$]h&]uh1jA hhhMhj hhubh)}(hhh]h)}(hXgInject page allocation failures only for a specific module:: #!/bin/bash FAILTYPE=fail_page_alloc module=$1 if [ -z $module ] then echo "Usage: $0 " exit 1 fi modprobe $module if [ ! -d /sys/module/$module/sections ] then echo Module $module is not loaded exit 1 fi cat /sys/module/$module/sections/.text > /sys/kernel/debug/$FAILTYPE/require-start cat /sys/module/$module/sections/.data > /sys/kernel/debug/$FAILTYPE/require-end echo N > /sys/kernel/debug/$FAILTYPE/task-filter echo 10 > /sys/kernel/debug/$FAILTYPE/probability echo 100 > /sys/kernel/debug/$FAILTYPE/interval echo -1 > /sys/kernel/debug/$FAILTYPE/times echo 0 > /sys/kernel/debug/$FAILTYPE/space echo 2 > /sys/kernel/debug/$FAILTYPE/verbose echo Y > /sys/kernel/debug/$FAILTYPE/ignore-gfp-wait echo Y > /sys/kernel/debug/$FAILTYPE/ignore-gfp-highmem echo 10 > /sys/kernel/debug/$FAILTYPE/stacktrace-depth trap "echo 0 > /sys/kernel/debug/$FAILTYPE/probability" SIGINT SIGTERM EXIT echo "Injecting errors into the module $module... (interrupt to stop)" sleep 1000000 h](h)}(h" exit 1 fi modprobe $module if [ ! -d /sys/module/$module/sections ] then echo Module $module is not loaded exit 1 fi cat /sys/module/$module/sections/.text > /sys/kernel/debug/$FAILTYPE/require-start cat /sys/module/$module/sections/.data > /sys/kernel/debug/$FAILTYPE/require-end echo N > /sys/kernel/debug/$FAILTYPE/task-filter echo 10 > /sys/kernel/debug/$FAILTYPE/probability echo 100 > /sys/kernel/debug/$FAILTYPE/interval echo -1 > /sys/kernel/debug/$FAILTYPE/times echo 0 > /sys/kernel/debug/$FAILTYPE/space echo 2 > /sys/kernel/debug/$FAILTYPE/verbose echo Y > /sys/kernel/debug/$FAILTYPE/ignore-gfp-wait echo Y > /sys/kernel/debug/$FAILTYPE/ignore-gfp-highmem echo 10 > /sys/kernel/debug/$FAILTYPE/stacktrace-depth trap "echo 0 > /sys/kernel/debug/$FAILTYPE/probability" SIGINT SIGTERM EXIT echo "Injecting errors into the module $module... (interrupt to stop)" sleep 1000000h]hX#!/bin/bash FAILTYPE=fail_page_alloc module=$1 if [ -z $module ] then echo "Usage: $0 " exit 1 fi modprobe $module if [ ! -d /sys/module/$module/sections ] then echo Module $module is not loaded exit 1 fi cat /sys/module/$module/sections/.text > /sys/kernel/debug/$FAILTYPE/require-start cat /sys/module/$module/sections/.data > /sys/kernel/debug/$FAILTYPE/require-end echo N > /sys/kernel/debug/$FAILTYPE/task-filter echo 10 > /sys/kernel/debug/$FAILTYPE/probability echo 100 > /sys/kernel/debug/$FAILTYPE/interval echo -1 > /sys/kernel/debug/$FAILTYPE/times echo 0 > /sys/kernel/debug/$FAILTYPE/space echo 2 > /sys/kernel/debug/$FAILTYPE/verbose echo Y > /sys/kernel/debug/$FAILTYPE/ignore-gfp-wait echo Y > /sys/kernel/debug/$FAILTYPE/ignore-gfp-highmem echo 10 > /sys/kernel/debug/$FAILTYPE/stacktrace-depth trap "echo 0 > /sys/kernel/debug/$FAILTYPE/probability" SIGINT SIGTERM EXIT echo "Injecting errors into the module $module... (interrupt to stop)" sleep 1000000}hjb sbah}(h]h ]h"]h$]h&]jjuh1jhhhMhjP ubeh}(h]h ]h"]h$]h&]uh1hhjM hhhhhNubah}(h]h ]h"]h$]h&]jjuh1hhhhMhj hhubjB )}(hN------------------------------------------------------------------------------h]h}(h]h ]h"]h$]h&]uh1jA hhhMhj hhubh)}(hhh]h)}(hXInject open_ctree error while btrfs mount:: #!/bin/bash rm -f testfile.img dd if=/dev/zero of=testfile.img bs=1M seek=1000 count=1 DEVICE=$(losetup --show -f testfile.img) mkfs.btrfs -f $DEVICE mkdir -p tmpmnt FAILTYPE=fail_function FAILFUNC=open_ctree echo $FAILFUNC > /sys/kernel/debug/$FAILTYPE/inject printf %#x -12 > /sys/kernel/debug/$FAILTYPE/$FAILFUNC/retval echo N > /sys/kernel/debug/$FAILTYPE/task-filter echo 100 > /sys/kernel/debug/$FAILTYPE/probability echo 0 > /sys/kernel/debug/$FAILTYPE/interval echo -1 > /sys/kernel/debug/$FAILTYPE/times echo 0 > /sys/kernel/debug/$FAILTYPE/space echo 1 > /sys/kernel/debug/$FAILTYPE/verbose mount -t btrfs $DEVICE tmpmnt if [ $? -ne 0 ] then echo "SUCCESS!" else echo "FAILED!" umount tmpmnt fi echo > /sys/kernel/debug/$FAILTYPE/inject rmdir tmpmnt losetup -d $DEVICE rm testfile.img h](h)}(h+Inject open_ctree error while btrfs mount::h]h*Inject open_ctree error while btrfs mount:}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj ubj)}(hX+#!/bin/bash rm -f testfile.img dd if=/dev/zero of=testfile.img bs=1M seek=1000 count=1 DEVICE=$(losetup --show -f testfile.img) mkfs.btrfs -f $DEVICE mkdir -p tmpmnt FAILTYPE=fail_function FAILFUNC=open_ctree echo $FAILFUNC > /sys/kernel/debug/$FAILTYPE/inject printf %#x -12 > /sys/kernel/debug/$FAILTYPE/$FAILFUNC/retval echo N > /sys/kernel/debug/$FAILTYPE/task-filter echo 100 > /sys/kernel/debug/$FAILTYPE/probability echo 0 > /sys/kernel/debug/$FAILTYPE/interval echo -1 > /sys/kernel/debug/$FAILTYPE/times echo 0 > /sys/kernel/debug/$FAILTYPE/space echo 1 > /sys/kernel/debug/$FAILTYPE/verbose mount -t btrfs $DEVICE tmpmnt if [ $? -ne 0 ] then echo "SUCCESS!" else echo "FAILED!" umount tmpmnt fi echo > /sys/kernel/debug/$FAILTYPE/inject rmdir tmpmnt losetup -d $DEVICE rm testfile.imgh]hX+#!/bin/bash rm -f testfile.img dd if=/dev/zero of=testfile.img bs=1M seek=1000 count=1 DEVICE=$(losetup --show -f testfile.img) mkfs.btrfs -f $DEVICE mkdir -p tmpmnt FAILTYPE=fail_function FAILFUNC=open_ctree echo $FAILFUNC > /sys/kernel/debug/$FAILTYPE/inject printf %#x -12 > /sys/kernel/debug/$FAILTYPE/$FAILFUNC/retval echo N > /sys/kernel/debug/$FAILTYPE/task-filter echo 100 > /sys/kernel/debug/$FAILTYPE/probability echo 0 > /sys/kernel/debug/$FAILTYPE/interval echo -1 > /sys/kernel/debug/$FAILTYPE/times echo 0 > /sys/kernel/debug/$FAILTYPE/space echo 1 > /sys/kernel/debug/$FAILTYPE/verbose mount -t btrfs $DEVICE tmpmnt if [ $? -ne 0 ] then echo "SUCCESS!" else echo "FAILED!" umount tmpmnt fi echo > /sys/kernel/debug/$FAILTYPE/inject rmdir tmpmnt losetup -d $DEVICE rm testfile.img}hj sbah}(h]h ]h"]h$]h&]jjuh1jhhhMhj ubeh}(h]h ]h"]h$]h&]uh1hhj hhhhhNubah}(h]h ]h"]h$]h&]jjuh1hhhhMhj hhubjB )}(hN------------------------------------------------------------------------------h]h}(h]h ]h"]h$]h&]uh1jA hhhMhj hhubh)}(hhh]h)}(hX_Inject only skbuff allocation failures :: # mark skbuff_head_cache as faulty echo 1 > /sys/kernel/slab/skbuff_head_cache/failslab # Turn on cache filter (off by default) echo 1 > /sys/kernel/debug/failslab/cache-filter # Turn on fault injection echo 1 > /sys/kernel/debug/failslab/times echo 1 > /sys/kernel/debug/failslab/probability h](h)}(h)Inject only skbuff allocation failures ::h]h&Inject only skbuff allocation failures}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj ubj)}(hX$# mark skbuff_head_cache as faulty echo 1 > /sys/kernel/slab/skbuff_head_cache/failslab # Turn on cache filter (off by default) echo 1 > /sys/kernel/debug/failslab/cache-filter # Turn on fault injection echo 1 > /sys/kernel/debug/failslab/times echo 1 > /sys/kernel/debug/failslab/probabilityh]hX$# mark skbuff_head_cache as faulty echo 1 > /sys/kernel/slab/skbuff_head_cache/failslab # Turn on cache filter (off by default) echo 1 > /sys/kernel/debug/failslab/cache-filter # Turn on fault injection echo 1 > /sys/kernel/debug/failslab/times echo 1 > /sys/kernel/debug/failslab/probability}hj sbah}(h]h ]h"]h$]h&]jjuh1jhhhMhj ubeh}(h]h ]h"]h$]h&]uh1hhj hhhhhNubah}(h]h ]h"]h$]h&]jjuh1hhhhMhj hhubeh}(h]application-examplesah ]h"]application examplesah$]h&]uh1hhhhhhhhMubh)}(hhh](h)}(h4Tool to run command with failslab or fail_page_alloch]h4Tool to run command with failslab or fail_page_alloc}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhj hhhhhM ubh)}(hIn order to make it easier to accomplish the tasks mentioned above, we can use tools/testing/fault-injection/failcmd.sh. Please run a command "./tools/testing/fault-injection/failcmd.sh --help" for more information and see the following examples.h]hIn order to make it easier to accomplish the tasks mentioned above, we can use tools/testing/fault-injection/failcmd.sh. Please run a command “./tools/testing/fault-injection/failcmd.sh --help” for more information and see the following examples.}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhM hj hhubh)}(h Examples:h]h Examples:}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj hhubh)}(hcRun a command "make -C tools/testing/selftests/ run_tests" with injecting slab allocation failure::h]hfRun a command “make -C tools/testing/selftests/ run_tests” with injecting slab allocation failure:}(hj# hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj hhubj)}(hd# ./tools/testing/fault-injection/failcmd.sh \ -- make -C tools/testing/selftests/ run_testsh]hd# ./tools/testing/fault-injection/failcmd.sh \ -- make -C tools/testing/selftests/ run_tests}hj1 sbah}(h]h ]h"]h$]h&]jjuh1jhhhMhj hhubh)}(hcSame as above except to specify 100 times failures at most instead of one time at most by default::h]hbSame as above except to specify 100 times failures at most instead of one time at most by default:}(hj? hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj hhubj)}(hp# ./tools/testing/fault-injection/failcmd.sh --times=100 \ -- make -C tools/testing/selftests/ run_testsh]hp# ./tools/testing/fault-injection/failcmd.sh --times=100 \ -- make -C tools/testing/selftests/ run_tests}hjM sbah}(h]h ]h"]h$]h&]jjuh1jhhhMhj hhubh)}(h[Same as above except to inject page allocation failure instead of slab allocation failure::h]hZSame as above except to inject page allocation failure instead of slab allocation failure:}(hj[ hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhM hj hhubj)}(h# env FAILCMD_TYPE=fail_page_alloc \ ./tools/testing/fault-injection/failcmd.sh --times=100 \ -- make -C tools/testing/selftests/ run_testsh]h# env FAILCMD_TYPE=fail_page_alloc \ ./tools/testing/fault-injection/failcmd.sh --times=100 \ -- make -C tools/testing/selftests/ run_tests}hji sbah}(h]h ]h"]h$]h&]jjuh1jhhhM#hj hhubeh}(h]4tool-to-run-command-with-failslab-or-fail-page-allocah ]h"]4tool to run command with failslab or fail_page_allocah$]h&]uh1hhhhhhhhM ubh)}(hhh](h)}(h Systematic faults using fail-nthh]h Systematic faults using fail-nth}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhj hhhhhM(ubh)}(hrThe following code systematically faults 0-th, 1-st, 2-nd and so on capabilities in the socketpair() system call::h]hqThe following code systematically faults 0-th, 1-st, 2-nd and so on capabilities in the socketpair() system call:}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhM*hj hhubj)}(hX #include #include #include #include #include #include #include #include #include #include int main() { int i, err, res, fail_nth, fds[2]; char buf[128]; system("echo N > /sys/kernel/debug/failslab/ignore-gfp-wait"); sprintf(buf, "/proc/self/task/%ld/fail-nth", syscall(SYS_gettid)); fail_nth = open(buf, O_RDWR); for (i = 1;; i++) { sprintf(buf, "%d", i); write(fail_nth, buf, strlen(buf)); res = socketpair(AF_LOCAL, SOCK_STREAM, 0, fds); err = errno; pread(fail_nth, buf, sizeof(buf), 0); if (res == 0) { close(fds[0]); close(fds[1]); } printf("%d-th fault %c: res=%d/%d\n", i, atoi(buf) ? 'N' : 'Y', res, err); if (atoi(buf)) break; } return 0; }h]hX #include #include #include #include #include #include #include #include #include #include int main() { int i, err, res, fail_nth, fds[2]; char buf[128]; system("echo N > /sys/kernel/debug/failslab/ignore-gfp-wait"); sprintf(buf, "/proc/self/task/%ld/fail-nth", syscall(SYS_gettid)); fail_nth = open(buf, O_RDWR); for (i = 1;; i++) { sprintf(buf, "%d", i); write(fail_nth, buf, strlen(buf)); res = socketpair(AF_LOCAL, SOCK_STREAM, 0, fds); err = errno; pread(fail_nth, buf, sizeof(buf), 0); if (res == 0) { close(fds[0]); close(fds[1]); } printf("%d-th fault %c: res=%d/%d\n", i, atoi(buf) ? 'N' : 'Y', res, err); if (atoi(buf)) break; } return 0; }}hj sbah}(h]h ]h"]h$]h&]jjuh1jhhhM-hj hhubh)}(hAn example output::h]hAn example output:}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMRhj hhubj)}(hX1-th fault Y: res=-1/23 2-th fault Y: res=-1/23 3-th fault Y: res=-1/12 4-th fault Y: res=-1/12 5-th fault Y: res=-1/23 6-th fault Y: res=-1/23 7-th fault Y: res=-1/23 8-th fault Y: res=-1/12 9-th fault Y: res=-1/12 10-th fault Y: res=-1/12 11-th fault Y: res=-1/12 12-th fault Y: res=-1/12 13-th fault Y: res=-1/12 14-th fault Y: res=-1/12 15-th fault Y: res=-1/12 16-th fault N: res=0/12h]hX1-th fault Y: res=-1/23 2-th fault Y: res=-1/23 3-th fault Y: res=-1/12 4-th fault Y: res=-1/12 5-th fault Y: res=-1/23 6-th fault Y: res=-1/23 7-th fault Y: res=-1/23 8-th fault Y: res=-1/12 9-th fault Y: res=-1/12 10-th fault Y: res=-1/12 11-th fault Y: res=-1/12 12-th fault Y: res=-1/12 13-th fault Y: res=-1/12 14-th fault Y: res=-1/12 15-th fault Y: res=-1/12 16-th fault N: res=0/12}hj sbah}(h]h ]h"]h$]h&]jjuh1jhhhMThj hhubeh}(h] systematic-faults-using-fail-nthah ]h"] systematic faults using fail-nthah$]h&]uh1hhhhhhhhM(ubeh}(h]+fault-injection-capabilities-infrastructureah ]h"]+fault injection capabilities infrastructureah$]h&]uh1hhhhhhhhKubeh}(h]h ]h"]h$]h&]sourcehuh1hcurrent_sourceN current_lineNsettingsdocutils.frontendValues)}(hN generatorN datestampN source_linkN source_urlN toc_backlinksentryfootnote_backlinksK sectnum_xformKstrip_commentsNstrip_elements_with_classesN strip_classesN report_levelK halt_levelKexit_status_levelKdebugNwarning_streamN tracebackinput_encoding utf-8-siginput_encoding_error_handlerstrictoutput_encodingutf-8output_encoding_error_handlerj error_encodingutf-8error_encoding_error_handlerbackslashreplace language_codeenrecord_dependenciesNconfigN id_prefixhauto_id_prefixid dump_settingsNdump_internalsNdump_transformsNdump_pseudo_xmlNexpose_internalsNstrict_visitorN_disable_configN_sourceh _destinationN _config_files]7/var/lib/git/docbuild/linux/Documentation/docutils.confafile_insertion_enabled raw_enabledKline_length_limitM'pep_referencesN pep_base_urlhttps://peps.python.org/pep_file_url_templatepep-%04drfc_referencesN rfc_base_url&https://datatracker.ietf.org/doc/html/ tab_widthKtrim_footnote_reference_spacesyntax_highlightlong smart_quotessmartquotes_locales]character_level_inline_markupdoctitle_xform docinfo_xformKsectsubtitle_xform image_loadinglinkembed_stylesheetcloak_email_addressessection_self_linkenvNubreporterNindirect_targets]substitution_defs}substitution_names}refnames}refids}nameids}(j j jjj{jxjjjjjsjpj j j* j' j j j j j j j| jy j j u nametypes}(j jj{jjjsj j* j j j j| j uh}(j hjhjxjjjjjjpjj j~j' jj j- j j j j jy j j j u footnote_refs} citation_refs} autofootnotes]autofootnote_refs]symbol_footnotes]symbol_footnote_refs] footnotes] citations]autofootnote_startKsymbol_footnote_startK id_counter collectionsCounter}Rparse_messages]transform_messages] transformerN include_log] decorationNhhub.