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-prev] [thread-next>] [day] [month] [year] [list]
Date:   Tue, 26 Apr 2022 08:07:44 -0400 (EDT)
From:   Mikulas Patocka <mpatocka@...hat.com>
To:     Andy Shevchenko <andy.shevchenko@...il.com>
cc:     Linus Torvalds <torvalds@...ux-foundation.org>,
        Andy Shevchenko <andy@...nel.org>,
        Mimi Zohar <zohar@...ux.ibm.com>,
        device-mapper development <dm-devel@...hat.com>,
        Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
        Mike Snitzer <msnitzer@...hat.com>,
        Milan Broz <gmazyland@...il.com>
Subject: [PATCH v2] hex2bin: fix access beyond string end



On Tue, 26 Apr 2022, Andy Shevchenko wrote:

> On Sun, Apr 24, 2022 at 10:48 PM Mikulas Patocka <mpatocka@...hat.com> wrote:
> >
> > If we pass too short string to "hex2bin" (and the string size without the
> > terminating NUL character is even), "hex2bin" reads one byte after the
> > terminating NUL character. This patch fixes it.
> >
> > Signed-off-by: Mikulas Patocka <mpatocka@...hat.com>
> > Cc: stable@...r.kernel.org
> 
> You need to provide a Fixes tag.

OK. Here I resend it with the "Fixes" tag.

> And on top of that it would be nice to understand if we need to
> support half-bytes, but in any case it's not a scope of the patch
> right now.

Do you think that there are any users who need this?

> -- 
> With Best Regards,
> Andy Shevchenko

Mikulas



From: Mikulas Patocka <mpatocka@...hat.com>

If we pass too short string to "hex2bin" (and the string size without the
terminating NUL character is even), "hex2bin" reads one byte after the
terminating NUL character. This patch fixes it.

Signed-off-by: Mikulas Patocka <mpatocka@...hat.com>
Fixes: b78049831ffe ("lib: add error checking to hex2bin")
Cc: stable@...r.kernel.org

---
 lib/hexdump.c |    9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

Index: linux-2.6/lib/hexdump.c
===================================================================
--- linux-2.6.orig/lib/hexdump.c	2022-04-24 18:51:16.000000000 +0200
+++ linux-2.6/lib/hexdump.c	2022-04-24 18:51:16.000000000 +0200
@@ -45,10 +45,13 @@ EXPORT_SYMBOL(hex_to_bin);
 int hex2bin(u8 *dst, const char *src, size_t count)
 {
 	while (count--) {
-		int hi = hex_to_bin(*src++);
-		int lo = hex_to_bin(*src++);
+		int hi, lo;
 
-		if ((hi < 0) || (lo < 0))
+		hi = hex_to_bin(*src++);
+		if (hi < 0)
+			return -EINVAL;
+		lo = hex_to_bin(*src++);
+		if (lo < 0)
 			return -EINVAL;
 
 		*dst++ = (hi << 4) | lo;

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ