Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/crypto/aes/arch/arm arm/aes_neon: Fix formatting of self...



details:   https://anonhg.NetBSD.org/src/rev/811b433ca5a4
branches:  trunk
changeset: 368167:811b433ca5a4
user:      riastradh <riastradh%NetBSD.org@localhost>
date:      Sun Jun 26 17:52:54 2022 +0000

description:
arm/aes_neon: Fix formatting of self-test failure message.

Discovered by code inspection.  Remarkably, a combination of errors
made this fail to be a stack buffer overrun.  Verified by booting
with ARMv8.0-AES disabled and with the self-test artificially made to
fail.

diffstat:

 sys/crypto/aes/arch/arm/aes_neon_subr.c |  8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)

diffs (32 lines):

diff -r 686d97ad257e -r 811b433ca5a4 sys/crypto/aes/arch/arm/aes_neon_subr.c
--- a/sys/crypto/aes/arch/arm/aes_neon_subr.c   Sun Jun 26 14:37:12 2022 +0000
+++ b/sys/crypto/aes/arch/arm/aes_neon_subr.c   Sun Jun 26 17:52:54 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: aes_neon_subr.c,v 1.7 2020/08/09 02:48:38 riastradh Exp $      */
+/*     $NetBSD: aes_neon_subr.c,v 1.8 2022/06/26 17:52:54 riastradh Exp $      */
 
 /*-
  * Copyright (c) 2020 The NetBSD Foundation, Inc.
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(1, "$NetBSD: aes_neon_subr.c,v 1.7 2020/08/09 02:48:38 riastradh Exp $");
+__KERNEL_RCSID(1, "$NetBSD: aes_neon_subr.c,v 1.8 2022/06/26 17:52:54 riastradh Exp $");
 
 #ifdef _KERNEL
 #include <sys/systm.h>
@@ -183,11 +183,11 @@
        for (i = 0; i < sizeof(cases)/sizeof(cases[0]); i++) {
                storeblock(t, aes_neon_xts_update(loadblock(cases[i].in)));
                if (memcmp(t, cases[i].out, 16)) {
-                       char buf[33];
+                       char buf[3*16 + 1];
                        unsigned j;
 
                        for (j = 0; j < 16; j++) {
-                               snprintf(buf + 2*j, sizeof(buf) - 2*j,
+                               snprintf(buf + 3*j, sizeof(buf) - 3*j,
                                    " %02hhx", t[j]);
                        }
                        printf("%s %u: %s\n", __func__, i, buf);



Home | Main Index | Thread Index | Old Index