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>] [day] [month] [year] [list]
Message-Id: <1562317176-13317-1-git-send-email-wen.yang99@zte.com.cn>
Date:   Fri, 5 Jul 2019 16:59:36 +0800
From:   Wen Yang <wen.yang99@....com.cn>
To:     linux-kernel@...r.kernel.org
Cc:     xue.zhihong@....com.cn, wang.yi59@....com.cn,
        cheng.shengyu@....com.cn, Wen Yang <wen.yang99@....com.cn>,
        Benjamin Herrenschmidt <benh@...nel.crashing.org>,
        Paul Mackerras <paulus@...ba.org>,
        Michael Ellerman <mpe@...erman.id.au>,
        Rob Herring <robh@...nel.org>, linuxppc-dev@...ts.ozlabs.org
Subject: [PATCH] powerpc: fix use-after-free on fixup_port_irq()

There is a possible use-after-free issue in the fixup_port_irq():

460 static void __init fixup_port_irq(int index,
461                                   struct device_node *np,
462                                   struct plat_serial8250_port *port)
463 {
...
469         if (!virq && legacy_serial_infos[index].irq_check_parent) {
470                 np = of_get_parent(np);  --> modified here.
...
474                 of_node_put(np); ---> released here
475         }
...
481 #ifdef CONFIG_SERIAL_8250_FSL
482   if (of_device_is_compatible(np, "fsl,ns16550")) --> dereferenced here
...
484 #endif
485 }

We solve this problem by introducing a new parent_np variable.

Fixes: 9deaa53ac7fa ("serial: add irq handler for Freescale 16550 errata.")
Signed-off-by: Wen Yang <wen.yang99@....com.cn>
Cc: Benjamin Herrenschmidt <benh@...nel.crashing.org>
Cc: Paul Mackerras <paulus@...ba.org>
Cc: Michael Ellerman <mpe@...erman.id.au>
Cc: Rob Herring <robh@...nel.org>
Cc: linuxppc-dev@...ts.ozlabs.org
Cc: linux-kernel@...r.kernel.org
---
 arch/powerpc/kernel/legacy_serial.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/arch/powerpc/kernel/legacy_serial.c b/arch/powerpc/kernel/legacy_serial.c
index 7cea597..0105f3e 100644
--- a/arch/powerpc/kernel/legacy_serial.c
+++ b/arch/powerpc/kernel/legacy_serial.c
@@ -461,17 +461,18 @@ static void __init fixup_port_irq(int index,
 				  struct device_node *np,
 				  struct plat_serial8250_port *port)
 {
+	struct device_node *parent_np;
 	unsigned int virq;
 
 	DBG("fixup_port_irq(%d)\n", index);
 
 	virq = irq_of_parse_and_map(np, 0);
 	if (!virq && legacy_serial_infos[index].irq_check_parent) {
-		np = of_get_parent(np);
-		if (np == NULL)
+		parent_np = of_get_parent(np);
+		if (parent_np == NULL)
 			return;
-		virq = irq_of_parse_and_map(np, 0);
-		of_node_put(np);
+		virq = irq_of_parse_and_map(parent_np, 0);
+		of_node_put(parent_np);
 	}
 	if (!virq)
 		return;
-- 
2.9.5

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ