Home GnuPG

mceliece6688128f: fix UBSAN runtime errors

Description

mceliece6688128f: fix UBSAN runtime errors

* cipher/mceliece6688128f.c (cbrecursion): Fix left shift of signed integer
by too many places, by casting to unsigned integer before shift.
(syndrome): Fix misaligned memory loads by using 'bufhelp.h'.

There was multiple undefined behaviour sanitizer warnings with mceliece668128f
which have been fixed by this commit:

$ tests/t-kem
../../cipher/mceliece6688128f.c:1766:37: runtime error: left shift of 73010 by 16 places cannot be represented in type 'int'
../../cipher/mceliece6688128f.c:1769:37: runtime error: left shift of 71034 by 16 places cannot be represented in type 'int'
../../cipher/mceliece6688128f.c:1792:39: runtime error: left shift of 72996 by 16 places cannot be represented in type 'int'
../../cipher/mceliece6688128f.c:1800:41: runtime error: left shift of 71344 by 16 places cannot be represented in type 'int'
../../cipher/mceliece6688128f.c:1807:43: runtime error: left shift of 68334 by 16 places cannot be represented in type 'int'
../../cipher/mceliece6688128f.c:1834:23: runtime error: left shift of 72247 by 16 places cannot be represented in type 'int'
../../cipher/mceliece6688128f.c:1833:19: runtime error: left shift of 136871 by 16 places cannot be represented in type 'int'
../../cipher/mceliece6688128f.c:1781:41: runtime error: left shift of 66551 by 20 places cannot be represented in type 'int'
../../cipher/mceliece6688128f.c:2261:15: runtime error: load of misaligned address 0x7ffd13d3ad84 for type 'const uint64_t', which requires 8 byte alignment
0x7ffd13d3ad84: note: pointer points here
  d8 7f e7 3c 61 1d b1 60  68 9b ff 4e 95 da 54 31  4b ca b9 7f e2 3b 06 a5  51 e3 7f 74 14 99 81 44
              ^

t-kem: 70 tests done

  • Signed-off-by: Jussi Kivilinna <jussi.kivilinna@iki.fi>

Details

Provenance
jukiviliAuthored on Mon, Sep 22, 7:34 AM
Parents
rC5c9ce0cc51d9: configure.ac: perform RISC-V vector crypto intrinsics bug checks without LTO
Branches
Unknown
Tags
Unknown