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]
Date:   Mon, 22 Mar 2021 19:06:22 -0700
From:   Lv Yunlong <lyl2019@...l.ustc.edu.cn>
To:     mporter@...nel.crashing.org, alex.bou9@...il.com
Cc:     linux-kernel@...r.kernel.org, Lv Yunlong <lyl2019@...l.ustc.edu.cn>
Subject: [PATCH] rapidio: Fix a use after free in mport_mm_close

In mport_mm_close, map is freed by kref_put(&map->ref,).
But mutex_unlock(&map->md->buf_mutex) uses map later.
Other thread could allocate the freed chunk and cause
an unexpected result.

My patch adds a variable buf_mutex to store the mutex before
map is freed.

Signed-off-by: Lv Yunlong <lyl2019@...l.ustc.edu.cn>
---
 drivers/rapidio/devices/rio_mport_cdev.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/rapidio/devices/rio_mport_cdev.c b/drivers/rapidio/devices/rio_mport_cdev.c
index 94331d999d27..836bcb4ab50a 100644
--- a/drivers/rapidio/devices/rio_mport_cdev.c
+++ b/drivers/rapidio/devices/rio_mport_cdev.c
@@ -2179,9 +2179,11 @@ static void mport_mm_close(struct vm_area_struct *vma)
 	struct rio_mport_mapping *map = vma->vm_private_data;
 
 	rmcd_debug(MMAP, "%pad", &map->phys_addr);
-	mutex_lock(&map->md->buf_mutex);
+	struct mutex buf_mutex = map->md->buf_mutex;
+
+	mutex_lock(&buf_mutex);
 	kref_put(&map->ref, mport_release_mapping);
-	mutex_unlock(&map->md->buf_mutex);
+	mutex_unlock(&buf_mutex);
 }
 
 static const struct vm_operations_struct vm_ops = {
-- 
2.25.1


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ