[Possible bug in __gmpz_powm]

Gabriel Sturzu gabriel.sturzu at keysight.com
Tue Jan 28 16:36:14 UTC 2020

Hello there,

My name is Antonio-Gabriel Sturzu and I work for Keysight.
Recently I found some invalid reads and writes by running our ikev1 implementation with
valgrind on PowerPC hardware.
The source of the problem seems to be the mpz_powm function
for all the invalid reads and writes.
In order to be sure that the source of the invalid reads and writes is not our own software
I have written a sample test program , I ran it with valgrind on PowerPC and I have attached the output file
from valgrind.  I also ran the program with valgrind on other hardware like MIPS-64 or x86-64 and the output
file is clean. It doesn't have any invalid reads or writes.
In conclusion, the issue seems to be only on Power-Pc. The problem seems to appear when all the operands are really big numbers.
When I used a small modulo value it didn't give any invalid reads or writes. The result is correct even when I use valgrind , the same as in x86 or MIPS-64.
The compiler that I used was powerpc-750-linux-gnu-gcc version 4.2.4.
The GMP version that I used is 6.0.0.
The output from uname -a is ppc GNU/Linux 2.6.7.
The output from running ./config.guess is coreihwl-unknown-linux-gnu.
The output from running ./configfsf.guess is x86_64-unknown-linux-gnu.
The configure summary build options from running ./configure are :

  Version:           GNU MP 6.0.0
  Host type:         coreihwl-unknown-linux-gnu
  ABI:               64
  Install prefix:    /usr/local
  Compiler:          gcc
  Static libraries:  yes
  Shared libraries:  yes

After compiling and linking with the PowerPC gmp library you just run ./executable_name. You don't need anything else.
I hope you have enough information to see if this is a real bug or not.

                                                                     Best regards,
                                                                               Antonio -Gabriel Sturzu

-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: gmp.c
URL: <https://gmplib.org/list-archives/gmp-bugs/attachments/20200128/604c4268/attachment.c>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: memcheck-power-pc.txt
URL: <https://gmplib.org/list-archives/gmp-bugs/attachments/20200128/604c4268/attachment.txt>

More information about the gmp-bugs mailing list