diff options
author | Philippe Reynes <philippe.reynes@softathome.com> | 2019-09-24 11:32:29 +0200 |
---|---|---|
committer | Simon Glass <sjg@chromium.org> | 2019-10-15 08:40:03 -0600 |
commit | ed7ea058a904a0db5c007039adfa79d27da5bcde (patch) | |
tree | bb73fcccbc4f389b463871182f87f898b345f829 | |
parent | 5fff9b3bc9da677bef8b5f7b5cb4e9e12c84a7d9 (diff) | |
download | u-boot-ed7ea058a904a0db5c007039adfa79d27da5bcde.tar.gz u-boot-ed7ea058a904a0db5c007039adfa79d27da5bcde.tar.bz2 u-boot-ed7ea058a904a0db5c007039adfa79d27da5bcde.zip |
cmd: aes: use map_sysmem when accessing memory
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>
-rw-r--r-- | cmd/aes.c | 14 |
1 files changed, 10 insertions, 4 deletions
@@ -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); @@ -64,6 +65,11 @@ static int do_aes(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[]) aes_cbc_decrypt_blocks(key_exp, iv_ptr, src_ptr, dst_ptr, aes_blocks); + unmap_sysmem(key_ptr); + unmap_sysmem(iv_ptr); + unmap_sysmem(src_ptr); + unmap_sysmem(dst_ptr); + return 0; } |