pstore updates for v6.9-rc1

- Make PSTORE_RAM available by default on arm64 (Nícolas F. R. A. Prado)
 
 - Allow for dynamic initialization in modular build (Guilherme G. Piccoli)
 
 - Add missing allocation failure check (Kunwu Chan)
 
 - Avoid duplicate memory zeroing (Christophe JAILLET)
 
 - Avoid potential double-free during pstorefs umount
 -----BEGIN PGP SIGNATURE-----
 
 iQJKBAABCgA0FiEEpcP2jyKd1g9yPm4TiXL039xtwCYFAmXvlFsWHGtlZXNjb29r
 QGNocm9taXVtLm9yZwAKCRCJcvTf3G3AJiR3D/0XGJYNL/jv5aF4J1Bsb21k7Hk0
 hfJYzYpQxvV4sNr7U91ELAYlS/V8Sm3s5qna/MyyQVcLHPAqE89yM6RTDlDMYbXr
 fgJgwYbsQEu0zvBgMSYQFkS9UQ1/Pj8gxteOIIHAepuCjDKMQgSbfQOOZ8R/8o73
 LuR8tVIlSW8JnUxDrrTHn8Mkn07HOInWTfmaA8HypdMOF3Rs0baDdABGB5CXAHan
 /a8VkazN9IDtGFJk9HB3tmwlSdzDF4at2bhwAgfQcisb2fhAbKN6n6jRW3564XNE
 5JH50JBJcE8Zc1RpbD4XT5ClqXPj9BvOLgbGAcbgZbmjuqxdQcDMJ1IwAmIsIHTG
 fT/6/MN4m5uuc7tik1Y3igpkiYiNr0itcOBI6iyT70Hj5p0IRR3DYxtV47RQsb5j
 1jBI6vtcmrwzOP8tKdrPlZ4iUl+wm7d5UjHleQZjpST3Rtm3an/TEuU3C7xVWKDf
 +LAb+vIao071L2JzNLwEKHAIEtcV9vtsM9I4ApoeC9gh80pW+OdfwfqiEkK3+Ht3
 Sk7u6ez45SDlJtx1amE+kA7qbaFEZxSDerWQ32pqb7bzrKWEtdFATdYL6eBPJItm
 V1c+I4fYv6udjUH1igwNUKWsxLgQ0KvRv1AtvrBtgfTrq2WuuplTxPbh1l+jGt/4
 nbu9FVNKLErrGGkK3Q==
 =xe9R
 -----END PGP SIGNATURE-----

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

Pull pstore updates from Kees Cook:

 - Make PSTORE_RAM available by default on arm64 (Nícolas F R A Prado)

 - Allow for dynamic initialization in modular build (Guilherme G
   Piccoli)

 - Add missing allocation failure check (Kunwu Chan)

 - Avoid duplicate memory zeroing (Christophe JAILLET)

 - Avoid potential double-free during pstorefs umount

* tag 'pstore-v6.9-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/kees/linux:
  pstore/zone: Don't clear memory twice
  pstore/zone: Add a null pointer check to the psz_kmsg_read
  efi: pstore: Allow dynamic initialization based on module parameter
  arm64: defconfig: Enable PSTORE_RAM
  pstore/ram: Register to module device table
  pstore: inode: Only d_invalidate() is needed
This commit is contained in:
Linus Torvalds 2024-03-12 14:36:18 -07:00
commit 41cb8c332b
5 changed files with 42 additions and 16 deletions

View File

@ -1616,6 +1616,7 @@ CONFIG_CONFIGFS_FS=y
CONFIG_EFIVAR_FS=y
CONFIG_UBIFS_FS=m
CONFIG_SQUASHFS=y
CONFIG_PSTORE_RAM=m
CONFIG_NFS_FS=y
CONFIG_NFS_V4=y
CONFIG_NFS_V4_1=y

View File

@ -14,16 +14,43 @@ static unsigned int record_size = 1024;
module_param(record_size, uint, 0444);
MODULE_PARM_DESC(record_size, "size of each pstore UEFI var (in bytes, min/default=1024)");
static bool efivars_pstore_disable =
IS_ENABLED(CONFIG_EFI_VARS_PSTORE_DEFAULT_DISABLE);
module_param_named(pstore_disable, efivars_pstore_disable, bool, 0644);
#define PSTORE_EFI_ATTRIBUTES \
(EFI_VARIABLE_NON_VOLATILE | \
EFI_VARIABLE_BOOTSERVICE_ACCESS | \
EFI_VARIABLE_RUNTIME_ACCESS)
static bool pstore_disable = IS_ENABLED(CONFIG_EFI_VARS_PSTORE_DEFAULT_DISABLE);
static int efivars_pstore_init(void);
static void efivars_pstore_exit(void);
static int efi_pstore_disable_set(const char *val, const struct kernel_param *kp)
{
int err;
bool old_pstore_disable = pstore_disable;
err = param_set_bool(val, kp);
if (err)
return err;
if (old_pstore_disable != pstore_disable) {
if (pstore_disable)
efivars_pstore_exit();
else
efivars_pstore_init();
}
return 0;
}
static const struct kernel_param_ops pstore_disable_ops = {
.set = efi_pstore_disable_set,
.get = param_get_bool,
};
module_param_cb(pstore_disable, &pstore_disable_ops, &pstore_disable, 0644);
__MODULE_PARM_TYPE(pstore_disable, "bool");
static int efi_pstore_open(struct pstore_info *psi)
{
int err;
@ -218,12 +245,12 @@ static struct pstore_info efi_pstore_info = {
.erase = efi_pstore_erase,
};
static __init int efivars_pstore_init(void)
static int efivars_pstore_init(void)
{
if (!efivar_supports_writes())
return 0;
if (efivars_pstore_disable)
if (pstore_disable)
return 0;
/*
@ -250,7 +277,7 @@ static __init int efivars_pstore_init(void)
return 0;
}
static __exit void efivars_pstore_exit(void)
static void efivars_pstore_exit(void)
{
if (!efi_pstore_info.bufsize)
return;

View File

@ -307,7 +307,6 @@ int pstore_put_backend_records(struct pstore_info *psi)
{
struct pstore_private *pos, *tmp;
struct dentry *root;
int rc = 0;
root = psinfo_lock_root();
if (!root)
@ -317,11 +316,8 @@ int pstore_put_backend_records(struct pstore_info *psi)
list_for_each_entry_safe(pos, tmp, &records_list, list) {
if (pos->record->psi == psi) {
list_del_init(&pos->list);
rc = simple_unlink(d_inode(root), pos->dentry);
if (WARN_ON(rc))
break;
d_drop(pos->dentry);
dput(pos->dentry);
d_invalidate(pos->dentry);
simple_unlink(d_inode(root), pos->dentry);
pos->dentry = NULL;
}
}
@ -329,7 +325,7 @@ int pstore_put_backend_records(struct pstore_info *psi)
inode_unlock(d_inode(root));
return rc;
return 0;
}
/*

View File

@ -893,6 +893,7 @@ static const struct of_device_id dt_match[] = {
{ .compatible = "ramoops" },
{}
};
MODULE_DEVICE_TABLE(of, dt_match);
static struct platform_driver ramoops_driver = {
.probe = ramoops_probe,

View File

@ -973,6 +973,8 @@ static ssize_t psz_kmsg_read(struct pstore_zone *zone,
char *buf = kasprintf(GFP_KERNEL, "%s: Total %d times\n",
kmsg_dump_reason_str(record->reason),
record->count);
if (!buf)
return -ENOMEM;
hlen = strlen(buf);
record->buf = krealloc(buf, hlen + size, GFP_KERNEL);
if (!record->buf) {
@ -1215,7 +1217,6 @@ static struct pstore_zone **psz_init_zones(enum pstore_type_id type,
pr_err("allocate for zones %s failed\n", name);
return ERR_PTR(-ENOMEM);
}
memset(zones, 0, c * sizeof(*zones));
for (i = 0; i < c; i++) {
zone = psz_init_zone(type, off, record_size);