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 for Android: free password hash cracker in your pocket
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Date: Thu, 21 Mar 2024 19:04:54 +0800
From: Guanrui Huang <guanrui.huang@...ux.alibaba.com>
To: maz@...nel.org
Cc: shannon.zhao@...ux.alibaba.com,
	tglx@...utronix.de,
	linux-arm-kernel@...ts.infradead.org,
	linux-kernel@...r.kernel.org,
	Guanrui Huang <guanrui.huang@...ux.alibaba.com>
Subject: [PATCH] irqchip/gic-v3-its: Fix double free on error

In its_vpe_irq_domain_alloc, when its_vpe_init() returns an error
with i > 0, its_vpe_irq_domain_free may free bitmap and vprop_page,
and then there is a double free in its_vpe_irq_domain_alloc.

Fix it by checking if bitmap is empty in its_vpe_irq_domain_alloc.
If bitmap is empty and i > 0, means that bitmap have been clear and free
in its_vpe_irq_domain_free.

Signed-off-by: Guanrui Huang <guanrui.huang@...ux.alibaba.com>
---
 drivers/irqchip/irq-gic-v3-its.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/irqchip/irq-gic-v3-its.c b/drivers/irqchip/irq-gic-v3-its.c
index fca888b36680..98a1be90caef 100644
--- a/drivers/irqchip/irq-gic-v3-its.c
+++ b/drivers/irqchip/irq-gic-v3-its.c
@@ -4562,9 +4562,14 @@ static int its_vpe_irq_domain_alloc(struct irq_domain *domain, unsigned int virq
 	}
 
 	if (err) {
-		if (i > 0)
+		if (i > 0) {
 			its_vpe_irq_domain_free(domain, virq, i);
 
+			/* bitmap and vprop_page be freed in its_vpe_irq_domain_free */
+			if (bitmap_empty(bitmap, nr_ids))
+				return err;
+		}
+
 		its_lpi_free(bitmap, base, nr_ids);
 		its_free_prop_table(vprop_page);
 	}
-- 
2.36.1


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ