Skip to contentSkip to conversation

for [BUG] rsa: crash in br_i32_decode() called from rsa_gen_key_prop() (Heinrich Schuchardt)

PATCH New REITHER Robert - Contractor 2 participants 2 messages Sep 9, 2020 – Sep 14, 2020

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 for [BUG] rsa: crash in br_i32_decode() called from rsa_gen_key_prop() (Heinrich Schuchardt)

Fixes problem for unaligned 32bit big-endian access in lib/rsa/rsa-keyprop.c

Exchanges br_i32_decode() with get_unaligned_be32().
This will keep the unaligned access for architectures capable and will do some byte-shift magic for the not so capable ones...

robert.reither at external.thalesgroup.com

lib/rsa/rsa-keyprop.c 2020-09-08 18:10:59.122022000 +0200 renamed from lib/rsa/rsa-keyprop.c 2020-09-07 20:17:33.000000000 +0200 +0 -0
@@ -15,6 +15,7 @@

#include <asm/byteorder.h>
#include <crypto/internal/rsa.h>
#include <u-boot/rsa-mod-exp.h>
+#include <asm/unaligned.h>
/**
* br_dec16be() - Convert 16-bit big-endian integer to native
@@ -23,7 +24,7 @@
*/
static unsigned br_dec16be(const void *src)
{
- return be16_to_cpup(src);
+ return get_unaligned_be16(src);
}
/**
@@ -33,7 +34,7 @@ static unsigned br_dec16be(const void *s
*/
static uint32_t br_dec32be(const void *src)
{
- return be32_to_cpup(src);
+ return get_unaligned_be32(src);
}
/**

#1 lore raw

PATCH 1/1 for [BUG] rsa: crash in br_i32_decode() called from rsa_gen_key_prop() (Heinrich Schuchardt)

Quoted 6 lines · REITHER Robert - Contractor

Fixes problem for unaligned 32bit big-endian access in lib/rsa/rsa-keyprop.c

Exchanges br_i32_decode() with get_unaligned_be32().
This will keep the unaligned access for architectures capable and will do some byte-shift magic for the not so capable ones...

robert.reither at external.thalesgroup.com

Hello Robert,

the solution approach looks fine but unfortunately your mail is not in patch format.

Please, add you signature when committing the patch. Format the patch with 'git format-patch'.
Check the file with 'scripts/checkpatch.pl'.
Determine the maintainers with 'scripts/get_maintainer.pl'. Send the patch with 'git send-email' to the maintainers and the list.

Best regards

Heinrich

Quoted 28 lines

*/
static unsigned br_dec16be(const void *src)
{

(quoted diff) +1 -1
-             return be16_to_cpup(src);
+            return get_unaligned_be16(src);

}
/**

(quoted diff) +1 -1
@@ -33,7 +34,7 @@ static unsigned br_dec16be(const void *s
  */
 static uint32_t br_dec32be(const void *src)
 {
-             return be32_to_cpup(src);
+            return get_unaligned_be32(src);
 }
 /**
 
lib/rsa/rsa-keyprop.c 2020-09-08 18:10:59.122022000 +0200 renamed from lib/rsa/rsa-keyprop.c 2020-09-07 20:17:33.000000000 +0200 +1 -0
@@ -15,6 +15,7 @@
 #include <asm/byteorder.h>
 #include <crypto/internal/rsa.h>
 #include <u-boot/rsa-mod-exp.h>
+#include <asm/unaligned.h>
 /**
  * br_dec16be() - Convert 16-bit big-endian integer to native
@@ -23,7 +24,7 @@