Skip to content

Commit 22beaf1

Browse files
committed
Merge: pstore/platform: Add check for kstrdup
MR: https://gitlab.com/redhat/centos-stream/src/kernel/centos-stream-9/-/merge_requests/4322 JIRA: https://issues.redhat.com/browse/RHEL-38128 CVE: CVE-2023-52869 Build Info: https://brewweb.engineering.redhat.com/brew/taskinfo?taskID=61487181 Tested: Did sanity boot testing Intel (intel-arrowlake-s-02) system. commit a19d48f Author: Jiasheng Jiang <jiasheng@iscas.ac.cn> Date: Fri Jun 23 10:27:06 2023 +0800 pstore/platform: Add check for kstrdup Add check for the return value of kstrdup() and return the error if it fails in order to avoid NULL pointer dereference. Fixes: 563ca40 ("pstore/platform: Switch pstore_info::name to const") Signed-off-by: Jiasheng Jiang <jiasheng@iscas.ac.cn> Link: https://lore.kernel.org/r/20230623022706.32125-1-jiasheng@iscas.ac.cn Signed-off-by: Kees Cook <keescook@chromium.org> Signed-off-by: Steve Best <sbest@redhat.com> Approved-by: Lenny Szubowicz <lszubowi@redhat.com> Approved-by: Tony Camuso <tcamuso@redhat.com> Approved-by: David Arcari <darcari@redhat.com> Approved-by: CKI KWF Bot <cki-ci-bot+kwf-gitlab-com@redhat.com> Merged-by: Lucas Zampieri <lzampier@redhat.com>
2 parents b21c362 + b06ab30 commit 22beaf1

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

fs/pstore/platform.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -561,6 +561,8 @@ static int pstore_write_user_compat(struct pstore_record *record,
561561
*/
562562
int pstore_register(struct pstore_info *psi)
563563
{
564+
char *new_backend;
565+
564566
if (backend && strcmp(backend, psi->name)) {
565567
pr_warn("ignoring unexpected backend '%s'\n", psi->name);
566568
return -EPERM;
@@ -580,11 +582,16 @@ int pstore_register(struct pstore_info *psi)
580582
return -EINVAL;
581583
}
582584

585+
new_backend = kstrdup(psi->name, GFP_KERNEL);
586+
if (!new_backend)
587+
return -ENOMEM;
588+
583589
mutex_lock(&psinfo_lock);
584590
if (psinfo) {
585591
pr_warn("backend '%s' already loaded: ignoring '%s'\n",
586592
psinfo->name, psi->name);
587593
mutex_unlock(&psinfo_lock);
594+
kfree(new_backend);
588595
return -EBUSY;
589596
}
590597

@@ -617,7 +624,7 @@ int pstore_register(struct pstore_info *psi)
617624
* Update the module parameter backend, so it is visible
618625
* through /sys/module/pstore/parameters/backend
619626
*/
620-
backend = kstrdup(psi->name, GFP_KERNEL);
627+
backend = new_backend;
621628

622629
pr_info("Registered %s as persistent store backend\n", psi->name);
623630

0 commit comments

Comments
 (0)