All of lore.kernel.org
 help / color / mirror / Atom feed
From: Philippe Reynes <philippe.reynes@softathome.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 3/4] cmd: aes: use map_sysmem when accessing memory
Date: Thu, 19 Sep 2019 15:39:44 +0200	[thread overview]
Message-ID: <1568900385-21957-4-git-send-email-philippe.reynes@softathome.com> (raw)
In-Reply-To: <1568900385-21957-1-git-send-email-philippe.reynes@softathome.com>

The aes command used to segfault when accessing memory in sandbox.
The pointer accesses should be mapped.

Signed-off-by: Philippe Reynes <philippe.reynes@softathome.com>
---
 cmd/aes.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/cmd/aes.c b/cmd/aes.c
index 7ff4a71..3db110c 100644
--- a/cmd/aes.c
+++ b/cmd/aes.c
@@ -11,6 +11,7 @@
 #include <malloc.h>
 #include <asm/byteorder.h>
 #include <linux/compiler.h>
+#include <mapmem.h>
 
 /**
  * do_aes() - Handle the "aes" command-line command
@@ -46,10 +47,10 @@ static int do_aes(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])
 	dst_addr = simple_strtoul(argv[5], NULL, 16);
 	len = simple_strtoul(argv[6], NULL, 16);
 
-	key_ptr = (uint8_t *)key_addr;
-	iv_ptr = (uint8_t *)iv_addr;
-	src_ptr = (uint8_t *)src_addr;
-	dst_ptr = (uint8_t *)dst_addr;
+	key_ptr = (uint8_t *)map_sysmem(key_addr, 128 / 8);
+	iv_ptr = (uint8_t *)map_sysmem(iv_addr, 128 / 8);
+	src_ptr = (uint8_t *)map_sysmem(src_addr, len);
+	dst_ptr = (uint8_t *)map_sysmem(dst_addr, len);
 
 	/* First we expand the key. */
 	aes_expand_key(key_ptr, key_exp);
-- 
2.7.4

  parent reply	other threads:[~2019-09-19 13:39 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-09-19 13:39 [U-Boot] [PATCH 0/4] pytest: add a simple test to check the command aes Philippe Reynes
2019-09-19 13:39 ` [U-Boot] [PATCH 1/4] sandbox: enable " Philippe Reynes
2019-10-21 15:25   ` Simon Glass
2019-09-19 13:39 ` [U-Boot] [PATCH 2/4] sandbox64: " Philippe Reynes
2019-09-19 13:39 ` Philippe Reynes [this message]
2019-09-19 13:39 ` [U-Boot] [PATCH 4/4] pytest: add a new test for aes Philippe Reynes

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1568900385-21957-4-git-send-email-philippe.reynes@softathome.com \
    --to=philippe.reynes@softathome.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.