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]
Message-Id: <20230203084302.589017-1-zyytlz.wz@163.com>
Date:   Fri,  3 Feb 2023 16:43:02 +0800
From:   Zheng Wang <zyytlz.wz@....com>
To:     tianjia.zhang@...ux.alibaba.com
Cc:     linux-kernel@...r.kernel.org, hackerzheng666@...il.com,
        alex000young@...il.com, Zheng Wang <zyytlz.wz@....com>
Subject: [PATCH] lib/mpi: Fix poential NULL pointer dereference in mpi_fdiv_q

in lib/mpi, there is multiple function that not check the return
value of mpi_alloc. One case is mpi_fdiv_q, if tmp == NULL,
tmp->nlimbs in mpi_fdiv_qr will cause NULL pointer dereference.
As the code is too much, here I only fix one of them. Other
function like mpi_barrett_init mpi_copy mpi_alloc_like mpi_set
mpi_set_ui mpi_alloc_set_ui has the same problem.

Please let me know if there is a better way to fix the
problem.

Note that, as a bug found by static analysis, it can be a false
positive or hard to trigger.

Fixes: a8ea8bdd9df9 ("lib/mpi: Extend the MPI library")
Signed-off-by: Zheng Wang <zyytlz.wz@....com>
---
 lib/mpi/mpi-div.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/lib/mpi/mpi-div.c b/lib/mpi/mpi-div.c
index 45beab8b9e9e..e8642265d7d4 100644
--- a/lib/mpi/mpi-div.c
+++ b/lib/mpi/mpi-div.c
@@ -43,7 +43,8 @@ void mpi_fdiv_r(MPI rem, MPI dividend, MPI divisor)
 void mpi_fdiv_q(MPI quot, MPI dividend, MPI divisor)
 {
 	MPI tmp = mpi_alloc(mpi_get_nlimbs(quot));
-	mpi_fdiv_qr(quot, tmp, dividend, divisor);
+	if (tmp)
+		mpi_fdiv_qr(quot, tmp, dividend, divisor);
 	mpi_free(tmp);
 }
 
-- 
2.25.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ