Le 04/08/2025 à 20:09, Eric Biggers a écrit :
On Mon, Aug 04, 2025 at 07:42:15PM +0200, Christophe Leroy wrote:
Le 03/08/2025 à 22:44, Eric Biggers a écrit :
MD5 is insecure, is no longer commonly used, and has never been
optimized for the most common architectures in the kernel. Only mips,
powerpc, and sparc have optimized MD5 code in the kernel. Of these,
only the powerpc one is actually testable in QEMU. The mips one works
only on Cavium Octeon SoCs.
Taken together, it's clear that it's time to retire these additional MD5
implementations, and focus maintenance on the MD5 generic C code.
Sorry, for me it is not that clear. Even if MD5 is depracated we still have
several applications that use MD5 for various reasons on our boards.
I ran the test on kernel v6.16 with following file:
# ls -l avion.au
-rw------- 1 root root 12130159 Jan 1 1970 avion.au
With CONFIG_CRYPTO_MD5_PPC:
# time md5sum avion.au
6513851d6109d42477b20cd56bf57f28 avion.au
real 0m 1.02s
user 0m 0.01s
sys 0m 1.01s
Without CONFIG_CRYPTO_MD5_PPC:
# time md5sum avion.au
6513851d6109d42477b20cd56bf57f28 avion.au
real 0m 1.35s
user 0m 0.01s
sys 0m 1.34s
I think the difference is big enough to consider keeping optimised MD5 code.
But md5sum doesn't use the kernel's MD5 code. So it's implausible that
it has any effect on md5sum. The difference you saw must be due to an
unrelated reason like I/O caching, CPU frequency, etc. Try running your
test multiple times to eliminate other sources of variation.
md5sum uses the kernel's MD5 code:
# ldd `which md5sum`
linux-vdso32.so.1 (0x77b90000)
libkcapi.so.1 => /usr/lib/libkcapi.so.1 (0x6ffa0000) <==
libcrypt.so.1 => /lib/libcrypt.so.1 (0x6ff50000)
libc.so.6 => /lib/libc.so.6 (0x6fd10000)
/lib/ld.so.1 => //lib/ld.so.1 (0x77ba0000)
Previous test was on an mpc8xx.
I now did the test on mpc832x and the difference is even bigger:
With CONFIG_CRYPTO_MD5_PPC:
# time md5sum avion.au
6513851d6109d42477b20cd56bf57f28 avion.au
real 0m 0.41s
user 0m 0.00s
sys 0m 0.34s
Without CONFIG_CRYPTO_MD5_PPC:
# time md5sum avion.au
6513851d6109d42477b20cd56bf57f28 avion.au
real 0m 0.58s
user 0m 0.00s
sys 0m 0.47s
Christophe