Skip to content

Commit f8feafe

Browse files
committed
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/[email protected]/ Signed-off-by: Kees Cook <[email protected]>
1 parent 7dcb784 commit f8feafe

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

fs/pstore/blk.c

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,10 @@ static long ftrace_size = -1;
5151
module_param(ftrace_size, long, 0400);
5252
MODULE_PARM_DESC(ftrace_size, "ftrace size in kbytes");
5353

54+
static bool best_effort;
55+
module_param(best_effort, bool, 0400);
56+
MODULE_PARM_DESC(best_effort, "use best effort to write (i.e. do not require storage driver pstore support, default: off)");
57+
5458
/*
5559
* blkdev - the block device to use for pstore storage
5660
*
@@ -374,7 +378,8 @@ static int __register_pstore_blk(struct pstore_blk_info *info)
374378
}
375379

376380
/* only allow driver matching the @blkdev */
377-
if (!binfo.devt || MAJOR(binfo.devt) != info->major) {
381+
if (!binfo.devt || (!best_effort &&
382+
MAJOR(binfo.devt) != info->major)) {
378383
pr_debug("invalid major %u (expect %u)\n",
379384
info->major, MAJOR(binfo.devt));
380385
ret = -ENODEV;
@@ -476,6 +481,20 @@ int pstore_blk_get_config(struct pstore_blk_config *info)
476481
}
477482
EXPORT_SYMBOL_GPL(pstore_blk_get_config);
478483

484+
static int __init pstore_blk_init(void)
485+
{
486+
struct pstore_blk_info info = { };
487+
int ret = 0;
488+
489+
mutex_lock(&pstore_blk_lock);
490+
if (!pstore_zone_info && best_effort && blkdev[0])
491+
ret = __register_pstore_blk(&info);
492+
mutex_unlock(&pstore_blk_lock);
493+
494+
return ret;
495+
}
496+
late_initcall(pstore_blk_init);
497+
479498
static void __exit pstore_blk_exit(void)
480499
{
481500
mutex_lock(&pstore_blk_lock);

0 commit comments

Comments
 (0)