* [PATCH] pstore/ram: Add check for kstrdup
@ 2023-06-14 9:37 Jiasheng Jiang
2023-06-14 19:02 ` Kees Cook
0 siblings, 1 reply; 2+ messages in thread
From: Jiasheng Jiang @ 2023-06-14 9:37 UTC (permalink / raw)
To: keescook, tony.luck, gpiccoli
Cc: linux-hardening, linux-kernel, Jiasheng Jiang
Add check for the return value of kstrdup() and return the error
if it fails in order to avoid NULL pointer dereference.
Fixes: e163fdb3f7f8 ("pstore/ram: Regularize prz label allocation lifetime")
Signed-off-by: Jiasheng Jiang <jiasheng@iscas.ac.cn>
---
fs/pstore/ram_core.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/fs/pstore/ram_core.c b/fs/pstore/ram_core.c
index 966191d3a5ba..85aaf0fc6d7d 100644
--- a/fs/pstore/ram_core.c
+++ b/fs/pstore/ram_core.c
@@ -599,6 +599,8 @@ struct persistent_ram_zone *persistent_ram_new(phys_addr_t start, size_t size,
raw_spin_lock_init(&prz->buffer_lock);
prz->flags = flags;
prz->label = kstrdup(label, GFP_KERNEL);
+ if (!prz->label)
+ goto err;
ret = persistent_ram_buffer_map(start, size, prz, memtype);
if (ret)
--
2.25.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] pstore/ram: Add check for kstrdup
2023-06-14 9:37 [PATCH] pstore/ram: Add check for kstrdup Jiasheng Jiang
@ 2023-06-14 19:02 ` Kees Cook
0 siblings, 0 replies; 2+ messages in thread
From: Kees Cook @ 2023-06-14 19:02 UTC (permalink / raw)
To: Tony Luck, gpiccoli, jiasheng; +Cc: Kees Cook, linux-hardening, linux-kernel
On Wed, 14 Jun 2023 17:37:33 +0800, Jiasheng Jiang wrote:
> Add check for the return value of kstrdup() and return the error
> if it fails in order to avoid NULL pointer dereference.
>
>
Applied to for-next/pstore, thanks!
[1/1] pstore/ram: Add check for kstrdup
https://git.kernel.org/kees/c/d97038d5ec20
--
Kees Cook
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2023-06-14 19:02 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-06-14 9:37 [PATCH] pstore/ram: Add check for kstrdup Jiasheng Jiang
2023-06-14 19:02 ` Kees Cook
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).