pstore update for v5.17-rc1

- Add boot param for early ftrace recording in pstore (Uwe Kleine-König)
 -----BEGIN PGP SIGNATURE-----
 
 iQJKBAABCgA0FiEEpcP2jyKd1g9yPm4TiXL039xtwCYFAmHV0TIWHGtlZXNjb29r
 QGNocm9taXVtLm9yZwAKCRCJcvTf3G3AJveID/0a/qRLfwNyjjLZ2MNtZLfL8ejs
 Qc/3wXJy7IoMe6OagbwS+boJ7PTOa3EMYh0h7GUGc8EjxFai+N2mGqEDMX/JZFRy
 zk1eWfNDpmCBrzo3VlOXrMM0Zb5cj3y9bfsLK31FcLN7gu+ivSXrA6BlPA513E+s
 SISPfK04tXJsLMBg12kKDkp8OcQ9ybKYDxUnScCFg+ef50pFdgzU6K79fUMGac8P
 M0n/ZDZRadUK8fCI2CChlOghWe09gWjWZIxstfn4qY+3C6R97ueB7IVCVgn/fbzX
 JIhsVmxjubQhd6AP/t5Ib5yzRFQ1O+p60LBGuwG8uA25DvnH3MfYhNRqpOB9R0a8
 3IygXuMcCGDl5LCBDteKrktdIKKCA8gLt0IydWD1xcVt8z7ux52/KTPyQZYYCPn4
 LvzACEL6O1qoPEod5k//BbF8p4A8JRBUPUCy55xtdQbOw/kg5H1fWg6xjGYW20Vs
 GpmuKKtDrAKX4OxIdLnaA5p3eBaF98OEo/d/H9PEUkYVc6xoPIGqwvepbt+N5Zpc
 vQ8FRqLTG+KvS3uUyXFlIdR5Rt/qwF0OoFxrMEEp0X/5aKwJHjW9v5qSkKehfQDI
 Ly4QsAaIZJx7w8FckGCBQzvTxfteMp5yivHW0ccOmnqxDLK04keoCxNSFBfP4FLQ
 4puMlfhXcL2ZO640bA==
 =Ux14
 -----END PGP SIGNATURE-----

Merge tag 'pstore-v5.17-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/kees/linux

Pull pstore update from Kees Cook:

 - Add boot param for early ftrace recording in pstore (Uwe
   Kleine-König)

* tag 'pstore-v5.17-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/kees/linux:
  pstore/ftrace: Allow immediate recording
This commit is contained in:
Linus Torvalds 2022-01-10 11:48:37 -08:00
commit 404dbad382
1 changed files with 30 additions and 16 deletions

View File

@ -64,20 +64,12 @@ static struct ftrace_ops pstore_ftrace_ops __read_mostly = {
static DEFINE_MUTEX(pstore_ftrace_lock);
static bool pstore_ftrace_enabled;
static ssize_t pstore_ftrace_knob_write(struct file *f, const char __user *buf,
size_t count, loff_t *ppos)
static int pstore_set_ftrace_enabled(bool on)
{
u8 on;
ssize_t ret;
ret = kstrtou8_from_user(buf, count, 2, &on);
if (ret)
return ret;
mutex_lock(&pstore_ftrace_lock);
if (!on ^ pstore_ftrace_enabled)
goto out;
if (on == pstore_ftrace_enabled)
return 0;
if (on) {
ftrace_ops_set_global_filter(&pstore_ftrace_ops);
@ -89,15 +81,30 @@ static ssize_t pstore_ftrace_knob_write(struct file *f, const char __user *buf,
if (ret) {
pr_err("%s: unable to %sregister ftrace ops: %zd\n",
__func__, on ? "" : "un", ret);
goto err;
} else {
pstore_ftrace_enabled = on;
}
pstore_ftrace_enabled = on;
out:
ret = count;
err:
return ret;
}
static ssize_t pstore_ftrace_knob_write(struct file *f, const char __user *buf,
size_t count, loff_t *ppos)
{
u8 on;
ssize_t ret;
ret = kstrtou8_from_user(buf, count, 2, &on);
if (ret)
return ret;
mutex_lock(&pstore_ftrace_lock);
ret = pstore_set_ftrace_enabled(on);
mutex_unlock(&pstore_ftrace_lock);
if (ret == 0)
ret = count;
return ret;
}
@ -117,6 +124,11 @@ static const struct file_operations pstore_knob_fops = {
static struct dentry *pstore_ftrace_dir;
static bool record_ftrace;
module_param(record_ftrace, bool, 0400);
MODULE_PARM_DESC(record_ftrace,
"enable ftrace recording immediately (default: off)");
void pstore_register_ftrace(void)
{
if (!psinfo->write)
@ -124,6 +136,8 @@ void pstore_register_ftrace(void)
pstore_ftrace_dir = debugfs_create_dir("pstore", NULL);
pstore_set_ftrace_enabled(record_ftrace);
debugfs_create_file("record_ftrace", 0600, pstore_ftrace_dir, NULL,
&pstore_knob_fops);
}