diff options
author | Kees Cook <keescook@chromium.org> | 2020-05-08 18:34:01 +0300 |
---|---|---|
committer | Kees Cook <keescook@chromium.org> | 2020-06-01 05:49:01 +0300 |
commit | f8feafeaeedbf0a324c373c5fa29a2098a69c458 (patch) | |
tree | aad8cbc80ade0f54b38c968bc9bfc13a8db420bb /fs/pstore/blk.c | |
parent | 7dcb7848ba110ff192efc917d1a6de66b4c9ca4f (diff) | |
download | linux-f8feafeaeedbf0a324c373c5fa29a2098a69c458.tar.xz |
pstore/blk: Introduce "best_effort" mode
In order to use arbitrary block devices as a pstore backend, provide a
new module param named "best_effort", which will allow using any block
device, even if it has not provided a panic_write callback.
Link: https://lore.kernel.org/lkml/20200511233229.27745-12-keescook@chromium.org/
Signed-off-by: Kees Cook <keescook@chromium.org>
Diffstat (limited to 'fs/pstore/blk.c')
-rw-r--r-- | fs/pstore/blk.c | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/fs/pstore/blk.c b/fs/pstore/blk.c index 881b40ed8142..fcd5563dde06 100644 --- a/fs/pstore/blk.c +++ b/fs/pstore/blk.c @@ -51,6 +51,10 @@ static long ftrace_size = -1; module_param(ftrace_size, long, 0400); MODULE_PARM_DESC(ftrace_size, "ftrace size in kbytes"); +static bool best_effort; +module_param(best_effort, bool, 0400); +MODULE_PARM_DESC(best_effort, "use best effort to write (i.e. do not require storage driver pstore support, default: off)"); + /* * blkdev - the block device to use for pstore storage * @@ -374,7 +378,8 @@ static int __register_pstore_blk(struct pstore_blk_info *info) } /* only allow driver matching the @blkdev */ - if (!binfo.devt || MAJOR(binfo.devt) != info->major) { + if (!binfo.devt || (!best_effort && + MAJOR(binfo.devt) != info->major)) { pr_debug("invalid major %u (expect %u)\n", info->major, MAJOR(binfo.devt)); ret = -ENODEV; @@ -476,6 +481,20 @@ int pstore_blk_get_config(struct pstore_blk_config *info) } EXPORT_SYMBOL_GPL(pstore_blk_get_config); +static int __init pstore_blk_init(void) +{ + struct pstore_blk_info info = { }; + int ret = 0; + + mutex_lock(&pstore_blk_lock); + if (!pstore_zone_info && best_effort && blkdev[0]) + ret = __register_pstore_blk(&info); + mutex_unlock(&pstore_blk_lock); + + return ret; +} +late_initcall(pstore_blk_init); + static void __exit pstore_blk_exit(void) { mutex_lock(&pstore_blk_lock); |