Skip to content

Commit 41cb8c3

Browse files
committed
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
2 parents a01c9fe + c8d25d6 commit 41cb8c3

File tree

5 files changed

+42
-16
lines changed

5 files changed

+42
-16
lines changed

arch/arm64/configs/defconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1616,6 +1616,7 @@ CONFIG_CONFIGFS_FS=y
16161616
CONFIG_EFIVAR_FS=y
16171617
CONFIG_UBIFS_FS=m
16181618
CONFIG_SQUASHFS=y
1619+
CONFIG_PSTORE_RAM=m
16191620
CONFIG_NFS_FS=y
16201621
CONFIG_NFS_V4=y
16211622
CONFIG_NFS_V4_1=y

drivers/firmware/efi/efi-pstore.c

Lines changed: 35 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,43 @@ static unsigned int record_size = 1024;
1414
module_param(record_size, uint, 0444);
1515
MODULE_PARM_DESC(record_size, "size of each pstore UEFI var (in bytes, min/default=1024)");
1616

17-
static bool efivars_pstore_disable =
18-
IS_ENABLED(CONFIG_EFI_VARS_PSTORE_DEFAULT_DISABLE);
19-
20-
module_param_named(pstore_disable, efivars_pstore_disable, bool, 0644);
21-
2217
#define PSTORE_EFI_ATTRIBUTES \
2318
(EFI_VARIABLE_NON_VOLATILE | \
2419
EFI_VARIABLE_BOOTSERVICE_ACCESS | \
2520
EFI_VARIABLE_RUNTIME_ACCESS)
2621

22+
static bool pstore_disable = IS_ENABLED(CONFIG_EFI_VARS_PSTORE_DEFAULT_DISABLE);
23+
24+
static int efivars_pstore_init(void);
25+
static void efivars_pstore_exit(void);
26+
27+
static int efi_pstore_disable_set(const char *val, const struct kernel_param *kp)
28+
{
29+
int err;
30+
bool old_pstore_disable = pstore_disable;
31+
32+
err = param_set_bool(val, kp);
33+
if (err)
34+
return err;
35+
36+
if (old_pstore_disable != pstore_disable) {
37+
if (pstore_disable)
38+
efivars_pstore_exit();
39+
else
40+
efivars_pstore_init();
41+
}
42+
43+
return 0;
44+
}
45+
46+
static const struct kernel_param_ops pstore_disable_ops = {
47+
.set = efi_pstore_disable_set,
48+
.get = param_get_bool,
49+
};
50+
51+
module_param_cb(pstore_disable, &pstore_disable_ops, &pstore_disable, 0644);
52+
__MODULE_PARM_TYPE(pstore_disable, "bool");
53+
2754
static int efi_pstore_open(struct pstore_info *psi)
2855
{
2956
int err;
@@ -218,12 +245,12 @@ static struct pstore_info efi_pstore_info = {
218245
.erase = efi_pstore_erase,
219246
};
220247

221-
static __init int efivars_pstore_init(void)
248+
static int efivars_pstore_init(void)
222249
{
223250
if (!efivar_supports_writes())
224251
return 0;
225252

226-
if (efivars_pstore_disable)
253+
if (pstore_disable)
227254
return 0;
228255

229256
/*
@@ -250,7 +277,7 @@ static __init int efivars_pstore_init(void)
250277
return 0;
251278
}
252279

253-
static __exit void efivars_pstore_exit(void)
280+
static void efivars_pstore_exit(void)
254281
{
255282
if (!efi_pstore_info.bufsize)
256283
return;

fs/pstore/inode.c

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,6 @@ int pstore_put_backend_records(struct pstore_info *psi)
307307
{
308308
struct pstore_private *pos, *tmp;
309309
struct dentry *root;
310-
int rc = 0;
311310

312311
root = psinfo_lock_root();
313312
if (!root)
@@ -317,19 +316,16 @@ int pstore_put_backend_records(struct pstore_info *psi)
317316
list_for_each_entry_safe(pos, tmp, &records_list, list) {
318317
if (pos->record->psi == psi) {
319318
list_del_init(&pos->list);
320-
rc = simple_unlink(d_inode(root), pos->dentry);
321-
if (WARN_ON(rc))
322-
break;
323-
d_drop(pos->dentry);
324-
dput(pos->dentry);
319+
d_invalidate(pos->dentry);
320+
simple_unlink(d_inode(root), pos->dentry);
325321
pos->dentry = NULL;
326322
}
327323
}
328324
}
329325

330326
inode_unlock(d_inode(root));
331327

332-
return rc;
328+
return 0;
333329
}
334330

335331
/*

fs/pstore/ram.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -893,6 +893,7 @@ static const struct of_device_id dt_match[] = {
893893
{ .compatible = "ramoops" },
894894
{}
895895
};
896+
MODULE_DEVICE_TABLE(of, dt_match);
896897

897898
static struct platform_driver ramoops_driver = {
898899
.probe = ramoops_probe,

fs/pstore/zone.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -973,6 +973,8 @@ static ssize_t psz_kmsg_read(struct pstore_zone *zone,
973973
char *buf = kasprintf(GFP_KERNEL, "%s: Total %d times\n",
974974
kmsg_dump_reason_str(record->reason),
975975
record->count);
976+
if (!buf)
977+
return -ENOMEM;
976978
hlen = strlen(buf);
977979
record->buf = krealloc(buf, hlen + size, GFP_KERNEL);
978980
if (!record->buf) {
@@ -1215,7 +1217,6 @@ static struct pstore_zone **psz_init_zones(enum pstore_type_id type,
12151217
pr_err("allocate for zones %s failed\n", name);
12161218
return ERR_PTR(-ENOMEM);
12171219
}
1218-
memset(zones, 0, c * sizeof(*zones));
12191220

12201221
for (i = 0; i < c; i++) {
12211222
zone = psz_init_zone(type, off, record_size);

0 commit comments

Comments
 (0)