pstore improvements

- Improve backward compatibility with older Chromebooks (Douglas Anderson)
 - Refactor debugfs initialization (Greg KH)
 - Fix double-free in pstore_mkfile() failure path (Norbert Manthey)
 -----BEGIN PGP SIGNATURE-----
 Comment: Kees Cook <kees@outflux.net>
 
 iQJKBAABCgA0FiEEpcP2jyKd1g9yPm4TiXL039xtwCYFAl0kE4MWHGtlZXNjb29r
 QGNocm9taXVtLm9yZwAKCRCJcvTf3G3AJsrbD/wI4xVrLljJ/vjBQIkXqg1QwfWn
 4dseBi2g0l+w2nKUPvsahiL5frBISM5/XD2YJdpq2X9/dvWEXmwv73AHYWjhPkfs
 hx3ecar73iBasjjZJddYAvhB2tTEmBHp2BidBF0uLHVluDWXeP4bpC+YD8i503Us
 4+d+zkHaGuAzPy8UKb9QNhyFsncMbe6QYOJeTi17LHBc+si1ToYtumEFKVI3QK5A
 ODrWIjuXn5tozKCXuWZMbZjgij31gy8NAPCkD0WCDukG3plrtbHQoBz9wk4mRAO2
 fIOHR9SmcqGYh4K+oU4/xds2Yy/MIGgNxomRfjC2Fz7FndWwEUpeDenvHe87vqCL
 3Ja/fhTuwoYlhEijRfkynfGZxkpijEYcf2ZXRE1WbF38do7oJVkJHMxVoBWJxUxu
 5qaMPPkj8I8hSs1EI7apE7K6HVZTqn8DZWjqk+8aPoVKhEfbVLQqwjmUmK/VU6t9
 DpCcXvYTMQsUYlFjSJzJ0UV5mPCL+0JwlK6F4kBZ3HR+sv36ueR/WrjELP7V/B3R
 8M6dCQHtYp/n5D2BEhQLqnxpD21fGVt63Gc7a9Oa8LcHZ4e+H+RRUjMr2uE13V6g
 WwKENAeNSdniwukZ+Ut6H3YQu6yyVeSHiXhUG7sNSzpOmhNoQ2hq5fI0ldv2fmrs
 wR+pR0EJbUNv4QkgIQ==
 =NhP6
 -----END PGP SIGNATURE-----

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

Pull pstore updates from Kees Cook:

 - Improve backward compatibility with older Chromebooks (Douglas
   Anderson)

 - Refactor debugfs initialization (Greg KH)

 - Fix double-free in pstore_mkfile() failure path (Norbert Manthey)

* tag 'pstore-v5.3-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/kees/linux:
  pstore: Fix double-free in pstore_mkfile() failure path
  pstore: no need to check return value of debugfs_create functions
  pstore/ram: Improve backward compatibility with older Chromebooks
This commit is contained in:
Linus Torvalds 2019-07-11 14:40:32 -07:00
commit 6b44fccdb8
3 changed files with 29 additions and 23 deletions

View File

@ -112,27 +112,13 @@ static struct dentry *pstore_ftrace_dir;
void pstore_register_ftrace(void)
{
struct dentry *file;
if (!psinfo->write)
return;
pstore_ftrace_dir = debugfs_create_dir("pstore", NULL);
if (!pstore_ftrace_dir) {
pr_err("%s: unable to create pstore directory\n", __func__);
return;
}
file = debugfs_create_file("record_ftrace", 0600, pstore_ftrace_dir,
NULL, &pstore_knob_fops);
if (!file) {
pr_err("%s: unable to create record_ftrace file\n", __func__);
goto err_file;
}
return;
err_file:
debugfs_remove(pstore_ftrace_dir);
debugfs_create_file("record_ftrace", 0600, pstore_ftrace_dir, NULL,
&pstore_knob_fops);
}
void pstore_unregister_ftrace(void)

View File

@ -318,22 +318,21 @@ int pstore_mkfile(struct dentry *root, struct pstore_record *record)
goto fail;
inode->i_mode = S_IFREG | 0444;
inode->i_fop = &pstore_file_operations;
private = kzalloc(sizeof(*private), GFP_KERNEL);
if (!private)
goto fail_alloc;
private->record = record;
scnprintf(name, sizeof(name), "%s-%s-%llu%s",
pstore_type_to_name(record->type),
record->psi->name, record->id,
record->compressed ? ".enc.z" : "");
private = kzalloc(sizeof(*private), GFP_KERNEL);
if (!private)
goto fail_inode;
dentry = d_alloc_name(root, name);
if (!dentry)
goto fail_private;
private->record = record;
inode->i_size = private->total_size = size;
inode->i_private = private;
if (record->time.tv_sec)
@ -349,7 +348,7 @@ int pstore_mkfile(struct dentry *root, struct pstore_record *record)
fail_private:
free_pstore_private(private);
fail_alloc:
fail_inode:
iput(inode);
fail:

View File

@ -655,6 +655,7 @@ static int ramoops_parse_dt(struct platform_device *pdev,
struct ramoops_platform_data *pdata)
{
struct device_node *of_node = pdev->dev.of_node;
struct device_node *parent_node;
struct resource *res;
u32 value;
int ret;
@ -689,6 +690,26 @@ static int ramoops_parse_dt(struct platform_device *pdev,
#undef parse_size
/*
* Some old Chromebooks relied on the kernel setting the
* console_size and pmsg_size to the record size since that's
* what the downstream kernel did. These same Chromebooks had
* "ramoops" straight under the root node which isn't
* according to the current upstream bindings (though it was
* arguably acceptable under a prior version of the bindings).
* Let's make those old Chromebooks work by detecting that
* we're not a child of "reserved-memory" and mimicking the
* expected behavior.
*/
parent_node = of_get_parent(of_node);
if (!of_node_name_eq(parent_node, "reserved-memory") &&
!pdata->console_size && !pdata->ftrace_size &&
!pdata->pmsg_size && !pdata->ecc_info.ecc_size) {
pdata->console_size = pdata->record_size;
pdata->pmsg_size = pdata->record_size;
}
of_node_put(parent_node);
return 0;
}