lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20221206083657.3202856-1-ruanjinjie@huawei.com>
Date:   Tue, 6 Dec 2022 16:36:57 +0800
From:   ruanjinjie <ruanjinjie@...wei.com>
To:     <robh+dt@...nel.org>, <frowand.list@...il.com>,
        <devicetree@...r.kernel.org>, <linux-kernel@...r.kernel.org>
CC:     <ruanjinjie@...wei.com>
Subject: [PATCH] of: overlay: fix null pointer dereferencing in find_dup_cset_node_entry() and find_dup_cset_prop()

when kmalloc() fail to allocate memory in kasprintf(), fn_1 or fn_2 will
be NULL, strcmp() will cause null pointer dereference.

Fixes: 2fe0e8769df9 ("of: overlay: check prevents multiple fragments touching same property")
Signed-off-by: ruanjinjie <ruanjinjie@...wei.com>
---
 drivers/of/overlay.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/drivers/of/overlay.c b/drivers/of/overlay.c
index bd8ff4df723d..49c066b51148 100644
--- a/drivers/of/overlay.c
+++ b/drivers/of/overlay.c
@@ -545,6 +545,11 @@ static int find_dup_cset_node_entry(struct overlay_changeset *ovcs,
 
 		fn_1 = kasprintf(GFP_KERNEL, "%pOF", ce_1->np);
 		fn_2 = kasprintf(GFP_KERNEL, "%pOF", ce_2->np);
+		if (!fn_1 || !fn_2) {
+			kfree(fn_1);
+			kfree(fn_2);
+			return -ENOMEM;
+		}
 		node_path_match = !strcmp(fn_1, fn_2);
 		kfree(fn_1);
 		kfree(fn_2);
@@ -580,6 +585,11 @@ static int find_dup_cset_prop(struct overlay_changeset *ovcs,
 
 		fn_1 = kasprintf(GFP_KERNEL, "%pOF", ce_1->np);
 		fn_2 = kasprintf(GFP_KERNEL, "%pOF", ce_2->np);
+		if (!fn_1 || !fn_2) {
+			kfree(fn_1);
+			kfree(fn_2);
+			return -ENOMEM;
+		}
 		node_path_match = !strcmp(fn_1, fn_2);
 		kfree(fn_1);
 		kfree(fn_2);
-- 
2.25.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ