netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH bpf-next 0/6] Error handling when map lookup isn't supported
@ 2018-10-09  1:04 Prashant Bhole
  2018-10-09  1:04 ` [PATCH bpf-next 1/6] bpf: error handling when map_lookup_elem " Prashant Bhole
                   ` (6 more replies)
  0 siblings, 7 replies; 16+ messages in thread
From: Prashant Bhole @ 2018-10-09  1:04 UTC (permalink / raw)
  To: Alexei Starovoitov, Daniel Borkmann
  Cc: Prashant Bhole, Jakub Kicinski, David S . Miller, Quentin Monnet, netdev

Currently when map a lookup fails, user space API can not make any
distinction whether given key was not found or lookup is not supported
by particular map.

In this series we modify return value of maps which do not support
lookup. Lookup on such map implementation will return -EOPNOTSUPP.
bpf() syscall with BPF_MAP_LOOKUP_ELEM command will set EOPNOTSUPP
errno. We also handle this error in bpftool to print appropriate
message.

Patch 1: adds handling of BPF_MAP_LOOKUP ELEM command of bpf syscall
such that errno will set to EOPNOTSUPP when map doesn't support lookup

Patch 2: Modifies the return value of map_lookup_elem() to EOPNOTSUPP
for maps which do not support lookup

Patch 3: Splits do_dump() in bpftool/map.c. Element printing code is
moved out into new function dump_map_elem(). This was done in order to
reduce deep indentation and accomodate further changes.

Patch 4: Changes in bpftool to print strerror() message when lookup
error is occured. This will result in appropriate message like
"Operation not supported" when map doesn't support lookup.

Patch 5: test_verifier: change fixup map naming convention as
suggested by Alexei

Patch 6: Added verifier tests to check whether verifier rejects call 
to bpf_map_lookup_elem from bpf program. For all map types those
do not support map lookup.

Prashant Bhole (6):
  bpf: error handling when map_lookup_elem isn't supported
  bpf: return EOPNOTSUPP when map lookup isn't supported
  tools/bpf: bpftool, split the function do_dump()
  tools/bpf: bpftool, print strerror when map lookup error occurs
  selftests/bpf: test_verifier, change names of fixup maps
  selftests/bpf: test_verifier, check bpf_map_lookup_elem access in bpf
    prog

 kernel/bpf/arraymap.c                       |   2 +-
 kernel/bpf/sockmap.c                        |   2 +-
 kernel/bpf/stackmap.c                       |   2 +-
 kernel/bpf/syscall.c                        |   9 +-
 kernel/bpf/xskmap.c                         |   2 +-
 tools/bpf/bpftool/map.c                     | 102 ++--
 tools/testing/selftests/bpf/test_verifier.c | 501 ++++++++++++--------
 7 files changed, 389 insertions(+), 231 deletions(-)

-- 
2.17.1

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [PATCH bpf-next 1/6] bpf: error handling when map_lookup_elem isn't supported
  2018-10-09  1:04 [PATCH bpf-next 0/6] Error handling when map lookup isn't supported Prashant Bhole
@ 2018-10-09  1:04 ` Prashant Bhole
  2018-10-09  6:57   ` Song Liu
  2018-10-09  1:04 ` [PATCH bpf-next 2/6] bpf: return EOPNOTSUPP when map lookup " Prashant Bhole
                   ` (5 subsequent siblings)
  6 siblings, 1 reply; 16+ messages in thread
From: Prashant Bhole @ 2018-10-09  1:04 UTC (permalink / raw)
  To: Alexei Starovoitov, Daniel Borkmann
  Cc: Prashant Bhole, Jakub Kicinski, David S . Miller, Quentin Monnet, netdev

The error value returned by map_lookup_elem doesn't differentiate
whether lookup was failed because of invalid key or lookup is not
supported.

Lets add handling for -EOPNOTSUPP return value of map_lookup_elem()
method of map, with expectation from map's implementation that it
should return -EOPNOTSUPP if lookup is not supported.

The errno for bpf syscall for BPF_MAP_LOOKUP_ELEM command will be set
to EOPNOTSUPP if map lookup is not supported.

Signed-off-by: Prashant Bhole <bhole_prashant_q7@lab.ntt.co.jp>
Acked-by: Alexei Starovoitov <ast@kernel.org>
---
 kernel/bpf/syscall.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/kernel/bpf/syscall.c b/kernel/bpf/syscall.c
index 5742df21598c..4f416234251f 100644
--- a/kernel/bpf/syscall.c
+++ b/kernel/bpf/syscall.c
@@ -719,10 +719,15 @@ static int map_lookup_elem(union bpf_attr *attr)
 	} else {
 		rcu_read_lock();
 		ptr = map->ops->map_lookup_elem(map, key);
-		if (ptr)
+		if (IS_ERR(ptr)) {
+			err = PTR_ERR(ptr);
+		} else if (!ptr) {
+			err = -ENOENT;
+		} else {
+			err = 0;
 			memcpy(value, ptr, value_size);
+		}
 		rcu_read_unlock();
-		err = ptr ? 0 : -ENOENT;
 	}
 
 	if (err)
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH bpf-next 2/6] bpf: return EOPNOTSUPP when map lookup isn't supported
  2018-10-09  1:04 [PATCH bpf-next 0/6] Error handling when map lookup isn't supported Prashant Bhole
  2018-10-09  1:04 ` [PATCH bpf-next 1/6] bpf: error handling when map_lookup_elem " Prashant Bhole
@ 2018-10-09  1:04 ` Prashant Bhole
  2018-10-09  6:58   ` Song Liu
  2018-10-09  1:04 ` [PATCH bpf-next 3/6] tools/bpf: bpftool, split the function do_dump() Prashant Bhole
                   ` (4 subsequent siblings)
  6 siblings, 1 reply; 16+ messages in thread
From: Prashant Bhole @ 2018-10-09  1:04 UTC (permalink / raw)
  To: Alexei Starovoitov, Daniel Borkmann
  Cc: Prashant Bhole, Jakub Kicinski, David S . Miller, Quentin Monnet, netdev

Return ERR_PTR(-EOPNOTSUPP) from map_lookup_elem() methods of below
map types:
- BPF_MAP_TYPE_PROG_ARRAY
- BPF_MAP_TYPE_STACK_TRACE
- BPF_MAP_TYPE_XSKMAP
- BPF_MAP_TYPE_SOCKMAP/BPF_MAP_TYPE_SOCKHASH

Signed-off-by: Prashant Bhole <bhole_prashant_q7@lab.ntt.co.jp>
Acked-by: Alexei Starovoitov <ast@kernel.org>
---
 kernel/bpf/arraymap.c | 2 +-
 kernel/bpf/sockmap.c  | 2 +-
 kernel/bpf/stackmap.c | 2 +-
 kernel/bpf/xskmap.c   | 2 +-
 4 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/kernel/bpf/arraymap.c b/kernel/bpf/arraymap.c
index dded84cbe814..24583da9ffd1 100644
--- a/kernel/bpf/arraymap.c
+++ b/kernel/bpf/arraymap.c
@@ -449,7 +449,7 @@ static void fd_array_map_free(struct bpf_map *map)
 
 static void *fd_array_map_lookup_elem(struct bpf_map *map, void *key)
 {
-	return NULL;
+	return ERR_PTR(-EOPNOTSUPP);
 }
 
 /* only called from syscall */
diff --git a/kernel/bpf/sockmap.c b/kernel/bpf/sockmap.c
index d37a1a0a6e1e..5d0677d808ae 100644
--- a/kernel/bpf/sockmap.c
+++ b/kernel/bpf/sockmap.c
@@ -2096,7 +2096,7 @@ int sockmap_get_from_fd(const union bpf_attr *attr, int type,
 
 static void *sock_map_lookup(struct bpf_map *map, void *key)
 {
-	return NULL;
+	return ERR_PTR(-EOPNOTSUPP);
 }
 
 static int sock_map_update_elem(struct bpf_map *map,
diff --git a/kernel/bpf/stackmap.c b/kernel/bpf/stackmap.c
index 8061a439ef18..b2ade10f7ec3 100644
--- a/kernel/bpf/stackmap.c
+++ b/kernel/bpf/stackmap.c
@@ -505,7 +505,7 @@ const struct bpf_func_proto bpf_get_stack_proto = {
 /* Called from eBPF program */
 static void *stack_map_lookup_elem(struct bpf_map *map, void *key)
 {
-	return NULL;
+	return ERR_PTR(-EOPNOTSUPP);
 }
 
 /* Called from syscall */
diff --git a/kernel/bpf/xskmap.c b/kernel/bpf/xskmap.c
index 9f8463afda9c..ef0b7b6ef8a5 100644
--- a/kernel/bpf/xskmap.c
+++ b/kernel/bpf/xskmap.c
@@ -154,7 +154,7 @@ void __xsk_map_flush(struct bpf_map *map)
 
 static void *xsk_map_lookup_elem(struct bpf_map *map, void *key)
 {
-	return NULL;
+	return ERR_PTR(-EOPNOTSUPP);
 }
 
 static int xsk_map_update_elem(struct bpf_map *map, void *key, void *value,
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH bpf-next 3/6] tools/bpf: bpftool, split the function do_dump()
  2018-10-09  1:04 [PATCH bpf-next 0/6] Error handling when map lookup isn't supported Prashant Bhole
  2018-10-09  1:04 ` [PATCH bpf-next 1/6] bpf: error handling when map_lookup_elem " Prashant Bhole
  2018-10-09  1:04 ` [PATCH bpf-next 2/6] bpf: return EOPNOTSUPP when map lookup " Prashant Bhole
@ 2018-10-09  1:04 ` Prashant Bhole
  2018-10-09  6:58   ` Song Liu
  2018-10-09  1:04 ` [PATCH bpf-next 4/6] tools/bpf: bpftool, print strerror when map lookup error occurs Prashant Bhole
                   ` (3 subsequent siblings)
  6 siblings, 1 reply; 16+ messages in thread
From: Prashant Bhole @ 2018-10-09  1:04 UTC (permalink / raw)
  To: Alexei Starovoitov, Daniel Borkmann
  Cc: Prashant Bhole, Jakub Kicinski, David S . Miller, Quentin Monnet, netdev

do_dump() function in bpftool/map.c has deep indentations. In order
to reduce deep indent, let's move element printing code out of
do_dump() into dump_map_elem() function.

Signed-off-by: Prashant Bhole <bhole_prashant_q7@lab.ntt.co.jp>
Acked-by: Jakub Kicinski <jakub.kicinski@netronome.com>
Acked-by: Alexei Starovoitov <ast@kernel.org>
---
 tools/bpf/bpftool/map.c | 83 ++++++++++++++++++++++++-----------------
 1 file changed, 49 insertions(+), 34 deletions(-)

diff --git a/tools/bpf/bpftool/map.c b/tools/bpf/bpftool/map.c
index 6003e9598973..28d365435fea 100644
--- a/tools/bpf/bpftool/map.c
+++ b/tools/bpf/bpftool/map.c
@@ -658,6 +658,54 @@ static int do_show(int argc, char **argv)
 	return errno == ENOENT ? 0 : -1;
 }
 
+static int dump_map_elem(int fd, void *key, void *value,
+			 struct bpf_map_info *map_info, struct btf *btf,
+			 json_writer_t *btf_wtr)
+{
+	int num_elems = 0;
+
+	if (!bpf_map_lookup_elem(fd, key, value)) {
+		if (json_output) {
+			print_entry_json(map_info, key, value, btf);
+		} else {
+			if (btf) {
+				struct btf_dumper d = {
+					.btf = btf,
+					.jw = btf_wtr,
+					.is_plain_text = true,
+				};
+
+				do_dump_btf(&d, map_info, key, value);
+			} else {
+				print_entry_plain(map_info, key, value);
+			}
+			num_elems++;
+		}
+		return num_elems;
+	}
+
+	/* lookup error handling */
+	if (map_is_map_of_maps(map_info->type) ||
+	    map_is_map_of_progs(map_info->type))
+		return 0;
+
+	if (json_output) {
+		jsonw_name(json_wtr, "key");
+		print_hex_data_json(key, map_info->key_size);
+		jsonw_name(json_wtr, "value");
+		jsonw_start_object(json_wtr);
+		jsonw_string_field(json_wtr, "error",
+				   "can't lookup element");
+		jsonw_end_object(json_wtr);
+	} else {
+		p_info("can't lookup element with key: ");
+		fprint_hex(stderr, key, map_info->key_size, " ");
+		fprintf(stderr, "\n");
+	}
+
+	return 0;
+}
+
 static int do_dump(int argc, char **argv)
 {
 	struct bpf_map_info info = {};
@@ -713,40 +761,7 @@ static int do_dump(int argc, char **argv)
 				err = 0;
 			break;
 		}
-
-		if (!bpf_map_lookup_elem(fd, key, value)) {
-			if (json_output)
-				print_entry_json(&info, key, value, btf);
-			else
-				if (btf) {
-					struct btf_dumper d = {
-						.btf = btf,
-						.jw = btf_wtr,
-						.is_plain_text = true,
-					};
-
-					do_dump_btf(&d, &info, key, value);
-				} else {
-					print_entry_plain(&info, key, value);
-				}
-			num_elems++;
-		} else if (!map_is_map_of_maps(info.type) &&
-			   !map_is_map_of_progs(info.type)) {
-			if (json_output) {
-				jsonw_name(json_wtr, "key");
-				print_hex_data_json(key, info.key_size);
-				jsonw_name(json_wtr, "value");
-				jsonw_start_object(json_wtr);
-				jsonw_string_field(json_wtr, "error",
-						   "can't lookup element");
-				jsonw_end_object(json_wtr);
-			} else {
-				p_info("can't lookup element with key: ");
-				fprint_hex(stderr, key, info.key_size, " ");
-				fprintf(stderr, "\n");
-			}
-		}
-
+		num_elems += dump_map_elem(fd, key, value, &info, btf, btf_wtr);
 		prev_key = key;
 	}
 
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH bpf-next 4/6] tools/bpf: bpftool, print strerror when map lookup error occurs
  2018-10-09  1:04 [PATCH bpf-next 0/6] Error handling when map lookup isn't supported Prashant Bhole
                   ` (2 preceding siblings ...)
  2018-10-09  1:04 ` [PATCH bpf-next 3/6] tools/bpf: bpftool, split the function do_dump() Prashant Bhole
@ 2018-10-09  1:04 ` Prashant Bhole
  2018-10-09  7:00   ` Song Liu
  2018-10-09  1:04 ` [PATCH bpf-next 5/6] selftests/bpf: test_verifier, change names of fixup maps Prashant Bhole
                   ` (2 subsequent siblings)
  6 siblings, 1 reply; 16+ messages in thread
From: Prashant Bhole @ 2018-10-09  1:04 UTC (permalink / raw)
  To: Alexei Starovoitov, Daniel Borkmann
  Cc: Prashant Bhole, Jakub Kicinski, David S . Miller, Quentin Monnet, netdev

Since map lookup error can be ENOENT or EOPNOTSUPP, let's print
strerror() as error message in normal and JSON output.

This patch adds helper function print_entry_error() to print
entry from lookup error occurs

Example: Following example dumps a map which does not support lookup.

Output before:
root# bpftool map -jp dump id 40
[
    "key": ["0x0a","0x00","0x00","0x00"
    ],
    "value": {
        "error": "can\'t lookup element"
    },
    "key": ["0x0b","0x00","0x00","0x00"
    ],
    "value": {
        "error": "can\'t lookup element"
    }
]

root# bpftool map dump id 40
can't lookup element with key:
0a 00 00 00
can't lookup element with key:
0b 00 00 00
Found 0 elements

Output after changes:
root# bpftool map dump -jp  id 45
[
    "key": ["0x0a","0x00","0x00","0x00"
    ],
    "value": {
        "error": "Operation not supported"
    },
    "key": ["0x0b","0x00","0x00","0x00"
    ],
    "value": {
        "error": "Operation not supported"
    }
]

root# bpftool map dump id 45
key:
0a 00 00 00
value:
Operation not supported
key:
0b 00 00 00
value:
Operation not supported
Found 0 elements

Signed-off-by: Prashant Bhole <bhole_prashant_q7@lab.ntt.co.jp>
Acked-by: Jakub Kicinski <jakub.kicinski@netronome.com>
Acked-by: Alexei Starovoitov <ast@kernel.org>
---
 tools/bpf/bpftool/map.c | 29 ++++++++++++++++++++++++-----
 1 file changed, 24 insertions(+), 5 deletions(-)

diff --git a/tools/bpf/bpftool/map.c b/tools/bpf/bpftool/map.c
index 28d365435fea..9f5de48f8a99 100644
--- a/tools/bpf/bpftool/map.c
+++ b/tools/bpf/bpftool/map.c
@@ -336,6 +336,25 @@ static void print_entry_json(struct bpf_map_info *info, unsigned char *key,
 	jsonw_end_object(json_wtr);
 }
 
+static void print_entry_error(struct bpf_map_info *info, unsigned char *key,
+			      const char *value)
+{
+	int value_size = strlen(value);
+	bool single_line, break_names;
+
+	break_names = info->key_size > 16 || value_size > 16;
+	single_line = info->key_size + value_size <= 24 && !break_names;
+
+	printf("key:%c", break_names ? '\n' : ' ');
+	fprint_hex(stdout, key, info->key_size, " ");
+
+	printf(single_line ? "  " : "\n");
+
+	printf("value:%c%s", break_names ? '\n' : ' ', value);
+
+	printf("\n");
+}
+
 static void print_entry_plain(struct bpf_map_info *info, unsigned char *key,
 			      unsigned char *value)
 {
@@ -663,6 +682,7 @@ static int dump_map_elem(int fd, void *key, void *value,
 			 json_writer_t *btf_wtr)
 {
 	int num_elems = 0;
+	int lookup_errno;
 
 	if (!bpf_map_lookup_elem(fd, key, value)) {
 		if (json_output) {
@@ -685,6 +705,8 @@ static int dump_map_elem(int fd, void *key, void *value,
 	}
 
 	/* lookup error handling */
+	lookup_errno = errno;
+
 	if (map_is_map_of_maps(map_info->type) ||
 	    map_is_map_of_progs(map_info->type))
 		return 0;
@@ -694,13 +716,10 @@ static int dump_map_elem(int fd, void *key, void *value,
 		print_hex_data_json(key, map_info->key_size);
 		jsonw_name(json_wtr, "value");
 		jsonw_start_object(json_wtr);
-		jsonw_string_field(json_wtr, "error",
-				   "can't lookup element");
+		jsonw_string_field(json_wtr, "error", strerror(lookup_errno));
 		jsonw_end_object(json_wtr);
 	} else {
-		p_info("can't lookup element with key: ");
-		fprint_hex(stderr, key, map_info->key_size, " ");
-		fprintf(stderr, "\n");
+		print_entry_error(map_info, key, strerror(lookup_errno));
 	}
 
 	return 0;
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH bpf-next 5/6] selftests/bpf: test_verifier, change names of fixup maps
  2018-10-09  1:04 [PATCH bpf-next 0/6] Error handling when map lookup isn't supported Prashant Bhole
                   ` (3 preceding siblings ...)
  2018-10-09  1:04 ` [PATCH bpf-next 4/6] tools/bpf: bpftool, print strerror when map lookup error occurs Prashant Bhole
@ 2018-10-09  1:04 ` Prashant Bhole
  2018-10-09  7:01   ` Song Liu
  2018-10-09  1:04 ` [PATCH bpf-next 6/6] selftests/bpf: test_verifier, check bpf_map_lookup_elem access in bpf prog Prashant Bhole
  2018-10-10  4:55 ` [PATCH bpf-next 0/6] Error handling when map lookup isn't supported Alexei Starovoitov
  6 siblings, 1 reply; 16+ messages in thread
From: Prashant Bhole @ 2018-10-09  1:04 UTC (permalink / raw)
  To: Alexei Starovoitov, Daniel Borkmann
  Cc: Prashant Bhole, Jakub Kicinski, David S . Miller, Quentin Monnet, netdev

Currently fixup map are named like fixup_map1, fixup_map2, and so on.
As suggested by Alexei let's change change map names such that we can
identify map type by looking at the name.

This patch is basically a find and replace change:
fixup_map1  ->  fixup_map_hash_8b
fixup_map2  ->  fixup_map_hash_48b
fixup_map3  ->  fixup_map_hash_16b
fixup_map4  ->  fixup_map_array_48b

Suggested-by: Alexei Starovoitov <ast@kernel.org>
Signed-off-by: Prashant Bhole <bhole_prashant_q7@lab.ntt.co.jp>
Acked-by: Alexei Starovoitov <ast@kernel.org>
---
 tools/testing/selftests/bpf/test_verifier.c | 380 ++++++++++----------
 1 file changed, 190 insertions(+), 190 deletions(-)

diff --git a/tools/testing/selftests/bpf/test_verifier.c b/tools/testing/selftests/bpf/test_verifier.c
index bc9cd8537467..65ae44c85d27 100644
--- a/tools/testing/selftests/bpf/test_verifier.c
+++ b/tools/testing/selftests/bpf/test_verifier.c
@@ -61,10 +61,10 @@ static bool unpriv_disabled = false;
 struct bpf_test {
 	const char *descr;
 	struct bpf_insn	insns[MAX_INSNS];
-	int fixup_map1[MAX_FIXUPS];
-	int fixup_map2[MAX_FIXUPS];
-	int fixup_map3[MAX_FIXUPS];
-	int fixup_map4[MAX_FIXUPS];
+	int fixup_map_hash_8b[MAX_FIXUPS];
+	int fixup_map_hash_48b[MAX_FIXUPS];
+	int fixup_map_hash_16b[MAX_FIXUPS];
+	int fixup_map_array_48b[MAX_FIXUPS];
 	int fixup_prog1[MAX_FIXUPS];
 	int fixup_prog2[MAX_FIXUPS];
 	int fixup_map_in_map[MAX_FIXUPS];
@@ -876,7 +876,7 @@ static struct bpf_test tests[] = {
 				     BPF_FUNC_map_lookup_elem),
 			BPF_EXIT_INSN(),
 		},
-		.fixup_map1 = { 2 },
+		.fixup_map_hash_8b = { 2 },
 		.errstr = "invalid indirect read from stack",
 		.result = REJECT,
 	},
@@ -1110,7 +1110,7 @@ static struct bpf_test tests[] = {
 			BPF_ST_MEM(BPF_DW, BPF_REG_0, 0, 0),
 			BPF_EXIT_INSN(),
 		},
-		.fixup_map1 = { 3 },
+		.fixup_map_hash_8b = { 3 },
 		.errstr = "R0 invalid mem access 'map_value_or_null'",
 		.result = REJECT,
 	},
@@ -1127,7 +1127,7 @@ static struct bpf_test tests[] = {
 			BPF_ST_MEM(BPF_DW, BPF_REG_0, 4, 0),
 			BPF_EXIT_INSN(),
 		},
-		.fixup_map1 = { 3 },
+		.fixup_map_hash_8b = { 3 },
 		.errstr = "misaligned value access",
 		.result = REJECT,
 		.flags = F_LOAD_WITH_STRICT_ALIGNMENT,
@@ -1147,7 +1147,7 @@ static struct bpf_test tests[] = {
 			BPF_ST_MEM(BPF_DW, BPF_REG_0, 0, 1),
 			BPF_EXIT_INSN(),
 		},
-		.fixup_map1 = { 3 },
+		.fixup_map_hash_8b = { 3 },
 		.errstr = "R0 invalid mem access",
 		.errstr_unpriv = "R0 leaks addr",
 		.result = REJECT,
@@ -1237,7 +1237,7 @@ static struct bpf_test tests[] = {
 				     BPF_FUNC_map_delete_elem),
 			BPF_EXIT_INSN(),
 		},
-		.fixup_map1 = { 24 },
+		.fixup_map_hash_8b = { 24 },
 		.errstr_unpriv = "R1 pointer comparison",
 		.result_unpriv = REJECT,
 		.result = ACCEPT,
@@ -1391,7 +1391,7 @@ static struct bpf_test tests[] = {
 				    offsetof(struct __sk_buff, pkt_type)),
 			BPF_EXIT_INSN(),
 		},
-		.fixup_map1 = { 4 },
+		.fixup_map_hash_8b = { 4 },
 		.errstr = "different pointers",
 		.errstr_unpriv = "R1 pointer comparison",
 		.result = REJECT,
@@ -1414,7 +1414,7 @@ static struct bpf_test tests[] = {
 			BPF_MOV64_REG(BPF_REG_1, BPF_REG_0),
 			BPF_JMP_IMM(BPF_JA, 0, 0, -12),
 		},
-		.fixup_map1 = { 6 },
+		.fixup_map_hash_8b = { 6 },
 		.errstr = "different pointers",
 		.errstr_unpriv = "R1 pointer comparison",
 		.result = REJECT,
@@ -1438,7 +1438,7 @@ static struct bpf_test tests[] = {
 			BPF_MOV64_REG(BPF_REG_1, BPF_REG_0),
 			BPF_JMP_IMM(BPF_JA, 0, 0, -13),
 		},
-		.fixup_map1 = { 7 },
+		.fixup_map_hash_8b = { 7 },
 		.errstr = "different pointers",
 		.errstr_unpriv = "R1 pointer comparison",
 		.result = REJECT,
@@ -2575,7 +2575,7 @@ static struct bpf_test tests[] = {
 			BPF_MOV64_IMM(BPF_REG_0, 0),
 			BPF_EXIT_INSN(),
 		},
-		.fixup_map1 = { 3 },
+		.fixup_map_hash_8b = { 3 },
 		.errstr_unpriv = "R4 leaks addr",
 		.result_unpriv = REJECT,
 		.result = ACCEPT,
@@ -2592,7 +2592,7 @@ static struct bpf_test tests[] = {
 			BPF_MOV64_IMM(BPF_REG_0, 0),
 			BPF_EXIT_INSN(),
 		},
-		.fixup_map1 = { 3 },
+		.fixup_map_hash_8b = { 3 },
 		.errstr = "invalid indirect read from stack off -8+0 size 8",
 		.result = REJECT,
 	},
@@ -2894,7 +2894,7 @@ static struct bpf_test tests[] = {
 			BPF_STX_MEM(BPF_DW, BPF_REG_0, BPF_REG_0, 0),
 			BPF_EXIT_INSN(),
 		},
-		.fixup_map1 = { 3 },
+		.fixup_map_hash_8b = { 3 },
 		.errstr_unpriv = "R0 leaks addr",
 		.result_unpriv = REJECT,
 		.result = ACCEPT,
@@ -2934,7 +2934,7 @@ static struct bpf_test tests[] = {
 			BPF_MOV64_IMM(BPF_REG_0, 0),
 			BPF_EXIT_INSN(),
 		},
-		.fixup_map1 = { 1 },
+		.fixup_map_hash_8b = { 1 },
 		.errstr_unpriv = "R1 pointer comparison",
 		.result_unpriv = REJECT,
 		.result = ACCEPT,
@@ -4073,7 +4073,7 @@ static struct bpf_test tests[] = {
 			BPF_MOV64_IMM(BPF_REG_0, 0),
 			BPF_EXIT_INSN(),
 		},
-		.fixup_map1 = { 5 },
+		.fixup_map_hash_8b = { 5 },
 		.result_unpriv = ACCEPT,
 		.result = ACCEPT,
 		.prog_type = BPF_PROG_TYPE_XDP,
@@ -4089,7 +4089,7 @@ static struct bpf_test tests[] = {
 			BPF_MOV64_IMM(BPF_REG_0, 0),
 			BPF_EXIT_INSN(),
 		},
-		.fixup_map1 = { 1 },
+		.fixup_map_hash_8b = { 1 },
 		.result = REJECT,
 		.errstr = "invalid access to packet",
 		.prog_type = BPF_PROG_TYPE_XDP,
@@ -4117,7 +4117,7 @@ static struct bpf_test tests[] = {
 			BPF_MOV64_IMM(BPF_REG_0, 0),
 			BPF_EXIT_INSN(),
 		},
-		.fixup_map1 = { 11 },
+		.fixup_map_hash_8b = { 11 },
 		.result = ACCEPT,
 		.prog_type = BPF_PROG_TYPE_XDP,
 	},
@@ -4139,7 +4139,7 @@ static struct bpf_test tests[] = {
 			BPF_MOV64_IMM(BPF_REG_0, 0),
 			BPF_EXIT_INSN(),
 		},
-		.fixup_map1 = { 7 },
+		.fixup_map_hash_8b = { 7 },
 		.result = REJECT,
 		.errstr = "invalid access to packet",
 		.prog_type = BPF_PROG_TYPE_XDP,
@@ -4161,7 +4161,7 @@ static struct bpf_test tests[] = {
 			BPF_MOV64_IMM(BPF_REG_0, 0),
 			BPF_EXIT_INSN(),
 		},
-		.fixup_map1 = { 6 },
+		.fixup_map_hash_8b = { 6 },
 		.result = REJECT,
 		.errstr = "invalid access to packet",
 		.prog_type = BPF_PROG_TYPE_XDP,
@@ -4184,7 +4184,7 @@ static struct bpf_test tests[] = {
 			BPF_MOV64_IMM(BPF_REG_0, 0),
 			BPF_EXIT_INSN(),
 		},
-		.fixup_map1 = { 5 },
+		.fixup_map_hash_8b = { 5 },
 		.result = ACCEPT,
 		.prog_type = BPF_PROG_TYPE_SCHED_CLS,
 	},
@@ -4199,7 +4199,7 @@ static struct bpf_test tests[] = {
 			BPF_MOV64_IMM(BPF_REG_0, 0),
 			BPF_EXIT_INSN(),
 		},
-		.fixup_map1 = { 1 },
+		.fixup_map_hash_8b = { 1 },
 		.result = REJECT,
 		.errstr = "invalid access to packet",
 		.prog_type = BPF_PROG_TYPE_SCHED_CLS,
@@ -4227,7 +4227,7 @@ static struct bpf_test tests[] = {
 			BPF_MOV64_IMM(BPF_REG_0, 0),
 			BPF_EXIT_INSN(),
 		},
-		.fixup_map1 = { 11 },
+		.fixup_map_hash_8b = { 11 },
 		.result = ACCEPT,
 		.prog_type = BPF_PROG_TYPE_SCHED_CLS,
 	},
@@ -4249,7 +4249,7 @@ static struct bpf_test tests[] = {
 			BPF_MOV64_IMM(BPF_REG_0, 0),
 			BPF_EXIT_INSN(),
 		},
-		.fixup_map1 = { 7 },
+		.fixup_map_hash_8b = { 7 },
 		.result = REJECT,
 		.errstr = "invalid access to packet",
 		.prog_type = BPF_PROG_TYPE_SCHED_CLS,
@@ -4271,7 +4271,7 @@ static struct bpf_test tests[] = {
 			BPF_MOV64_IMM(BPF_REG_0, 0),
 			BPF_EXIT_INSN(),
 		},
-		.fixup_map1 = { 6 },
+		.fixup_map_hash_8b = { 6 },
 		.result = REJECT,
 		.errstr = "invalid access to packet",
 		.prog_type = BPF_PROG_TYPE_SCHED_CLS,
@@ -4555,7 +4555,7 @@ static struct bpf_test tests[] = {
 				   offsetof(struct test_val, foo)),
 			BPF_EXIT_INSN(),
 		},
-		.fixup_map2 = { 3 },
+		.fixup_map_hash_48b = { 3 },
 		.errstr_unpriv = "R0 leaks addr",
 		.result_unpriv = REJECT,
 		.result = ACCEPT,
@@ -4577,7 +4577,7 @@ static struct bpf_test tests[] = {
 				   offsetof(struct test_val, foo)),
 			BPF_EXIT_INSN(),
 		},
-		.fixup_map2 = { 3 },
+		.fixup_map_hash_48b = { 3 },
 		.errstr_unpriv = "R0 leaks addr",
 		.result_unpriv = REJECT,
 		.result = ACCEPT,
@@ -4601,7 +4601,7 @@ static struct bpf_test tests[] = {
 				   offsetof(struct test_val, foo)),
 			BPF_EXIT_INSN(),
 		},
-		.fixup_map2 = { 3 },
+		.fixup_map_hash_48b = { 3 },
 		.errstr_unpriv = "R0 leaks addr",
 		.result_unpriv = REJECT,
 		.result = ACCEPT,
@@ -4629,7 +4629,7 @@ static struct bpf_test tests[] = {
 				   offsetof(struct test_val, foo)),
 			BPF_EXIT_INSN(),
 		},
-		.fixup_map2 = { 3 },
+		.fixup_map_hash_48b = { 3 },
 		.errstr_unpriv = "R0 leaks addr",
 		.result_unpriv = REJECT,
 		.result = ACCEPT,
@@ -4649,7 +4649,7 @@ static struct bpf_test tests[] = {
 				   offsetof(struct test_val, foo)),
 			BPF_EXIT_INSN(),
 		},
-		.fixup_map2 = { 3 },
+		.fixup_map_hash_48b = { 3 },
 		.errstr = "invalid access to map value, value_size=48 off=48 size=8",
 		.result = REJECT,
 	},
@@ -4670,7 +4670,7 @@ static struct bpf_test tests[] = {
 				   offsetof(struct test_val, foo)),
 			BPF_EXIT_INSN(),
 		},
-		.fixup_map2 = { 3 },
+		.fixup_map_hash_48b = { 3 },
 		.errstr = "R0 min value is outside of the array range",
 		.result = REJECT,
 		.flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
@@ -4692,7 +4692,7 @@ static struct bpf_test tests[] = {
 				   offsetof(struct test_val, foo)),
 			BPF_EXIT_INSN(),
 		},
-		.fixup_map2 = { 3 },
+		.fixup_map_hash_48b = { 3 },
 		.errstr = "R0 unbounded memory access, make sure to bounds check any array access into a map",
 		.result = REJECT,
 		.flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
@@ -4717,7 +4717,7 @@ static struct bpf_test tests[] = {
 				   offsetof(struct test_val, foo)),
 			BPF_EXIT_INSN(),
 		},
-		.fixup_map2 = { 3 },
+		.fixup_map_hash_48b = { 3 },
 		.errstr_unpriv = "R0 leaks addr",
 		.errstr = "R0 unbounded memory access",
 		.result_unpriv = REJECT,
@@ -4744,7 +4744,7 @@ static struct bpf_test tests[] = {
 				   offsetof(struct test_val, foo)),
 			BPF_EXIT_INSN(),
 		},
-		.fixup_map2 = { 3 },
+		.fixup_map_hash_48b = { 3 },
 		.errstr_unpriv = "R0 leaks addr",
 		.errstr = "invalid access to map value, value_size=48 off=44 size=8",
 		.result_unpriv = REJECT,
@@ -4774,7 +4774,7 @@ static struct bpf_test tests[] = {
 				    offsetof(struct test_val, foo)),
 			BPF_EXIT_INSN(),
 		},
-		.fixup_map2 = { 3, 11 },
+		.fixup_map_hash_48b = { 3, 11 },
 		.errstr = "R0 pointer += pointer",
 		.result = REJECT,
 		.flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
@@ -4807,7 +4807,7 @@ static struct bpf_test tests[] = {
 			BPF_ALU64_IMM(BPF_AND, BPF_REG_0, 1),
 			BPF_EXIT_INSN(),
 		},
-		.fixup_map1 = { 1 },
+		.fixup_map_hash_8b = { 1 },
 		.result = REJECT,
 		.errstr = "cannot pass map_type 1 into func bpf_get_local_storage",
 		.prog_type = BPF_PROG_TYPE_CGROUP_SKB,
@@ -4922,7 +4922,7 @@ static struct bpf_test tests[] = {
 			BPF_ALU64_IMM(BPF_AND, BPF_REG_0, 1),
 			BPF_EXIT_INSN(),
 		},
-		.fixup_map1 = { 1 },
+		.fixup_map_hash_8b = { 1 },
 		.result = REJECT,
 		.errstr = "cannot pass map_type 1 into func bpf_get_local_storage",
 		.prog_type = BPF_PROG_TYPE_CGROUP_SKB,
@@ -5024,7 +5024,7 @@ static struct bpf_test tests[] = {
 			BPF_ST_MEM(BPF_DW, BPF_REG_4, 0, 0),
 			BPF_EXIT_INSN(),
 		},
-		.fixup_map1 = { 4 },
+		.fixup_map_hash_8b = { 4 },
 		.result = ACCEPT,
 		.prog_type = BPF_PROG_TYPE_SCHED_CLS
 	},
@@ -5045,7 +5045,7 @@ static struct bpf_test tests[] = {
 			BPF_ST_MEM(BPF_DW, BPF_REG_4, 0, 0),
 			BPF_EXIT_INSN(),
 		},
-		.fixup_map1 = { 4 },
+		.fixup_map_hash_8b = { 4 },
 		.errstr = "R4 pointer arithmetic on map_value_or_null",
 		.result = REJECT,
 		.prog_type = BPF_PROG_TYPE_SCHED_CLS
@@ -5066,7 +5066,7 @@ static struct bpf_test tests[] = {
 			BPF_ST_MEM(BPF_DW, BPF_REG_4, 0, 0),
 			BPF_EXIT_INSN(),
 		},
-		.fixup_map1 = { 4 },
+		.fixup_map_hash_8b = { 4 },
 		.errstr = "R4 pointer arithmetic on map_value_or_null",
 		.result = REJECT,
 		.prog_type = BPF_PROG_TYPE_SCHED_CLS
@@ -5087,7 +5087,7 @@ static struct bpf_test tests[] = {
 			BPF_ST_MEM(BPF_DW, BPF_REG_4, 0, 0),
 			BPF_EXIT_INSN(),
 		},
-		.fixup_map1 = { 4 },
+		.fixup_map_hash_8b = { 4 },
 		.errstr = "R4 pointer arithmetic on map_value_or_null",
 		.result = REJECT,
 		.prog_type = BPF_PROG_TYPE_SCHED_CLS
@@ -5113,7 +5113,7 @@ static struct bpf_test tests[] = {
 			BPF_ST_MEM(BPF_DW, BPF_REG_4, 0, 0),
 			BPF_EXIT_INSN(),
 		},
-		.fixup_map1 = { 4 },
+		.fixup_map_hash_8b = { 4 },
 		.result = REJECT,
 		.errstr = "R4 !read_ok",
 		.prog_type = BPF_PROG_TYPE_SCHED_CLS
@@ -5141,7 +5141,7 @@ static struct bpf_test tests[] = {
 			BPF_ST_MEM(BPF_DW, BPF_REG_4, 0, 0),
 			BPF_EXIT_INSN(),
 		},
-		.fixup_map1 = { 4 },
+		.fixup_map_hash_8b = { 4 },
 		.result = ACCEPT,
 		.prog_type = BPF_PROG_TYPE_SCHED_CLS
 	},
@@ -5162,7 +5162,7 @@ static struct bpf_test tests[] = {
 			BPF_ST_MEM(BPF_DW, BPF_REG_0, 0, offsetof(struct test_val, foo)),
 			BPF_EXIT_INSN(),
 		},
-		.fixup_map2 = { 3 },
+		.fixup_map_hash_48b = { 3 },
 		.errstr = "R0 unbounded memory access",
 		.result = REJECT,
 		.errstr_unpriv = "R0 leaks addr",
@@ -5412,7 +5412,7 @@ static struct bpf_test tests[] = {
 				      offsetof(struct __sk_buff, cb[0])),
 			BPF_EXIT_INSN(),
 		},
-		.fixup_map1 = { 2 },
+		.fixup_map_hash_8b = { 2 },
 		.errstr_unpriv = "R2 leaks addr into mem",
 		.result_unpriv = REJECT,
 		.result = REJECT,
@@ -5442,7 +5442,7 @@ static struct bpf_test tests[] = {
 				      offsetof(struct __sk_buff, cb[0])),
 			BPF_EXIT_INSN(),
 		},
-		.fixup_map1 = { 1 },
+		.fixup_map_hash_8b = { 1 },
 		.errstr_unpriv = "R2 leaks addr into ctx",
 		.result_unpriv = REJECT,
 		.result = ACCEPT,
@@ -5464,7 +5464,7 @@ static struct bpf_test tests[] = {
 			BPF_MOV64_IMM(BPF_REG_0, 0),
 			BPF_EXIT_INSN(),
 		},
-		.fixup_map1 = { 4 },
+		.fixup_map_hash_8b = { 4 },
 		.errstr_unpriv = "R6 leaks addr into mem",
 		.result_unpriv = REJECT,
 		.result = ACCEPT,
@@ -5484,7 +5484,7 @@ static struct bpf_test tests[] = {
 			BPF_EMIT_CALL(BPF_FUNC_probe_read),
 			BPF_EXIT_INSN(),
 		},
-		.fixup_map2 = { 3 },
+		.fixup_map_hash_48b = { 3 },
 		.result = ACCEPT,
 		.prog_type = BPF_PROG_TYPE_TRACEPOINT,
 	},
@@ -5503,7 +5503,7 @@ static struct bpf_test tests[] = {
 			BPF_EMIT_CALL(BPF_FUNC_probe_read),
 			BPF_EXIT_INSN(),
 		},
-		.fixup_map2 = { 3 },
+		.fixup_map_hash_48b = { 3 },
 		.result = ACCEPT,
 		.prog_type = BPF_PROG_TYPE_TRACEPOINT,
 	},
@@ -5521,7 +5521,7 @@ static struct bpf_test tests[] = {
 			BPF_EMIT_CALL(BPF_FUNC_trace_printk),
 			BPF_EXIT_INSN(),
 		},
-		.fixup_map2 = { 3 },
+		.fixup_map_hash_48b = { 3 },
 		.errstr = "invalid access to map value, value_size=48 off=0 size=0",
 		.result = REJECT,
 		.prog_type = BPF_PROG_TYPE_TRACEPOINT,
@@ -5541,7 +5541,7 @@ static struct bpf_test tests[] = {
 			BPF_EMIT_CALL(BPF_FUNC_probe_read),
 			BPF_EXIT_INSN(),
 		},
-		.fixup_map2 = { 3 },
+		.fixup_map_hash_48b = { 3 },
 		.errstr = "invalid access to map value, value_size=48 off=0 size=56",
 		.result = REJECT,
 		.prog_type = BPF_PROG_TYPE_TRACEPOINT,
@@ -5561,7 +5561,7 @@ static struct bpf_test tests[] = {
 			BPF_EMIT_CALL(BPF_FUNC_probe_read),
 			BPF_EXIT_INSN(),
 		},
-		.fixup_map2 = { 3 },
+		.fixup_map_hash_48b = { 3 },
 		.errstr = "R2 min value is negative",
 		.result = REJECT,
 		.prog_type = BPF_PROG_TYPE_TRACEPOINT,
@@ -5585,7 +5585,7 @@ static struct bpf_test tests[] = {
 			BPF_EMIT_CALL(BPF_FUNC_probe_read),
 			BPF_EXIT_INSN(),
 		},
-		.fixup_map2 = { 3 },
+		.fixup_map_hash_48b = { 3 },
 		.result = ACCEPT,
 		.prog_type = BPF_PROG_TYPE_TRACEPOINT,
 	},
@@ -5606,7 +5606,7 @@ static struct bpf_test tests[] = {
 			BPF_EMIT_CALL(BPF_FUNC_probe_read),
 			BPF_EXIT_INSN(),
 		},
-		.fixup_map2 = { 3 },
+		.fixup_map_hash_48b = { 3 },
 		.result = ACCEPT,
 		.prog_type = BPF_PROG_TYPE_TRACEPOINT,
 	},
@@ -5626,7 +5626,7 @@ static struct bpf_test tests[] = {
 			BPF_EMIT_CALL(BPF_FUNC_trace_printk),
 			BPF_EXIT_INSN(),
 		},
-		.fixup_map2 = { 3 },
+		.fixup_map_hash_48b = { 3 },
 		.errstr = "invalid access to map value, value_size=48 off=4 size=0",
 		.result = REJECT,
 		.prog_type = BPF_PROG_TYPE_TRACEPOINT,
@@ -5650,7 +5650,7 @@ static struct bpf_test tests[] = {
 			BPF_EMIT_CALL(BPF_FUNC_probe_read),
 			BPF_EXIT_INSN(),
 		},
-		.fixup_map2 = { 3 },
+		.fixup_map_hash_48b = { 3 },
 		.errstr = "invalid access to map value, value_size=48 off=4 size=52",
 		.result = REJECT,
 		.prog_type = BPF_PROG_TYPE_TRACEPOINT,
@@ -5672,7 +5672,7 @@ static struct bpf_test tests[] = {
 			BPF_EMIT_CALL(BPF_FUNC_probe_read),
 			BPF_EXIT_INSN(),
 		},
-		.fixup_map2 = { 3 },
+		.fixup_map_hash_48b = { 3 },
 		.errstr = "R2 min value is negative",
 		.result = REJECT,
 		.prog_type = BPF_PROG_TYPE_TRACEPOINT,
@@ -5694,7 +5694,7 @@ static struct bpf_test tests[] = {
 			BPF_EMIT_CALL(BPF_FUNC_probe_read),
 			BPF_EXIT_INSN(),
 		},
-		.fixup_map2 = { 3 },
+		.fixup_map_hash_48b = { 3 },
 		.errstr = "R2 min value is negative",
 		.result = REJECT,
 		.prog_type = BPF_PROG_TYPE_TRACEPOINT,
@@ -5719,7 +5719,7 @@ static struct bpf_test tests[] = {
 			BPF_EMIT_CALL(BPF_FUNC_probe_read),
 			BPF_EXIT_INSN(),
 		},
-		.fixup_map2 = { 3 },
+		.fixup_map_hash_48b = { 3 },
 		.result = ACCEPT,
 		.prog_type = BPF_PROG_TYPE_TRACEPOINT,
 	},
@@ -5741,7 +5741,7 @@ static struct bpf_test tests[] = {
 			BPF_EMIT_CALL(BPF_FUNC_probe_read),
 			BPF_EXIT_INSN(),
 		},
-		.fixup_map2 = { 3 },
+		.fixup_map_hash_48b = { 3 },
 		.result = ACCEPT,
 		.prog_type = BPF_PROG_TYPE_TRACEPOINT,
 	},
@@ -5761,7 +5761,7 @@ static struct bpf_test tests[] = {
 			BPF_EMIT_CALL(BPF_FUNC_trace_printk),
 			BPF_EXIT_INSN(),
 		},
-		.fixup_map2 = { 3 },
+		.fixup_map_hash_48b = { 3 },
 		.errstr = "R1 min value is outside of the array range",
 		.result = REJECT,
 		.prog_type = BPF_PROG_TYPE_TRACEPOINT,
@@ -5786,7 +5786,7 @@ static struct bpf_test tests[] = {
 			BPF_EMIT_CALL(BPF_FUNC_probe_read),
 			BPF_EXIT_INSN(),
 		},
-		.fixup_map2 = { 3 },
+		.fixup_map_hash_48b = { 3 },
 		.errstr = "invalid access to map value, value_size=48 off=4 size=52",
 		.result = REJECT,
 		.prog_type = BPF_PROG_TYPE_TRACEPOINT,
@@ -5809,7 +5809,7 @@ static struct bpf_test tests[] = {
 			BPF_EMIT_CALL(BPF_FUNC_probe_read),
 			BPF_EXIT_INSN(),
 		},
-		.fixup_map2 = { 3 },
+		.fixup_map_hash_48b = { 3 },
 		.errstr = "R2 min value is negative",
 		.result = REJECT,
 		.prog_type = BPF_PROG_TYPE_TRACEPOINT,
@@ -5832,7 +5832,7 @@ static struct bpf_test tests[] = {
 			BPF_EMIT_CALL(BPF_FUNC_probe_read),
 			BPF_EXIT_INSN(),
 		},
-		.fixup_map2 = { 3 },
+		.fixup_map_hash_48b = { 3 },
 		.errstr = "R2 min value is negative",
 		.result = REJECT,
 		.prog_type = BPF_PROG_TYPE_TRACEPOINT,
@@ -5858,7 +5858,7 @@ static struct bpf_test tests[] = {
 			BPF_EMIT_CALL(BPF_FUNC_probe_read),
 			BPF_EXIT_INSN(),
 		},
-		.fixup_map2 = { 3 },
+		.fixup_map_hash_48b = { 3 },
 		.result = ACCEPT,
 		.prog_type = BPF_PROG_TYPE_TRACEPOINT,
 	},
@@ -5881,7 +5881,7 @@ static struct bpf_test tests[] = {
 			BPF_EMIT_CALL(BPF_FUNC_probe_read),
 			BPF_EXIT_INSN(),
 		},
-		.fixup_map2 = { 3 },
+		.fixup_map_hash_48b = { 3 },
 		.result = ACCEPT,
 		.prog_type = BPF_PROG_TYPE_TRACEPOINT,
 	},
@@ -5903,7 +5903,7 @@ static struct bpf_test tests[] = {
 			BPF_EMIT_CALL(BPF_FUNC_trace_printk),
 			BPF_EXIT_INSN(),
 		},
-		.fixup_map2 = { 3 },
+		.fixup_map_hash_48b = { 3 },
 		.errstr = "R1 min value is outside of the array range",
 		.result = REJECT,
 		.prog_type = BPF_PROG_TYPE_TRACEPOINT,
@@ -5925,7 +5925,7 @@ static struct bpf_test tests[] = {
 			BPF_EMIT_CALL(BPF_FUNC_probe_read),
 			BPF_EXIT_INSN(),
 		},
-		.fixup_map2 = { 3 },
+		.fixup_map_hash_48b = { 3 },
 		.errstr = "R1 unbounded memory access",
 		.result = REJECT,
 		.prog_type = BPF_PROG_TYPE_TRACEPOINT,
@@ -5951,7 +5951,7 @@ static struct bpf_test tests[] = {
 			BPF_EMIT_CALL(BPF_FUNC_probe_read),
 			BPF_EXIT_INSN(),
 		},
-		.fixup_map2 = { 3 },
+		.fixup_map_hash_48b = { 3 },
 		.errstr = "invalid access to map value, value_size=48 off=4 size=45",
 		.result = REJECT,
 		.prog_type = BPF_PROG_TYPE_TRACEPOINT,
@@ -5975,7 +5975,7 @@ static struct bpf_test tests[] = {
 			BPF_MOV64_IMM(BPF_REG_0, 0),
 			BPF_EXIT_INSN(),
 		},
-		.fixup_map2 = { 3 },
+		.fixup_map_hash_48b = { 3 },
 		.result = ACCEPT,
 		.prog_type = BPF_PROG_TYPE_TRACEPOINT,
 	},
@@ -5998,7 +5998,7 @@ static struct bpf_test tests[] = {
 			BPF_MOV64_IMM(BPF_REG_0, 0),
 			BPF_EXIT_INSN(),
 		},
-		.fixup_map2 = { 3 },
+		.fixup_map_hash_48b = { 3 },
 		.result = REJECT,
 		.errstr = "R1 unbounded memory access",
 		.prog_type = BPF_PROG_TYPE_TRACEPOINT,
@@ -6022,7 +6022,7 @@ static struct bpf_test tests[] = {
 			BPF_MOV64_IMM(BPF_REG_0, 0),
 			BPF_EXIT_INSN(),
 		},
-		.fixup_map2 = { 3 },
+		.fixup_map_hash_48b = { 3 },
 		.result = ACCEPT,
 		.prog_type = BPF_PROG_TYPE_TRACEPOINT,
 	},
@@ -6045,7 +6045,7 @@ static struct bpf_test tests[] = {
 			BPF_MOV64_IMM(BPF_REG_0, 0),
 			BPF_EXIT_INSN(),
 		},
-		.fixup_map2 = { 3 },
+		.fixup_map_hash_48b = { 3 },
 		.result = REJECT,
 		.errstr = "R1 unbounded memory access",
 		.prog_type = BPF_PROG_TYPE_TRACEPOINT,
@@ -6070,7 +6070,7 @@ static struct bpf_test tests[] = {
 			BPF_MOV64_IMM(BPF_REG_0, 0),
 			BPF_EXIT_INSN(),
 		},
-		.fixup_map2 = { 3 },
+		.fixup_map_hash_48b = { 3 },
 		.result = ACCEPT,
 		.prog_type = BPF_PROG_TYPE_TRACEPOINT,
 	},
@@ -6094,7 +6094,7 @@ static struct bpf_test tests[] = {
 			BPF_MOV64_IMM(BPF_REG_0, 0),
 			BPF_EXIT_INSN(),
 		},
-		.fixup_map2 = { 3 },
+		.fixup_map_hash_48b = { 3 },
 		.result = ACCEPT,
 		.prog_type = BPF_PROG_TYPE_TRACEPOINT,
 	},
@@ -6118,7 +6118,7 @@ static struct bpf_test tests[] = {
 			BPF_MOV64_IMM(BPF_REG_0, 0),
 			BPF_EXIT_INSN(),
 		},
-		.fixup_map2 = { 3 },
+		.fixup_map_hash_48b = { 3 },
 		.result = REJECT,
 		.errstr = "R1 min value is negative",
 		.prog_type = BPF_PROG_TYPE_TRACEPOINT,
@@ -6143,7 +6143,7 @@ static struct bpf_test tests[] = {
 			BPF_MOV64_IMM(BPF_REG_0, 0),
 			BPF_EXIT_INSN(),
 		},
-		.fixup_map2 = { 3 },
+		.fixup_map_hash_48b = { 3 },
 		.result = ACCEPT,
 		.prog_type = BPF_PROG_TYPE_TRACEPOINT,
 	},
@@ -6167,7 +6167,7 @@ static struct bpf_test tests[] = {
 			BPF_MOV64_IMM(BPF_REG_0, 0),
 			BPF_EXIT_INSN(),
 		},
-		.fixup_map2 = { 3 },
+		.fixup_map_hash_48b = { 3 },
 		.result = ACCEPT,
 		.prog_type = BPF_PROG_TYPE_TRACEPOINT,
 	},
@@ -6191,7 +6191,7 @@ static struct bpf_test tests[] = {
 			BPF_MOV64_IMM(BPF_REG_0, 0),
 			BPF_EXIT_INSN(),
 		},
-		.fixup_map2 = { 3 },
+		.fixup_map_hash_48b = { 3 },
 		.result = REJECT,
 		.errstr = "R1 min value is negative",
 		.prog_type = BPF_PROG_TYPE_TRACEPOINT,
@@ -6210,7 +6210,7 @@ static struct bpf_test tests[] = {
 			BPF_EMIT_CALL(BPF_FUNC_map_lookup_elem),
 			BPF_EXIT_INSN(),
 		},
-		.fixup_map3 = { 3, 8 },
+		.fixup_map_hash_16b = { 3, 8 },
 		.result = ACCEPT,
 		.prog_type = BPF_PROG_TYPE_TRACEPOINT,
 	},
@@ -6230,7 +6230,7 @@ static struct bpf_test tests[] = {
 			BPF_EMIT_CALL(BPF_FUNC_map_update_elem),
 			BPF_EXIT_INSN(),
 		},
-		.fixup_map3 = { 3, 10 },
+		.fixup_map_hash_16b = { 3, 10 },
 		.result = ACCEPT,
 		.prog_type = BPF_PROG_TYPE_TRACEPOINT,
 	},
@@ -6250,8 +6250,8 @@ static struct bpf_test tests[] = {
 			BPF_EMIT_CALL(BPF_FUNC_map_update_elem),
 			BPF_EXIT_INSN(),
 		},
-		.fixup_map1 = { 3 },
-		.fixup_map3 = { 10 },
+		.fixup_map_hash_8b = { 3 },
+		.fixup_map_hash_16b = { 10 },
 		.result = REJECT,
 		.errstr = "invalid access to map value, value_size=8 off=0 size=16",
 		.prog_type = BPF_PROG_TYPE_TRACEPOINT,
@@ -6272,7 +6272,7 @@ static struct bpf_test tests[] = {
 			BPF_EMIT_CALL(BPF_FUNC_map_lookup_elem),
 			BPF_EXIT_INSN(),
 		},
-		.fixup_map3 = { 3, 9 },
+		.fixup_map_hash_16b = { 3, 9 },
 		.result = ACCEPT,
 		.prog_type = BPF_PROG_TYPE_TRACEPOINT,
 	},
@@ -6292,7 +6292,7 @@ static struct bpf_test tests[] = {
 			BPF_EMIT_CALL(BPF_FUNC_map_lookup_elem),
 			BPF_EXIT_INSN(),
 		},
-		.fixup_map3 = { 3, 9 },
+		.fixup_map_hash_16b = { 3, 9 },
 		.result = REJECT,
 		.errstr = "invalid access to map value, value_size=16 off=12 size=8",
 		.prog_type = BPF_PROG_TYPE_TRACEPOINT,
@@ -6312,7 +6312,7 @@ static struct bpf_test tests[] = {
 			BPF_EMIT_CALL(BPF_FUNC_map_lookup_elem),
 			BPF_EXIT_INSN(),
 		},
-		.fixup_map3 = { 3, 9 },
+		.fixup_map_hash_16b = { 3, 9 },
 		.result = REJECT,
 		.errstr = "invalid access to map value, value_size=16 off=-4 size=8",
 		.prog_type = BPF_PROG_TYPE_TRACEPOINT,
@@ -6334,7 +6334,7 @@ static struct bpf_test tests[] = {
 			BPF_EMIT_CALL(BPF_FUNC_map_lookup_elem),
 			BPF_EXIT_INSN(),
 		},
-		.fixup_map3 = { 3, 10 },
+		.fixup_map_hash_16b = { 3, 10 },
 		.result = ACCEPT,
 		.prog_type = BPF_PROG_TYPE_TRACEPOINT,
 	},
@@ -6355,7 +6355,7 @@ static struct bpf_test tests[] = {
 			BPF_EMIT_CALL(BPF_FUNC_map_lookup_elem),
 			BPF_EXIT_INSN(),
 		},
-		.fixup_map3 = { 3, 10 },
+		.fixup_map_hash_16b = { 3, 10 },
 		.result = REJECT,
 		.errstr = "invalid access to map value, value_size=16 off=12 size=8",
 		.prog_type = BPF_PROG_TYPE_TRACEPOINT,
@@ -6376,7 +6376,7 @@ static struct bpf_test tests[] = {
 			BPF_EMIT_CALL(BPF_FUNC_map_lookup_elem),
 			BPF_EXIT_INSN(),
 		},
-		.fixup_map3 = { 3, 10 },
+		.fixup_map_hash_16b = { 3, 10 },
 		.result = REJECT,
 		.errstr = "invalid access to map value, value_size=16 off=-4 size=8",
 		.prog_type = BPF_PROG_TYPE_TRACEPOINT,
@@ -6399,7 +6399,7 @@ static struct bpf_test tests[] = {
 			BPF_EMIT_CALL(BPF_FUNC_map_lookup_elem),
 			BPF_EXIT_INSN(),
 		},
-		.fixup_map3 = { 3, 11 },
+		.fixup_map_hash_16b = { 3, 11 },
 		.result = ACCEPT,
 		.prog_type = BPF_PROG_TYPE_TRACEPOINT,
 	},
@@ -6419,7 +6419,7 @@ static struct bpf_test tests[] = {
 			BPF_EMIT_CALL(BPF_FUNC_map_lookup_elem),
 			BPF_EXIT_INSN(),
 		},
-		.fixup_map3 = { 3, 10 },
+		.fixup_map_hash_16b = { 3, 10 },
 		.result = REJECT,
 		.errstr = "R2 unbounded memory access, make sure to bounds check any array access into a map",
 		.prog_type = BPF_PROG_TYPE_TRACEPOINT,
@@ -6442,7 +6442,7 @@ static struct bpf_test tests[] = {
 			BPF_EMIT_CALL(BPF_FUNC_map_lookup_elem),
 			BPF_EXIT_INSN(),
 		},
-		.fixup_map3 = { 3, 11 },
+		.fixup_map_hash_16b = { 3, 11 },
 		.result = REJECT,
 		.errstr = "invalid access to map value, value_size=16 off=9 size=8",
 		.prog_type = BPF_PROG_TYPE_TRACEPOINT,
@@ -6464,7 +6464,7 @@ static struct bpf_test tests[] = {
 			BPF_ST_MEM(BPF_DW, BPF_REG_3, 0, 42),
 			BPF_EXIT_INSN(),
 		},
-		.fixup_map2 = { 3 },
+		.fixup_map_hash_48b = { 3 },
 		.errstr_unpriv = "R0 leaks addr",
 		.result = ACCEPT,
 		.result_unpriv = REJECT,
@@ -6485,7 +6485,7 @@ static struct bpf_test tests[] = {
 			BPF_ST_MEM(BPF_DW, BPF_REG_3, 0, 42),
 			BPF_EXIT_INSN(),
 		},
-		.fixup_map2 = { 3 },
+		.fixup_map_hash_48b = { 3 },
 		.errstr_unpriv = "R0 leaks addr",
 		.result = ACCEPT,
 		.result_unpriv = REJECT,
@@ -6502,7 +6502,7 @@ static struct bpf_test tests[] = {
 			BPF_STX_MEM(BPF_DW, BPF_REG_0, BPF_REG_1, 0),
 			BPF_EXIT_INSN(),
 		},
-		.fixup_map2 = { 3 },
+		.fixup_map_hash_48b = { 3 },
 		.errstr_unpriv = "R1 !read_ok",
 		.errstr = "R1 !read_ok",
 		.result = REJECT,
@@ -6536,7 +6536,7 @@ static struct bpf_test tests[] = {
 			BPF_ST_MEM(BPF_DW, BPF_REG_7, -4, 24),
 			BPF_EXIT_INSN(),
 		},
-		.fixup_map2 = { 3 },
+		.fixup_map_hash_48b = { 3 },
 		.errstr_unpriv = "R0 leaks addr",
 		.result = ACCEPT,
 		.result_unpriv = REJECT,
@@ -6564,7 +6564,7 @@ static struct bpf_test tests[] = {
 			BPF_LDX_MEM(BPF_DW, BPF_REG_7, BPF_REG_0, 4),
 			BPF_EXIT_INSN(),
 		},
-		.fixup_map2 = { 3 },
+		.fixup_map_hash_48b = { 3 },
 		.errstr_unpriv = "R0 leaks addr",
 		.result = ACCEPT,
 		.result_unpriv = REJECT,
@@ -6583,7 +6583,7 @@ static struct bpf_test tests[] = {
 			BPF_ST_MEM(BPF_DW, BPF_REG_0, 0, 22),
 			BPF_EXIT_INSN(),
 		},
-		.fixup_map2 = { 3 },
+		.fixup_map_hash_48b = { 3 },
 		.errstr = "R0 bitwise operator &= on pointer",
 		.result = REJECT,
 	},
@@ -6600,7 +6600,7 @@ static struct bpf_test tests[] = {
 			BPF_ST_MEM(BPF_DW, BPF_REG_0, 0, 22),
 			BPF_EXIT_INSN(),
 		},
-		.fixup_map2 = { 3 },
+		.fixup_map_hash_48b = { 3 },
 		.errstr = "R0 32-bit pointer arithmetic prohibited",
 		.result = REJECT,
 	},
@@ -6617,7 +6617,7 @@ static struct bpf_test tests[] = {
 			BPF_ST_MEM(BPF_DW, BPF_REG_0, 0, 22),
 			BPF_EXIT_INSN(),
 		},
-		.fixup_map2 = { 3 },
+		.fixup_map_hash_48b = { 3 },
 		.errstr = "R0 pointer arithmetic with /= operator",
 		.result = REJECT,
 	},
@@ -6634,7 +6634,7 @@ static struct bpf_test tests[] = {
 			BPF_ST_MEM(BPF_DW, BPF_REG_0, 0, 22),
 			BPF_EXIT_INSN(),
 		},
-		.fixup_map2 = { 3 },
+		.fixup_map_hash_48b = { 3 },
 		.errstr_unpriv = "R0 pointer arithmetic prohibited",
 		.errstr = "invalid mem access 'inv'",
 		.result = REJECT,
@@ -6658,7 +6658,7 @@ static struct bpf_test tests[] = {
 			BPF_ST_MEM(BPF_DW, BPF_REG_0, 0, 22),
 			BPF_EXIT_INSN(),
 		},
-		.fixup_map2 = { 3 },
+		.fixup_map_hash_48b = { 3 },
 		.errstr = "R0 invalid mem access 'inv'",
 		.result = REJECT,
 	},
@@ -6681,7 +6681,7 @@ static struct bpf_test tests[] = {
 			BPF_ST_MEM(BPF_DW, BPF_REG_3, 0, 42),
 			BPF_EXIT_INSN(),
 		},
-		.fixup_map2 = { 3 },
+		.fixup_map_hash_48b = { 3 },
 		.errstr_unpriv = "R0 leaks addr",
 		.result = ACCEPT,
 		.result_unpriv = REJECT,
@@ -6927,7 +6927,7 @@ static struct bpf_test tests[] = {
 			BPF_MOV64_IMM(BPF_REG_0, 0),
 			BPF_EXIT_INSN(),
 		},
-		.fixup_map2 = { 3 },
+		.fixup_map_hash_48b = { 3 },
 		.result = ACCEPT,
 		.prog_type = BPF_PROG_TYPE_TRACEPOINT,
 	},
@@ -6953,7 +6953,7 @@ static struct bpf_test tests[] = {
 			BPF_MOV64_IMM(BPF_REG_0, 0),
 			BPF_EXIT_INSN(),
 		},
-		.fixup_map2 = { 3 },
+		.fixup_map_hash_48b = { 3 },
 		.errstr = "invalid access to map value, value_size=48 off=0 size=49",
 		.result = REJECT,
 		.prog_type = BPF_PROG_TYPE_TRACEPOINT,
@@ -6981,7 +6981,7 @@ static struct bpf_test tests[] = {
 			BPF_MOV64_IMM(BPF_REG_0, 0),
 			BPF_EXIT_INSN(),
 		},
-		.fixup_map2 = { 3 },
+		.fixup_map_hash_48b = { 3 },
 		.result = ACCEPT,
 		.prog_type = BPF_PROG_TYPE_TRACEPOINT,
 	},
@@ -7008,7 +7008,7 @@ static struct bpf_test tests[] = {
 			BPF_MOV64_IMM(BPF_REG_0, 0),
 			BPF_EXIT_INSN(),
 		},
-		.fixup_map2 = { 3 },
+		.fixup_map_hash_48b = { 3 },
 		.errstr = "R1 min value is outside of the array range",
 		.result = REJECT,
 		.prog_type = BPF_PROG_TYPE_TRACEPOINT,
@@ -7080,7 +7080,7 @@ static struct bpf_test tests[] = {
 			BPF_EMIT_CALL(BPF_FUNC_csum_diff),
 			BPF_EXIT_INSN(),
 		},
-		.fixup_map1 = { 3 },
+		.fixup_map_hash_8b = { 3 },
 		.result = ACCEPT,
 		.prog_type = BPF_PROG_TYPE_SCHED_CLS,
 	},
@@ -7105,7 +7105,7 @@ static struct bpf_test tests[] = {
 			BPF_EMIT_CALL(BPF_FUNC_csum_diff),
 			BPF_EXIT_INSN(),
 		},
-		.fixup_map1 = { 3 },
+		.fixup_map_hash_8b = { 3 },
 		.result = ACCEPT,
 		.prog_type = BPF_PROG_TYPE_SCHED_CLS,
 	},
@@ -7128,7 +7128,7 @@ static struct bpf_test tests[] = {
 			BPF_EMIT_CALL(BPF_FUNC_csum_diff),
 			BPF_EXIT_INSN(),
 		},
-		.fixup_map1 = { 3 },
+		.fixup_map_hash_8b = { 3 },
 		.result = ACCEPT,
 		.prog_type = BPF_PROG_TYPE_SCHED_CLS,
 	},
@@ -7209,7 +7209,7 @@ static struct bpf_test tests[] = {
 			BPF_EMIT_CALL(BPF_FUNC_probe_read),
 			BPF_EXIT_INSN(),
 		},
-		.fixup_map1 = { 3 },
+		.fixup_map_hash_8b = { 3 },
 		.result = ACCEPT,
 		.prog_type = BPF_PROG_TYPE_TRACEPOINT,
 	},
@@ -7230,7 +7230,7 @@ static struct bpf_test tests[] = {
 			BPF_EMIT_CALL(BPF_FUNC_probe_read),
 			BPF_EXIT_INSN(),
 		},
-		.fixup_map1 = { 3 },
+		.fixup_map_hash_8b = { 3 },
 		.result = ACCEPT,
 		.prog_type = BPF_PROG_TYPE_TRACEPOINT,
 	},
@@ -7250,7 +7250,7 @@ static struct bpf_test tests[] = {
 			BPF_EMIT_CALL(BPF_FUNC_probe_read),
 			BPF_EXIT_INSN(),
 		},
-		.fixup_map1 = { 3 },
+		.fixup_map_hash_8b = { 3 },
 		.result = ACCEPT,
 		.prog_type = BPF_PROG_TYPE_TRACEPOINT,
 	},
@@ -7325,7 +7325,7 @@ static struct bpf_test tests[] = {
 				   offsetof(struct test_val, foo)),
 			BPF_EXIT_INSN(),
 		},
-		.fixup_map2 = { 3 },
+		.fixup_map_hash_48b = { 3 },
 		.errstr = "R0 max value is outside of the array range",
 		.result = REJECT,
 		.flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
@@ -7355,7 +7355,7 @@ static struct bpf_test tests[] = {
 			BPF_MOV64_REG(BPF_REG_0, 0),
 			BPF_EXIT_INSN(),
 		},
-		.fixup_map2 = { 3 },
+		.fixup_map_hash_48b = { 3 },
 		.errstr = "R0 max value is outside of the array range",
 		.result = REJECT,
 		.flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
@@ -7708,7 +7708,7 @@ static struct bpf_test tests[] = {
 			BPF_MOV64_IMM(BPF_REG_0, 0),
 			BPF_EXIT_INSN(),
 		},
-		.fixup_map1 = { 3 },
+		.fixup_map_hash_8b = { 3 },
 		.errstr = "unbounded min value",
 		.result = REJECT,
 	},
@@ -7732,7 +7732,7 @@ static struct bpf_test tests[] = {
 			BPF_MOV64_IMM(BPF_REG_0, 0),
 			BPF_EXIT_INSN(),
 		},
-		.fixup_map1 = { 3 },
+		.fixup_map_hash_8b = { 3 },
 		.errstr = "unbounded min value",
 		.result = REJECT,
 	},
@@ -7758,7 +7758,7 @@ static struct bpf_test tests[] = {
 			BPF_MOV64_IMM(BPF_REG_0, 0),
 			BPF_EXIT_INSN(),
 		},
-		.fixup_map1 = { 3 },
+		.fixup_map_hash_8b = { 3 },
 		.errstr = "unbounded min value",
 		.result = REJECT,
 	},
@@ -7783,7 +7783,7 @@ static struct bpf_test tests[] = {
 			BPF_MOV64_IMM(BPF_REG_0, 0),
 			BPF_EXIT_INSN(),
 		},
-		.fixup_map1 = { 3 },
+		.fixup_map_hash_8b = { 3 },
 		.errstr = "unbounded min value",
 		.result = REJECT,
 	},
@@ -7807,7 +7807,7 @@ static struct bpf_test tests[] = {
 			BPF_MOV64_IMM(BPF_REG_0, 0),
 			BPF_EXIT_INSN(),
 		},
-		.fixup_map1 = { 3 },
+		.fixup_map_hash_8b = { 3 },
 		.result = ACCEPT,
 	},
 	{
@@ -7831,7 +7831,7 @@ static struct bpf_test tests[] = {
 			BPF_MOV64_IMM(BPF_REG_0, 0),
 			BPF_EXIT_INSN(),
 		},
-		.fixup_map1 = { 3 },
+		.fixup_map_hash_8b = { 3 },
 		.errstr = "unbounded min value",
 		.result = REJECT,
 	},
@@ -7877,7 +7877,7 @@ static struct bpf_test tests[] = {
 			BPF_MOV64_IMM(BPF_REG_0, 0),
 			BPF_EXIT_INSN(),
 		},
-		.fixup_map1 = { 3 },
+		.fixup_map_hash_8b = { 3 },
 		.result = ACCEPT,
 	},
 	{
@@ -7902,7 +7902,7 @@ static struct bpf_test tests[] = {
 			BPF_MOV64_IMM(BPF_REG_0, 0),
 			BPF_EXIT_INSN(),
 		},
-		.fixup_map1 = { 3 },
+		.fixup_map_hash_8b = { 3 },
 		.errstr = "unbounded min value",
 		.result = REJECT,
 	},
@@ -7928,7 +7928,7 @@ static struct bpf_test tests[] = {
 			BPF_MOV64_IMM(BPF_REG_0, 0),
 			BPF_EXIT_INSN(),
 		},
-		.fixup_map1 = { 3 },
+		.fixup_map_hash_8b = { 3 },
 		.result = ACCEPT,
 	},
 	{
@@ -7953,7 +7953,7 @@ static struct bpf_test tests[] = {
 			BPF_MOV64_IMM(BPF_REG_0, 0),
 			BPF_EXIT_INSN(),
 		},
-		.fixup_map1 = { 3 },
+		.fixup_map_hash_8b = { 3 },
 		.errstr = "unbounded min value",
 		.result = REJECT,
 	},
@@ -7980,7 +7980,7 @@ static struct bpf_test tests[] = {
 			BPF_MOV64_IMM(BPF_REG_0, 0),
 			BPF_EXIT_INSN(),
 		},
-		.fixup_map1 = { 3 },
+		.fixup_map_hash_8b = { 3 },
 		.errstr = "unbounded min value",
 		.result = REJECT,
 	},
@@ -8006,7 +8006,7 @@ static struct bpf_test tests[] = {
 			BPF_MOV64_IMM(BPF_REG_0, 0),
 			BPF_EXIT_INSN(),
 		},
-		.fixup_map1 = { 3 },
+		.fixup_map_hash_8b = { 3 },
 		.errstr = "unbounded min value",
 		.result = REJECT,
 	},
@@ -8035,7 +8035,7 @@ static struct bpf_test tests[] = {
 			BPF_MOV64_IMM(BPF_REG_0, 0),
 			BPF_EXIT_INSN(),
 		},
-		.fixup_map1 = { 3 },
+		.fixup_map_hash_8b = { 3 },
 		.errstr = "unbounded min value",
 		.result = REJECT,
 	},
@@ -8065,7 +8065,7 @@ static struct bpf_test tests[] = {
 			BPF_JMP_REG(BPF_JGT, BPF_REG_1, BPF_REG_2, -3),
 			BPF_JMP_IMM(BPF_JA, 0, 0, -7),
 		},
-		.fixup_map1 = { 4 },
+		.fixup_map_hash_8b = { 4 },
 		.errstr = "R0 invalid mem access 'inv'",
 		.result = REJECT,
 	},
@@ -8093,7 +8093,7 @@ static struct bpf_test tests[] = {
 			BPF_MOV64_IMM(BPF_REG_0, 0),
 			BPF_EXIT_INSN(),
 		},
-		.fixup_map1 = { 3 },
+		.fixup_map_hash_8b = { 3 },
 		.errstr = "unbounded min value",
 		.result = REJECT,
 		.result_unpriv = REJECT,
@@ -8120,7 +8120,7 @@ static struct bpf_test tests[] = {
 			BPF_MOV64_IMM(BPF_REG_0, 0),
 			BPF_EXIT_INSN(),
 		},
-		.fixup_map1 = { 3 },
+		.fixup_map_hash_8b = { 3 },
 		.errstr = "R0 max value is outside of the array range",
 		.result = REJECT,
 	},
@@ -8145,7 +8145,7 @@ static struct bpf_test tests[] = {
 			BPF_MOV64_IMM(BPF_REG_0, 0),
 			BPF_EXIT_INSN(),
 		},
-		.fixup_map1 = { 3 },
+		.fixup_map_hash_8b = { 3 },
 		.errstr = "R0 min value is negative, either use unsigned index or do a if (index >=0) check.",
 		.result = REJECT,
 	},
@@ -8171,7 +8171,7 @@ static struct bpf_test tests[] = {
 			BPF_MOV64_IMM(BPF_REG_0, 0),
 			BPF_EXIT_INSN(),
 		},
-		.fixup_map1 = { 3 },
+		.fixup_map_hash_8b = { 3 },
 		.result = ACCEPT
 	},
 	{
@@ -8196,7 +8196,7 @@ static struct bpf_test tests[] = {
 			BPF_MOV64_IMM(BPF_REG_0, 0),
 			BPF_EXIT_INSN(),
 		},
-		.fixup_map1 = { 3 },
+		.fixup_map_hash_8b = { 3 },
 		.errstr = "map_value pointer and 4294967295",
 		.result = REJECT
 	},
@@ -8222,7 +8222,7 @@ static struct bpf_test tests[] = {
 			BPF_MOV64_IMM(BPF_REG_0, 0),
 			BPF_EXIT_INSN(),
 		},
-		.fixup_map1 = { 3 },
+		.fixup_map_hash_8b = { 3 },
 		.errstr = "R0 min value is outside of the array range",
 		.result = REJECT
 	},
@@ -8246,7 +8246,7 @@ static struct bpf_test tests[] = {
 			BPF_MOV64_IMM(BPF_REG_0, 0),
 			BPF_EXIT_INSN(),
 		},
-		.fixup_map1 = { 4 },
+		.fixup_map_hash_8b = { 4 },
 		.errstr = "value_size=8 off=1073741825",
 		.result = REJECT,
 		.prog_type = BPF_PROG_TYPE_SCHED_CLS,
@@ -8271,7 +8271,7 @@ static struct bpf_test tests[] = {
 			BPF_MOV64_IMM(BPF_REG_0, 0),
 			BPF_EXIT_INSN(),
 		},
-		.fixup_map1 = { 4 },
+		.fixup_map_hash_8b = { 4 },
 		.errstr = "value 1073741823",
 		.result = REJECT,
 		.prog_type = BPF_PROG_TYPE_SCHED_CLS,
@@ -8307,7 +8307,7 @@ static struct bpf_test tests[] = {
 			BPF_MOV64_IMM(BPF_REG_0, 0),
 			BPF_EXIT_INSN(),
 		},
-		.fixup_map1 = { 3 },
+		.fixup_map_hash_8b = { 3 },
 		.result = ACCEPT
 	},
 	{
@@ -8346,7 +8346,7 @@ static struct bpf_test tests[] = {
 			BPF_MOV64_IMM(BPF_REG_0, 0),
 			BPF_EXIT_INSN(),
 		},
-		.fixup_map1 = { 3 },
+		.fixup_map_hash_8b = { 3 },
 		/* not actually fully unbounded, but the bound is very high */
 		.errstr = "R0 unbounded memory access",
 		.result = REJECT
@@ -8389,7 +8389,7 @@ static struct bpf_test tests[] = {
 			BPF_MOV64_IMM(BPF_REG_0, 0),
 			BPF_EXIT_INSN(),
 		},
-		.fixup_map1 = { 3 },
+		.fixup_map_hash_8b = { 3 },
 		/* not actually fully unbounded, but the bound is very high */
 		.errstr = "R0 unbounded memory access",
 		.result = REJECT
@@ -8418,7 +8418,7 @@ static struct bpf_test tests[] = {
 			BPF_MOV64_IMM(BPF_REG_0, 0),
 			BPF_EXIT_INSN(),
 		},
-		.fixup_map1 = { 3 },
+		.fixup_map_hash_8b = { 3 },
 		.result = ACCEPT
 	},
 	{
@@ -8445,7 +8445,7 @@ static struct bpf_test tests[] = {
 			BPF_MOV64_IMM(BPF_REG_0, 0),
 			BPF_EXIT_INSN(),
 		},
-		.fixup_map1 = { 3 },
+		.fixup_map_hash_8b = { 3 },
 		.errstr = "R0 max value is outside of the array range",
 		.result = REJECT
 	},
@@ -8475,7 +8475,7 @@ static struct bpf_test tests[] = {
 			BPF_MOV64_IMM(BPF_REG_0, 0),
 			BPF_EXIT_INSN(),
 		},
-		.fixup_map1 = { 3 },
+		.fixup_map_hash_8b = { 3 },
 		.errstr = "R0 unbounded memory access",
 		.result = REJECT
 	},
@@ -8495,7 +8495,7 @@ static struct bpf_test tests[] = {
 			BPF_JMP_A(0),
 			BPF_EXIT_INSN(),
 		},
-		.fixup_map1 = { 3 },
+		.fixup_map_hash_8b = { 3 },
 		.errstr = "map_value pointer and 2147483646",
 		.result = REJECT
 	},
@@ -8517,7 +8517,7 @@ static struct bpf_test tests[] = {
 			BPF_JMP_A(0),
 			BPF_EXIT_INSN(),
 		},
-		.fixup_map1 = { 3 },
+		.fixup_map_hash_8b = { 3 },
 		.errstr = "pointer offset 1073741822",
 		.result = REJECT
 	},
@@ -8538,7 +8538,7 @@ static struct bpf_test tests[] = {
 			BPF_JMP_A(0),
 			BPF_EXIT_INSN(),
 		},
-		.fixup_map1 = { 3 },
+		.fixup_map_hash_8b = { 3 },
 		.errstr = "pointer offset -1073741822",
 		.result = REJECT
 	},
@@ -8560,7 +8560,7 @@ static struct bpf_test tests[] = {
 			BPF_JMP_A(0),
 			BPF_EXIT_INSN(),
 		},
-		.fixup_map1 = { 3 },
+		.fixup_map_hash_8b = { 3 },
 		.errstr = "map_value pointer and 1000000000000",
 		.result = REJECT
 	},
@@ -8580,7 +8580,7 @@ static struct bpf_test tests[] = {
 			BPF_JMP_A(0),
 			BPF_EXIT_INSN(),
 		},
-		.fixup_map1 = { 3 },
+		.fixup_map_hash_8b = { 3 },
 		.result = ACCEPT,
 		.retval = POINTER_VALUE,
 		.result_unpriv = REJECT,
@@ -8601,7 +8601,7 @@ static struct bpf_test tests[] = {
 			BPF_LDX_MEM(BPF_DW, BPF_REG_0, BPF_REG_0, 0),
 			BPF_EXIT_INSN(),
 		},
-		.fixup_map1 = { 3 },
+		.fixup_map_hash_8b = { 3 },
 		.result = ACCEPT,
 		.retval = POINTER_VALUE,
 		.result_unpriv = REJECT,
@@ -8669,7 +8669,7 @@ static struct bpf_test tests[] = {
 			BPF_MOV64_IMM(BPF_REG_0, 0),
 			BPF_EXIT_INSN(),
 		},
-		.fixup_map1 = { 5 },
+		.fixup_map_hash_8b = { 5 },
 		.errstr = "variable stack read R2",
 		.result = REJECT,
 		.prog_type = BPF_PROG_TYPE_LWT_IN,
@@ -8750,7 +8750,7 @@ static struct bpf_test tests[] = {
 				   offsetof(struct test_val, foo)),
 			BPF_EXIT_INSN(),
 		},
-		.fixup_map2 = { 3 },
+		.fixup_map_hash_48b = { 3 },
 		.errstr_unpriv = "R0 leaks addr",
 		.errstr = "R0 unbounded memory access",
 		.result_unpriv = REJECT,
@@ -10284,7 +10284,7 @@ static struct bpf_test tests[] = {
 			BPF_EXIT_INSN(),
 		},
 		.prog_type = BPF_PROG_TYPE_SCHED_CLS,
-		.fixup_map1 = { 16 },
+		.fixup_map_hash_8b = { 16 },
 		.result = REJECT,
 		.errstr = "R0 min value is outside of the array range",
 	},
@@ -11235,7 +11235,7 @@ static struct bpf_test tests[] = {
 			BPF_EXIT_INSN(), /* return 0 */
 		},
 		.prog_type = BPF_PROG_TYPE_XDP,
-		.fixup_map1 = { 23 },
+		.fixup_map_hash_8b = { 23 },
 		.result = ACCEPT,
 	},
 	{
@@ -11290,7 +11290,7 @@ static struct bpf_test tests[] = {
 			BPF_EXIT_INSN(), /* return 1 */
 		},
 		.prog_type = BPF_PROG_TYPE_XDP,
-		.fixup_map1 = { 23 },
+		.fixup_map_hash_8b = { 23 },
 		.result = ACCEPT,
 	},
 	{
@@ -11345,7 +11345,7 @@ static struct bpf_test tests[] = {
 			BPF_EXIT_INSN(), /* return 1 */
 		},
 		.prog_type = BPF_PROG_TYPE_XDP,
-		.fixup_map1 = { 23 },
+		.fixup_map_hash_8b = { 23 },
 		.result = REJECT,
 		.errstr = "invalid read from stack off -16+0 size 8",
 	},
@@ -11417,7 +11417,7 @@ static struct bpf_test tests[] = {
 			BPF_EXIT_INSN(),
 		},
 		.prog_type = BPF_PROG_TYPE_SCHED_CLS,
-		.fixup_map1 = { 12, 22 },
+		.fixup_map_hash_8b = { 12, 22 },
 		.result = REJECT,
 		.errstr = "invalid access to map value, value_size=8 off=2 size=8",
 	},
@@ -11489,7 +11489,7 @@ static struct bpf_test tests[] = {
 			BPF_EXIT_INSN(),
 		},
 		.prog_type = BPF_PROG_TYPE_SCHED_CLS,
-		.fixup_map1 = { 12, 22 },
+		.fixup_map_hash_8b = { 12, 22 },
 		.result = ACCEPT,
 	},
 	{
@@ -11560,7 +11560,7 @@ static struct bpf_test tests[] = {
 			BPF_JMP_IMM(BPF_JA, 0, 0, -8),
 		},
 		.prog_type = BPF_PROG_TYPE_SCHED_CLS,
-		.fixup_map1 = { 12, 22 },
+		.fixup_map_hash_8b = { 12, 22 },
 		.result = REJECT,
 		.errstr = "invalid access to map value, value_size=8 off=2 size=8",
 	},
@@ -11632,7 +11632,7 @@ static struct bpf_test tests[] = {
 			BPF_EXIT_INSN(),
 		},
 		.prog_type = BPF_PROG_TYPE_SCHED_CLS,
-		.fixup_map1 = { 12, 22 },
+		.fixup_map_hash_8b = { 12, 22 },
 		.result = ACCEPT,
 	},
 	{
@@ -11703,7 +11703,7 @@ static struct bpf_test tests[] = {
 			BPF_EXIT_INSN(),
 		},
 		.prog_type = BPF_PROG_TYPE_SCHED_CLS,
-		.fixup_map1 = { 12, 22 },
+		.fixup_map_hash_8b = { 12, 22 },
 		.result = REJECT,
 		.errstr = "R0 invalid mem access 'inv'",
 	},
@@ -12048,7 +12048,7 @@ static struct bpf_test tests[] = {
 			BPF_STX_MEM(BPF_DW, BPF_REG_6, BPF_REG_0, 0),
 			BPF_EXIT_INSN(),
 		},
-		.fixup_map1 = { 13 },
+		.fixup_map_hash_8b = { 13 },
 		.result = ACCEPT,
 		.prog_type = BPF_PROG_TYPE_XDP,
 	},
@@ -12075,7 +12075,7 @@ static struct bpf_test tests[] = {
 				     BPF_FUNC_map_lookup_elem),
 			BPF_EXIT_INSN(),
 		},
-		.fixup_map2 = { 6 },
+		.fixup_map_hash_48b = { 6 },
 		.errstr = "invalid indirect read from stack off -8+0 size 8",
 		.result = REJECT,
 		.prog_type = BPF_PROG_TYPE_XDP,
@@ -12107,8 +12107,8 @@ static struct bpf_test tests[] = {
 			BPF_EXIT_INSN(),
 		},
 		.prog_type = BPF_PROG_TYPE_SCHED_CLS,
-		.fixup_map2 = { 13 },
-		.fixup_map4 = { 16 },
+		.fixup_map_hash_48b = { 13 },
+		.fixup_map_array_48b = { 16 },
 		.result = ACCEPT,
 		.retval = 1,
 	},
@@ -12140,7 +12140,7 @@ static struct bpf_test tests[] = {
 		},
 		.prog_type = BPF_PROG_TYPE_SCHED_CLS,
 		.fixup_map_in_map = { 16 },
-		.fixup_map4 = { 13 },
+		.fixup_map_array_48b = { 13 },
 		.result = REJECT,
 		.errstr = "R0 invalid mem access 'map_ptr'",
 	},
@@ -12208,7 +12208,7 @@ static struct bpf_test tests[] = {
 			BPF_ST_MEM(BPF_DW, BPF_REG_6, 0, 0xdead),
 			BPF_EXIT_INSN(),
 		},
-		.fixup_map1 = { 3 },
+		.fixup_map_hash_8b = { 3 },
 		.errstr = "R6 invalid mem access 'inv'",
 		.result = REJECT,
 		.prog_type = BPF_PROG_TYPE_TRACEPOINT,
@@ -12232,7 +12232,7 @@ static struct bpf_test tests[] = {
 			BPF_LDX_MEM(BPF_DW, BPF_REG_5, BPF_REG_10, -16),
 			BPF_EXIT_INSN(),
 		},
-		.fixup_map1 = { 3 },
+		.fixup_map_hash_8b = { 3 },
 		.errstr = "invalid read from stack off -16+0 size 8",
 		.result = REJECT,
 		.prog_type = BPF_PROG_TYPE_TRACEPOINT,
@@ -12354,7 +12354,7 @@ static struct bpf_test tests[] = {
 			BPF_LDX_MEM(BPF_W, BPF_REG_0, BPF_REG_0, 3),
 			BPF_EXIT_INSN(),
 		},
-		.fixup_map1 = { 3 },
+		.fixup_map_hash_8b = { 3 },
 		.result = REJECT,
 		.errstr = "misaligned value access off",
 		.prog_type = BPF_PROG_TYPE_SCHED_CLS,
@@ -12464,7 +12464,7 @@ static struct bpf_test tests[] = {
 			BPF_EMIT_CALL(BPF_FUNC_get_stack),
 			BPF_EXIT_INSN(),
 		},
-		.fixup_map2 = { 4 },
+		.fixup_map_hash_48b = { 4 },
 		.result = ACCEPT,
 		.prog_type = BPF_PROG_TYPE_TRACEPOINT,
 	},
@@ -13511,10 +13511,10 @@ static char bpf_vlog[UINT_MAX >> 8];
 static void do_test_fixup(struct bpf_test *test, enum bpf_map_type prog_type,
 			  struct bpf_insn *prog, int *map_fds)
 {
-	int *fixup_map1 = test->fixup_map1;
-	int *fixup_map2 = test->fixup_map2;
-	int *fixup_map3 = test->fixup_map3;
-	int *fixup_map4 = test->fixup_map4;
+	int *fixup_map_hash_8b = test->fixup_map_hash_8b;
+	int *fixup_map_hash_48b = test->fixup_map_hash_48b;
+	int *fixup_map_hash_16b = test->fixup_map_hash_16b;
+	int *fixup_map_array_48b = test->fixup_map_array_48b;
 	int *fixup_prog1 = test->fixup_prog1;
 	int *fixup_prog2 = test->fixup_prog2;
 	int *fixup_map_in_map = test->fixup_map_in_map;
@@ -13528,40 +13528,40 @@ static void do_test_fixup(struct bpf_test *test, enum bpf_map_type prog_type,
 	 * for verifier and not do a runtime lookup, so the only thing
 	 * that really matters is value size in this case.
 	 */
-	if (*fixup_map1) {
+	if (*fixup_map_hash_8b) {
 		map_fds[0] = create_map(BPF_MAP_TYPE_HASH, sizeof(long long),
 					sizeof(long long), 1);
 		do {
-			prog[*fixup_map1].imm = map_fds[0];
-			fixup_map1++;
-		} while (*fixup_map1);
+			prog[*fixup_map_hash_8b].imm = map_fds[0];
+			fixup_map_hash_8b++;
+		} while (*fixup_map_hash_8b);
 	}
 
-	if (*fixup_map2) {
+	if (*fixup_map_hash_48b) {
 		map_fds[1] = create_map(BPF_MAP_TYPE_HASH, sizeof(long long),
 					sizeof(struct test_val), 1);
 		do {
-			prog[*fixup_map2].imm = map_fds[1];
-			fixup_map2++;
-		} while (*fixup_map2);
+			prog[*fixup_map_hash_48b].imm = map_fds[1];
+			fixup_map_hash_48b++;
+		} while (*fixup_map_hash_48b);
 	}
 
-	if (*fixup_map3) {
+	if (*fixup_map_hash_16b) {
 		map_fds[2] = create_map(BPF_MAP_TYPE_HASH, sizeof(long long),
 					sizeof(struct other_val), 1);
 		do {
-			prog[*fixup_map3].imm = map_fds[2];
-			fixup_map3++;
-		} while (*fixup_map3);
+			prog[*fixup_map_hash_16b].imm = map_fds[2];
+			fixup_map_hash_16b++;
+		} while (*fixup_map_hash_16b);
 	}
 
-	if (*fixup_map4) {
+	if (*fixup_map_array_48b) {
 		map_fds[3] = create_map(BPF_MAP_TYPE_ARRAY, sizeof(int),
 					sizeof(struct test_val), 1);
 		do {
-			prog[*fixup_map4].imm = map_fds[3];
-			fixup_map4++;
-		} while (*fixup_map4);
+			prog[*fixup_map_array_48b].imm = map_fds[3];
+			fixup_map_array_48b++;
+		} while (*fixup_map_array_48b);
 	}
 
 	if (*fixup_prog1) {
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH bpf-next 6/6] selftests/bpf: test_verifier, check bpf_map_lookup_elem access in bpf prog
  2018-10-09  1:04 [PATCH bpf-next 0/6] Error handling when map lookup isn't supported Prashant Bhole
                   ` (4 preceding siblings ...)
  2018-10-09  1:04 ` [PATCH bpf-next 5/6] selftests/bpf: test_verifier, change names of fixup maps Prashant Bhole
@ 2018-10-09  1:04 ` Prashant Bhole
  2018-10-09  7:02   ` Song Liu
  2018-10-10  4:55 ` [PATCH bpf-next 0/6] Error handling when map lookup isn't supported Alexei Starovoitov
  6 siblings, 1 reply; 16+ messages in thread
From: Prashant Bhole @ 2018-10-09  1:04 UTC (permalink / raw)
  To: Alexei Starovoitov, Daniel Borkmann
  Cc: Prashant Bhole, Jakub Kicinski, David S . Miller, Quentin Monnet, netdev

map_lookup_elem isn't supported by certain map types like:
- BPF_MAP_TYPE_PROG_ARRAY
- BPF_MAP_TYPE_STACK_TRACE
- BPF_MAP_TYPE_XSKMAP
- BPF_MAP_TYPE_SOCKMAP/BPF_MAP_TYPE_SOCKHASH
Let's add verfier tests to check whether verifier prevents
bpf_map_lookup_elem call on above programs from bpf program.

Signed-off-by: Prashant Bhole <bhole_prashant_q7@lab.ntt.co.jp>
Acked-by: Alexei Starovoitov <ast@kernel.org>
---
 tools/testing/selftests/bpf/test_verifier.c | 121 +++++++++++++++++++-
 1 file changed, 120 insertions(+), 1 deletion(-)

diff --git a/tools/testing/selftests/bpf/test_verifier.c b/tools/testing/selftests/bpf/test_verifier.c
index 65ae44c85d27..cf4cd32b6772 100644
--- a/tools/testing/selftests/bpf/test_verifier.c
+++ b/tools/testing/selftests/bpf/test_verifier.c
@@ -48,7 +48,7 @@
 
 #define MAX_INSNS	BPF_MAXINSNS
 #define MAX_FIXUPS	8
-#define MAX_NR_MAPS	8
+#define MAX_NR_MAPS	13
 #define POINTER_VALUE	0xcafe4all
 #define TEST_DATA_LEN	64
 
@@ -65,6 +65,10 @@ struct bpf_test {
 	int fixup_map_hash_48b[MAX_FIXUPS];
 	int fixup_map_hash_16b[MAX_FIXUPS];
 	int fixup_map_array_48b[MAX_FIXUPS];
+	int fixup_map_sockmap[MAX_FIXUPS];
+	int fixup_map_sockhash[MAX_FIXUPS];
+	int fixup_map_xskmap[MAX_FIXUPS];
+	int fixup_map_stacktrace[MAX_FIXUPS];
 	int fixup_prog1[MAX_FIXUPS];
 	int fixup_prog2[MAX_FIXUPS];
 	int fixup_map_in_map[MAX_FIXUPS];
@@ -4541,6 +4545,85 @@ static struct bpf_test tests[] = {
 		.errstr = "invalid access to packet",
 		.prog_type = BPF_PROG_TYPE_SCHED_CLS,
 	},
+	{
+		"prevent map lookup in sockmap",
+		.insns = {
+			BPF_ST_MEM(BPF_DW, BPF_REG_10, -8, 0),
+			BPF_MOV64_REG(BPF_REG_2, BPF_REG_10),
+			BPF_ALU64_IMM(BPF_ADD, BPF_REG_2, -8),
+			BPF_LD_MAP_FD(BPF_REG_1, 0),
+			BPF_RAW_INSN(BPF_JMP | BPF_CALL, 0, 0, 0,
+				     BPF_FUNC_map_lookup_elem),
+			BPF_EXIT_INSN(),
+		},
+		.fixup_map_sockmap = { 3 },
+		.result = REJECT,
+		.errstr = "cannot pass map_type 15 into func bpf_map_lookup_elem",
+		.prog_type = BPF_PROG_TYPE_SOCK_OPS,
+	},
+	{
+		"prevent map lookup in sockhash",
+		.insns = {
+			BPF_ST_MEM(BPF_DW, BPF_REG_10, -8, 0),
+			BPF_MOV64_REG(BPF_REG_2, BPF_REG_10),
+			BPF_ALU64_IMM(BPF_ADD, BPF_REG_2, -8),
+			BPF_LD_MAP_FD(BPF_REG_1, 0),
+			BPF_RAW_INSN(BPF_JMP | BPF_CALL, 0, 0, 0,
+				     BPF_FUNC_map_lookup_elem),
+			BPF_EXIT_INSN(),
+		},
+		.fixup_map_sockhash = { 3 },
+		.result = REJECT,
+		.errstr = "cannot pass map_type 18 into func bpf_map_lookup_elem",
+		.prog_type = BPF_PROG_TYPE_SOCK_OPS,
+	},
+	{
+		"prevent map lookup in xskmap",
+		.insns = {
+			BPF_ST_MEM(BPF_DW, BPF_REG_10, -8, 0),
+			BPF_MOV64_REG(BPF_REG_2, BPF_REG_10),
+			BPF_ALU64_IMM(BPF_ADD, BPF_REG_2, -8),
+			BPF_LD_MAP_FD(BPF_REG_1, 0),
+			BPF_RAW_INSN(BPF_JMP | BPF_CALL, 0, 0, 0,
+				     BPF_FUNC_map_lookup_elem),
+			BPF_EXIT_INSN(),
+		},
+		.fixup_map_xskmap = { 3 },
+		.result = REJECT,
+		.errstr = "cannot pass map_type 17 into func bpf_map_lookup_elem",
+		.prog_type = BPF_PROG_TYPE_XDP,
+	},
+	{
+		"prevent map lookup in stack trace",
+		.insns = {
+			BPF_ST_MEM(BPF_DW, BPF_REG_10, -8, 0),
+			BPF_MOV64_REG(BPF_REG_2, BPF_REG_10),
+			BPF_ALU64_IMM(BPF_ADD, BPF_REG_2, -8),
+			BPF_LD_MAP_FD(BPF_REG_1, 0),
+			BPF_RAW_INSN(BPF_JMP | BPF_CALL, 0, 0, 0,
+				     BPF_FUNC_map_lookup_elem),
+			BPF_EXIT_INSN(),
+		},
+		.fixup_map_stacktrace = { 3 },
+		.result = REJECT,
+		.errstr = "cannot pass map_type 7 into func bpf_map_lookup_elem",
+		.prog_type = BPF_PROG_TYPE_PERF_EVENT,
+	},
+	{
+		"prevent map lookup in prog array",
+		.insns = {
+			BPF_ST_MEM(BPF_DW, BPF_REG_10, -8, 0),
+			BPF_MOV64_REG(BPF_REG_2, BPF_REG_10),
+			BPF_ALU64_IMM(BPF_ADD, BPF_REG_2, -8),
+			BPF_LD_MAP_FD(BPF_REG_1, 0),
+			BPF_RAW_INSN(BPF_JMP | BPF_CALL, 0, 0, 0,
+				     BPF_FUNC_map_lookup_elem),
+			BPF_EXIT_INSN(),
+		},
+		.fixup_prog2 = { 3 },
+		.result = REJECT,
+		.errstr = "cannot pass map_type 3 into func bpf_map_lookup_elem",
+	},
 	{
 		"valid map access into an array with a constant",
 		.insns = {
@@ -13515,6 +13598,10 @@ static void do_test_fixup(struct bpf_test *test, enum bpf_map_type prog_type,
 	int *fixup_map_hash_48b = test->fixup_map_hash_48b;
 	int *fixup_map_hash_16b = test->fixup_map_hash_16b;
 	int *fixup_map_array_48b = test->fixup_map_array_48b;
+	int *fixup_map_sockmap = test->fixup_map_sockmap;
+	int *fixup_map_sockhash = test->fixup_map_sockhash;
+	int *fixup_map_xskmap = test->fixup_map_xskmap;
+	int *fixup_map_stacktrace = test->fixup_map_stacktrace;
 	int *fixup_prog1 = test->fixup_prog1;
 	int *fixup_prog2 = test->fixup_prog2;
 	int *fixup_map_in_map = test->fixup_map_in_map;
@@ -13603,6 +13690,38 @@ static void do_test_fixup(struct bpf_test *test, enum bpf_map_type prog_type,
 			fixup_percpu_cgroup_storage++;
 		} while (*fixup_percpu_cgroup_storage);
 	}
+	if (*fixup_map_sockmap) {
+		map_fds[9] = create_map(BPF_MAP_TYPE_SOCKMAP, sizeof(int),
+					sizeof(int), 1);
+		do {
+			prog[*fixup_map_sockmap].imm = map_fds[9];
+			fixup_map_sockmap++;
+		} while (*fixup_map_sockmap);
+	}
+	if (*fixup_map_sockhash) {
+		map_fds[10] = create_map(BPF_MAP_TYPE_SOCKHASH, sizeof(int),
+					sizeof(int), 1);
+		do {
+			prog[*fixup_map_sockhash].imm = map_fds[10];
+			fixup_map_sockhash++;
+		} while (*fixup_map_sockhash);
+	}
+	if (*fixup_map_xskmap) {
+		map_fds[11] = create_map(BPF_MAP_TYPE_XSKMAP, sizeof(int),
+					sizeof(int), 1);
+		do {
+			prog[*fixup_map_xskmap].imm = map_fds[11];
+			fixup_map_xskmap++;
+		} while (*fixup_map_xskmap);
+	}
+	if (*fixup_map_stacktrace) {
+		map_fds[12] = create_map(BPF_MAP_TYPE_STACK_TRACE, sizeof(u32),
+					 sizeof(u64), 1);
+		do {
+			prog[*fixup_map_stacktrace].imm = map_fds[12];
+			fixup_map_stacktrace++;
+		} while (fixup_map_stacktrace);
+	}
 }
 
 static void do_test_single(struct bpf_test *test, bool unpriv,
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* Re: [PATCH bpf-next 1/6] bpf: error handling when map_lookup_elem isn't supported
  2018-10-09  1:04 ` [PATCH bpf-next 1/6] bpf: error handling when map_lookup_elem " Prashant Bhole
@ 2018-10-09  6:57   ` Song Liu
  0 siblings, 0 replies; 16+ messages in thread
From: Song Liu @ 2018-10-09  6:57 UTC (permalink / raw)
  To: Prashant Bhole
  Cc: Alexei Starovoitov, Daniel Borkmann, Jakub Kicinski,
	David S . Miller, Quentin Monnet, Networking

On Mon, Oct 8, 2018 at 6:06 PM Prashant Bhole
<bhole_prashant_q7@lab.ntt.co.jp> wrote:
>
> The error value returned by map_lookup_elem doesn't differentiate
> whether lookup was failed because of invalid key or lookup is not
> supported.
>
> Lets add handling for -EOPNOTSUPP return value of map_lookup_elem()
> method of map, with expectation from map's implementation that it
> should return -EOPNOTSUPP if lookup is not supported.
>
> The errno for bpf syscall for BPF_MAP_LOOKUP_ELEM command will be set
> to EOPNOTSUPP if map lookup is not supported.
>
> Signed-off-by: Prashant Bhole <bhole_prashant_q7@lab.ntt.co.jp>
> Acked-by: Alexei Starovoitov <ast@kernel.org>

Acked-by: Song Liu <songliubraving@fb.com>

> ---
>  kernel/bpf/syscall.c | 9 +++++++--
>  1 file changed, 7 insertions(+), 2 deletions(-)
>
> diff --git a/kernel/bpf/syscall.c b/kernel/bpf/syscall.c
> index 5742df21598c..4f416234251f 100644
> --- a/kernel/bpf/syscall.c
> +++ b/kernel/bpf/syscall.c
> @@ -719,10 +719,15 @@ static int map_lookup_elem(union bpf_attr *attr)
>         } else {
>                 rcu_read_lock();
>                 ptr = map->ops->map_lookup_elem(map, key);
> -               if (ptr)
> +               if (IS_ERR(ptr)) {
> +                       err = PTR_ERR(ptr);
> +               } else if (!ptr) {
> +                       err = -ENOENT;
> +               } else {
> +                       err = 0;
>                         memcpy(value, ptr, value_size);
> +               }
>                 rcu_read_unlock();
> -               err = ptr ? 0 : -ENOENT;
>         }
>
>         if (err)
> --
> 2.17.1
>
>

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH bpf-next 2/6] bpf: return EOPNOTSUPP when map lookup isn't supported
  2018-10-09  1:04 ` [PATCH bpf-next 2/6] bpf: return EOPNOTSUPP when map lookup " Prashant Bhole
@ 2018-10-09  6:58   ` Song Liu
  0 siblings, 0 replies; 16+ messages in thread
From: Song Liu @ 2018-10-09  6:58 UTC (permalink / raw)
  To: Prashant Bhole
  Cc: Alexei Starovoitov, Daniel Borkmann, Jakub Kicinski,
	David S . Miller, Quentin Monnet, Networking

On Mon, Oct 8, 2018 at 6:06 PM Prashant Bhole
<bhole_prashant_q7@lab.ntt.co.jp> wrote:
>
> Return ERR_PTR(-EOPNOTSUPP) from map_lookup_elem() methods of below
> map types:
> - BPF_MAP_TYPE_PROG_ARRAY
> - BPF_MAP_TYPE_STACK_TRACE
> - BPF_MAP_TYPE_XSKMAP
> - BPF_MAP_TYPE_SOCKMAP/BPF_MAP_TYPE_SOCKHASH
>
> Signed-off-by: Prashant Bhole <bhole_prashant_q7@lab.ntt.co.jp>
> Acked-by: Alexei Starovoitov <ast@kernel.org>
Acked-by: Song Liu <songliubraving@fb.com>
> ---
>  kernel/bpf/arraymap.c | 2 +-
>  kernel/bpf/sockmap.c  | 2 +-
>  kernel/bpf/stackmap.c | 2 +-
>  kernel/bpf/xskmap.c   | 2 +-
>  4 files changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/kernel/bpf/arraymap.c b/kernel/bpf/arraymap.c
> index dded84cbe814..24583da9ffd1 100644
> --- a/kernel/bpf/arraymap.c
> +++ b/kernel/bpf/arraymap.c
> @@ -449,7 +449,7 @@ static void fd_array_map_free(struct bpf_map *map)
>
>  static void *fd_array_map_lookup_elem(struct bpf_map *map, void *key)
>  {
> -       return NULL;
> +       return ERR_PTR(-EOPNOTSUPP);
>  }
>
>  /* only called from syscall */
> diff --git a/kernel/bpf/sockmap.c b/kernel/bpf/sockmap.c
> index d37a1a0a6e1e..5d0677d808ae 100644
> --- a/kernel/bpf/sockmap.c
> +++ b/kernel/bpf/sockmap.c
> @@ -2096,7 +2096,7 @@ int sockmap_get_from_fd(const union bpf_attr *attr, int type,
>
>  static void *sock_map_lookup(struct bpf_map *map, void *key)
>  {
> -       return NULL;
> +       return ERR_PTR(-EOPNOTSUPP);
>  }
>
>  static int sock_map_update_elem(struct bpf_map *map,
> diff --git a/kernel/bpf/stackmap.c b/kernel/bpf/stackmap.c
> index 8061a439ef18..b2ade10f7ec3 100644
> --- a/kernel/bpf/stackmap.c
> +++ b/kernel/bpf/stackmap.c
> @@ -505,7 +505,7 @@ const struct bpf_func_proto bpf_get_stack_proto = {
>  /* Called from eBPF program */
>  static void *stack_map_lookup_elem(struct bpf_map *map, void *key)
>  {
> -       return NULL;
> +       return ERR_PTR(-EOPNOTSUPP);
>  }
>
>  /* Called from syscall */
> diff --git a/kernel/bpf/xskmap.c b/kernel/bpf/xskmap.c
> index 9f8463afda9c..ef0b7b6ef8a5 100644
> --- a/kernel/bpf/xskmap.c
> +++ b/kernel/bpf/xskmap.c
> @@ -154,7 +154,7 @@ void __xsk_map_flush(struct bpf_map *map)
>
>  static void *xsk_map_lookup_elem(struct bpf_map *map, void *key)
>  {
> -       return NULL;
> +       return ERR_PTR(-EOPNOTSUPP);
>  }
>
>  static int xsk_map_update_elem(struct bpf_map *map, void *key, void *value,
> --
> 2.17.1
>
>

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH bpf-next 3/6] tools/bpf: bpftool, split the function do_dump()
  2018-10-09  1:04 ` [PATCH bpf-next 3/6] tools/bpf: bpftool, split the function do_dump() Prashant Bhole
@ 2018-10-09  6:58   ` Song Liu
  0 siblings, 0 replies; 16+ messages in thread
From: Song Liu @ 2018-10-09  6:58 UTC (permalink / raw)
  To: Prashant Bhole
  Cc: Alexei Starovoitov, Daniel Borkmann, Jakub Kicinski,
	David S . Miller, Quentin Monnet, Networking

On Mon, Oct 8, 2018 at 6:06 PM Prashant Bhole
<bhole_prashant_q7@lab.ntt.co.jp> wrote:
>
> do_dump() function in bpftool/map.c has deep indentations. In order
> to reduce deep indent, let's move element printing code out of
> do_dump() into dump_map_elem() function.
>
> Signed-off-by: Prashant Bhole <bhole_prashant_q7@lab.ntt.co.jp>
> Acked-by: Jakub Kicinski <jakub.kicinski@netronome.com>
> Acked-by: Alexei Starovoitov <ast@kernel.org>

Acked-by: Song Liu <songliubraving@fb.com>

> ---
>  tools/bpf/bpftool/map.c | 83 ++++++++++++++++++++++++-----------------
>  1 file changed, 49 insertions(+), 34 deletions(-)
>
> diff --git a/tools/bpf/bpftool/map.c b/tools/bpf/bpftool/map.c
> index 6003e9598973..28d365435fea 100644
> --- a/tools/bpf/bpftool/map.c
> +++ b/tools/bpf/bpftool/map.c
> @@ -658,6 +658,54 @@ static int do_show(int argc, char **argv)
>         return errno == ENOENT ? 0 : -1;
>  }
>
> +static int dump_map_elem(int fd, void *key, void *value,
> +                        struct bpf_map_info *map_info, struct btf *btf,
> +                        json_writer_t *btf_wtr)
> +{
> +       int num_elems = 0;
> +
> +       if (!bpf_map_lookup_elem(fd, key, value)) {
> +               if (json_output) {
> +                       print_entry_json(map_info, key, value, btf);
> +               } else {
> +                       if (btf) {
> +                               struct btf_dumper d = {
> +                                       .btf = btf,
> +                                       .jw = btf_wtr,
> +                                       .is_plain_text = true,
> +                               };
> +
> +                               do_dump_btf(&d, map_info, key, value);
> +                       } else {
> +                               print_entry_plain(map_info, key, value);
> +                       }
> +                       num_elems++;
> +               }
> +               return num_elems;
> +       }
> +
> +       /* lookup error handling */
> +       if (map_is_map_of_maps(map_info->type) ||
> +           map_is_map_of_progs(map_info->type))
> +               return 0;
> +
> +       if (json_output) {
> +               jsonw_name(json_wtr, "key");
> +               print_hex_data_json(key, map_info->key_size);
> +               jsonw_name(json_wtr, "value");
> +               jsonw_start_object(json_wtr);
> +               jsonw_string_field(json_wtr, "error",
> +                                  "can't lookup element");
> +               jsonw_end_object(json_wtr);
> +       } else {
> +               p_info("can't lookup element with key: ");
> +               fprint_hex(stderr, key, map_info->key_size, " ");
> +               fprintf(stderr, "\n");
> +       }
> +
> +       return 0;
> +}
> +
>  static int do_dump(int argc, char **argv)
>  {
>         struct bpf_map_info info = {};
> @@ -713,40 +761,7 @@ static int do_dump(int argc, char **argv)
>                                 err = 0;
>                         break;
>                 }
> -
> -               if (!bpf_map_lookup_elem(fd, key, value)) {
> -                       if (json_output)
> -                               print_entry_json(&info, key, value, btf);
> -                       else
> -                               if (btf) {
> -                                       struct btf_dumper d = {
> -                                               .btf = btf,
> -                                               .jw = btf_wtr,
> -                                               .is_plain_text = true,
> -                                       };
> -
> -                                       do_dump_btf(&d, &info, key, value);
> -                               } else {
> -                                       print_entry_plain(&info, key, value);
> -                               }
> -                       num_elems++;
> -               } else if (!map_is_map_of_maps(info.type) &&
> -                          !map_is_map_of_progs(info.type)) {
> -                       if (json_output) {
> -                               jsonw_name(json_wtr, "key");
> -                               print_hex_data_json(key, info.key_size);
> -                               jsonw_name(json_wtr, "value");
> -                               jsonw_start_object(json_wtr);
> -                               jsonw_string_field(json_wtr, "error",
> -                                                  "can't lookup element");
> -                               jsonw_end_object(json_wtr);
> -                       } else {
> -                               p_info("can't lookup element with key: ");
> -                               fprint_hex(stderr, key, info.key_size, " ");
> -                               fprintf(stderr, "\n");
> -                       }
> -               }
> -
> +               num_elems += dump_map_elem(fd, key, value, &info, btf, btf_wtr);
>                 prev_key = key;
>         }
>
> --
> 2.17.1
>
>

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH bpf-next 4/6] tools/bpf: bpftool, print strerror when map lookup error occurs
  2018-10-09  1:04 ` [PATCH bpf-next 4/6] tools/bpf: bpftool, print strerror when map lookup error occurs Prashant Bhole
@ 2018-10-09  7:00   ` Song Liu
  0 siblings, 0 replies; 16+ messages in thread
From: Song Liu @ 2018-10-09  7:00 UTC (permalink / raw)
  To: Prashant Bhole
  Cc: Alexei Starovoitov, Daniel Borkmann, Jakub Kicinski,
	David S . Miller, Quentin Monnet, Networking

On Mon, Oct 8, 2018 at 6:06 PM Prashant Bhole
<bhole_prashant_q7@lab.ntt.co.jp> wrote:
>
> Since map lookup error can be ENOENT or EOPNOTSUPP, let's print
> strerror() as error message in normal and JSON output.
>
> This patch adds helper function print_entry_error() to print
> entry from lookup error occurs
>
> Example: Following example dumps a map which does not support lookup.
>
> Output before:
> root# bpftool map -jp dump id 40
> [
>     "key": ["0x0a","0x00","0x00","0x00"
>     ],
>     "value": {
>         "error": "can\'t lookup element"
>     },
>     "key": ["0x0b","0x00","0x00","0x00"
>     ],
>     "value": {
>         "error": "can\'t lookup element"
>     }
> ]
>
> root# bpftool map dump id 40
> can't lookup element with key:
> 0a 00 00 00
> can't lookup element with key:
> 0b 00 00 00
> Found 0 elements
>
> Output after changes:
> root# bpftool map dump -jp  id 45
> [
>     "key": ["0x0a","0x00","0x00","0x00"
>     ],
>     "value": {
>         "error": "Operation not supported"
>     },
>     "key": ["0x0b","0x00","0x00","0x00"
>     ],
>     "value": {
>         "error": "Operation not supported"
>     }
> ]
>
> root# bpftool map dump id 45
> key:
> 0a 00 00 00
> value:
> Operation not supported
> key:
> 0b 00 00 00
> value:
> Operation not supported
> Found 0 elements
>
> Signed-off-by: Prashant Bhole <bhole_prashant_q7@lab.ntt.co.jp>
> Acked-by: Jakub Kicinski <jakub.kicinski@netronome.com>
> Acked-by: Alexei Starovoitov <ast@kernel.org>

Acked-by: Song Liu <songliubraving@fb.com>

> ---
>  tools/bpf/bpftool/map.c | 29 ++++++++++++++++++++++++-----
>  1 file changed, 24 insertions(+), 5 deletions(-)
>
> diff --git a/tools/bpf/bpftool/map.c b/tools/bpf/bpftool/map.c
> index 28d365435fea..9f5de48f8a99 100644
> --- a/tools/bpf/bpftool/map.c
> +++ b/tools/bpf/bpftool/map.c
> @@ -336,6 +336,25 @@ static void print_entry_json(struct bpf_map_info *info, unsigned char *key,
>         jsonw_end_object(json_wtr);
>  }
>
> +static void print_entry_error(struct bpf_map_info *info, unsigned char *key,
> +                             const char *value)
> +{
> +       int value_size = strlen(value);
> +       bool single_line, break_names;
> +
> +       break_names = info->key_size > 16 || value_size > 16;
> +       single_line = info->key_size + value_size <= 24 && !break_names;
> +
> +       printf("key:%c", break_names ? '\n' : ' ');
> +       fprint_hex(stdout, key, info->key_size, " ");
> +
> +       printf(single_line ? "  " : "\n");
> +
> +       printf("value:%c%s", break_names ? '\n' : ' ', value);
> +
> +       printf("\n");
> +}
> +
>  static void print_entry_plain(struct bpf_map_info *info, unsigned char *key,
>                               unsigned char *value)
>  {
> @@ -663,6 +682,7 @@ static int dump_map_elem(int fd, void *key, void *value,
>                          json_writer_t *btf_wtr)
>  {
>         int num_elems = 0;
> +       int lookup_errno;
>
>         if (!bpf_map_lookup_elem(fd, key, value)) {
>                 if (json_output) {
> @@ -685,6 +705,8 @@ static int dump_map_elem(int fd, void *key, void *value,
>         }
>
>         /* lookup error handling */
> +       lookup_errno = errno;
> +
>         if (map_is_map_of_maps(map_info->type) ||
>             map_is_map_of_progs(map_info->type))
>                 return 0;
> @@ -694,13 +716,10 @@ static int dump_map_elem(int fd, void *key, void *value,
>                 print_hex_data_json(key, map_info->key_size);
>                 jsonw_name(json_wtr, "value");
>                 jsonw_start_object(json_wtr);
> -               jsonw_string_field(json_wtr, "error",
> -                                  "can't lookup element");
> +               jsonw_string_field(json_wtr, "error", strerror(lookup_errno));
>                 jsonw_end_object(json_wtr);
>         } else {
> -               p_info("can't lookup element with key: ");
> -               fprint_hex(stderr, key, map_info->key_size, " ");
> -               fprintf(stderr, "\n");
> +               print_entry_error(map_info, key, strerror(lookup_errno));
>         }
>
>         return 0;
> --
> 2.17.1
>
>

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH bpf-next 5/6] selftests/bpf: test_verifier, change names of fixup maps
  2018-10-09  1:04 ` [PATCH bpf-next 5/6] selftests/bpf: test_verifier, change names of fixup maps Prashant Bhole
@ 2018-10-09  7:01   ` Song Liu
  0 siblings, 0 replies; 16+ messages in thread
From: Song Liu @ 2018-10-09  7:01 UTC (permalink / raw)
  To: Prashant Bhole
  Cc: Alexei Starovoitov, Daniel Borkmann, Jakub Kicinski,
	David S . Miller, Quentin Monnet, Networking

On Mon, Oct 8, 2018 at 6:07 PM Prashant Bhole
<bhole_prashant_q7@lab.ntt.co.jp> wrote:
>
> Currently fixup map are named like fixup_map1, fixup_map2, and so on.
> As suggested by Alexei let's change change map names such that we can
> identify map type by looking at the name.
>
> This patch is basically a find and replace change:
> fixup_map1  ->  fixup_map_hash_8b
> fixup_map2  ->  fixup_map_hash_48b
> fixup_map3  ->  fixup_map_hash_16b
> fixup_map4  ->  fixup_map_array_48b
>
> Suggested-by: Alexei Starovoitov <ast@kernel.org>
> Signed-off-by: Prashant Bhole <bhole_prashant_q7@lab.ntt.co.jp>
> Acked-by: Alexei Starovoitov <ast@kernel.org>
Acked-by: Song Liu <songliubraving@fb.com>


> ---
>  tools/testing/selftests/bpf/test_verifier.c | 380 ++++++++++----------
>  1 file changed, 190 insertions(+), 190 deletions(-)
>
> diff --git a/tools/testing/selftests/bpf/test_verifier.c b/tools/testing/selftests/bpf/test_verifier.c
> index bc9cd8537467..65ae44c85d27 100644
> --- a/tools/testing/selftests/bpf/test_verifier.c
> +++ b/tools/testing/selftests/bpf/test_verifier.c
> @@ -61,10 +61,10 @@ static bool unpriv_disabled = false;
>  struct bpf_test {
>         const char *descr;
>         struct bpf_insn insns[MAX_INSNS];
> -       int fixup_map1[MAX_FIXUPS];
> -       int fixup_map2[MAX_FIXUPS];
> -       int fixup_map3[MAX_FIXUPS];
> -       int fixup_map4[MAX_FIXUPS];
> +       int fixup_map_hash_8b[MAX_FIXUPS];
> +       int fixup_map_hash_48b[MAX_FIXUPS];
> +       int fixup_map_hash_16b[MAX_FIXUPS];
> +       int fixup_map_array_48b[MAX_FIXUPS];
>         int fixup_prog1[MAX_FIXUPS];
>         int fixup_prog2[MAX_FIXUPS];
>         int fixup_map_in_map[MAX_FIXUPS];
> @@ -876,7 +876,7 @@ static struct bpf_test tests[] = {
>                                      BPF_FUNC_map_lookup_elem),
>                         BPF_EXIT_INSN(),
>                 },
> -               .fixup_map1 = { 2 },
> +               .fixup_map_hash_8b = { 2 },
>                 .errstr = "invalid indirect read from stack",
>                 .result = REJECT,
>         },
> @@ -1110,7 +1110,7 @@ static struct bpf_test tests[] = {
>                         BPF_ST_MEM(BPF_DW, BPF_REG_0, 0, 0),
>                         BPF_EXIT_INSN(),
>                 },
> -               .fixup_map1 = { 3 },
> +               .fixup_map_hash_8b = { 3 },
>                 .errstr = "R0 invalid mem access 'map_value_or_null'",
>                 .result = REJECT,
>         },
> @@ -1127,7 +1127,7 @@ static struct bpf_test tests[] = {
>                         BPF_ST_MEM(BPF_DW, BPF_REG_0, 4, 0),
>                         BPF_EXIT_INSN(),
>                 },
> -               .fixup_map1 = { 3 },
> +               .fixup_map_hash_8b = { 3 },
>                 .errstr = "misaligned value access",
>                 .result = REJECT,
>                 .flags = F_LOAD_WITH_STRICT_ALIGNMENT,
> @@ -1147,7 +1147,7 @@ static struct bpf_test tests[] = {
>                         BPF_ST_MEM(BPF_DW, BPF_REG_0, 0, 1),
>                         BPF_EXIT_INSN(),
>                 },
> -               .fixup_map1 = { 3 },
> +               .fixup_map_hash_8b = { 3 },
>                 .errstr = "R0 invalid mem access",
>                 .errstr_unpriv = "R0 leaks addr",
>                 .result = REJECT,
> @@ -1237,7 +1237,7 @@ static struct bpf_test tests[] = {
>                                      BPF_FUNC_map_delete_elem),
>                         BPF_EXIT_INSN(),
>                 },
> -               .fixup_map1 = { 24 },
> +               .fixup_map_hash_8b = { 24 },
>                 .errstr_unpriv = "R1 pointer comparison",
>                 .result_unpriv = REJECT,
>                 .result = ACCEPT,
> @@ -1391,7 +1391,7 @@ static struct bpf_test tests[] = {
>                                     offsetof(struct __sk_buff, pkt_type)),
>                         BPF_EXIT_INSN(),
>                 },
> -               .fixup_map1 = { 4 },
> +               .fixup_map_hash_8b = { 4 },
>                 .errstr = "different pointers",
>                 .errstr_unpriv = "R1 pointer comparison",
>                 .result = REJECT,
> @@ -1414,7 +1414,7 @@ static struct bpf_test tests[] = {
>                         BPF_MOV64_REG(BPF_REG_1, BPF_REG_0),
>                         BPF_JMP_IMM(BPF_JA, 0, 0, -12),
>                 },
> -               .fixup_map1 = { 6 },
> +               .fixup_map_hash_8b = { 6 },
>                 .errstr = "different pointers",
>                 .errstr_unpriv = "R1 pointer comparison",
>                 .result = REJECT,
> @@ -1438,7 +1438,7 @@ static struct bpf_test tests[] = {
>                         BPF_MOV64_REG(BPF_REG_1, BPF_REG_0),
>                         BPF_JMP_IMM(BPF_JA, 0, 0, -13),
>                 },
> -               .fixup_map1 = { 7 },
> +               .fixup_map_hash_8b = { 7 },
>                 .errstr = "different pointers",
>                 .errstr_unpriv = "R1 pointer comparison",
>                 .result = REJECT,
> @@ -2575,7 +2575,7 @@ static struct bpf_test tests[] = {
>                         BPF_MOV64_IMM(BPF_REG_0, 0),
>                         BPF_EXIT_INSN(),
>                 },
> -               .fixup_map1 = { 3 },
> +               .fixup_map_hash_8b = { 3 },
>                 .errstr_unpriv = "R4 leaks addr",
>                 .result_unpriv = REJECT,
>                 .result = ACCEPT,
> @@ -2592,7 +2592,7 @@ static struct bpf_test tests[] = {
>                         BPF_MOV64_IMM(BPF_REG_0, 0),
>                         BPF_EXIT_INSN(),
>                 },
> -               .fixup_map1 = { 3 },
> +               .fixup_map_hash_8b = { 3 },
>                 .errstr = "invalid indirect read from stack off -8+0 size 8",
>                 .result = REJECT,
>         },
> @@ -2894,7 +2894,7 @@ static struct bpf_test tests[] = {
>                         BPF_STX_MEM(BPF_DW, BPF_REG_0, BPF_REG_0, 0),
>                         BPF_EXIT_INSN(),
>                 },
> -               .fixup_map1 = { 3 },
> +               .fixup_map_hash_8b = { 3 },
>                 .errstr_unpriv = "R0 leaks addr",
>                 .result_unpriv = REJECT,
>                 .result = ACCEPT,
> @@ -2934,7 +2934,7 @@ static struct bpf_test tests[] = {
>                         BPF_MOV64_IMM(BPF_REG_0, 0),
>                         BPF_EXIT_INSN(),
>                 },
> -               .fixup_map1 = { 1 },
> +               .fixup_map_hash_8b = { 1 },
>                 .errstr_unpriv = "R1 pointer comparison",
>                 .result_unpriv = REJECT,
>                 .result = ACCEPT,
> @@ -4073,7 +4073,7 @@ static struct bpf_test tests[] = {
>                         BPF_MOV64_IMM(BPF_REG_0, 0),
>                         BPF_EXIT_INSN(),
>                 },
> -               .fixup_map1 = { 5 },
> +               .fixup_map_hash_8b = { 5 },
>                 .result_unpriv = ACCEPT,
>                 .result = ACCEPT,
>                 .prog_type = BPF_PROG_TYPE_XDP,
> @@ -4089,7 +4089,7 @@ static struct bpf_test tests[] = {
>                         BPF_MOV64_IMM(BPF_REG_0, 0),
>                         BPF_EXIT_INSN(),
>                 },
> -               .fixup_map1 = { 1 },
> +               .fixup_map_hash_8b = { 1 },
>                 .result = REJECT,
>                 .errstr = "invalid access to packet",
>                 .prog_type = BPF_PROG_TYPE_XDP,
> @@ -4117,7 +4117,7 @@ static struct bpf_test tests[] = {
>                         BPF_MOV64_IMM(BPF_REG_0, 0),
>                         BPF_EXIT_INSN(),
>                 },
> -               .fixup_map1 = { 11 },
> +               .fixup_map_hash_8b = { 11 },
>                 .result = ACCEPT,
>                 .prog_type = BPF_PROG_TYPE_XDP,
>         },
> @@ -4139,7 +4139,7 @@ static struct bpf_test tests[] = {
>                         BPF_MOV64_IMM(BPF_REG_0, 0),
>                         BPF_EXIT_INSN(),
>                 },
> -               .fixup_map1 = { 7 },
> +               .fixup_map_hash_8b = { 7 },
>                 .result = REJECT,
>                 .errstr = "invalid access to packet",
>                 .prog_type = BPF_PROG_TYPE_XDP,
> @@ -4161,7 +4161,7 @@ static struct bpf_test tests[] = {
>                         BPF_MOV64_IMM(BPF_REG_0, 0),
>                         BPF_EXIT_INSN(),
>                 },
> -               .fixup_map1 = { 6 },
> +               .fixup_map_hash_8b = { 6 },
>                 .result = REJECT,
>                 .errstr = "invalid access to packet",
>                 .prog_type = BPF_PROG_TYPE_XDP,
> @@ -4184,7 +4184,7 @@ static struct bpf_test tests[] = {
>                         BPF_MOV64_IMM(BPF_REG_0, 0),
>                         BPF_EXIT_INSN(),
>                 },
> -               .fixup_map1 = { 5 },
> +               .fixup_map_hash_8b = { 5 },
>                 .result = ACCEPT,
>                 .prog_type = BPF_PROG_TYPE_SCHED_CLS,
>         },
> @@ -4199,7 +4199,7 @@ static struct bpf_test tests[] = {
>                         BPF_MOV64_IMM(BPF_REG_0, 0),
>                         BPF_EXIT_INSN(),
>                 },
> -               .fixup_map1 = { 1 },
> +               .fixup_map_hash_8b = { 1 },
>                 .result = REJECT,
>                 .errstr = "invalid access to packet",
>                 .prog_type = BPF_PROG_TYPE_SCHED_CLS,
> @@ -4227,7 +4227,7 @@ static struct bpf_test tests[] = {
>                         BPF_MOV64_IMM(BPF_REG_0, 0),
>                         BPF_EXIT_INSN(),
>                 },
> -               .fixup_map1 = { 11 },
> +               .fixup_map_hash_8b = { 11 },
>                 .result = ACCEPT,
>                 .prog_type = BPF_PROG_TYPE_SCHED_CLS,
>         },
> @@ -4249,7 +4249,7 @@ static struct bpf_test tests[] = {
>                         BPF_MOV64_IMM(BPF_REG_0, 0),
>                         BPF_EXIT_INSN(),
>                 },
> -               .fixup_map1 = { 7 },
> +               .fixup_map_hash_8b = { 7 },
>                 .result = REJECT,
>                 .errstr = "invalid access to packet",
>                 .prog_type = BPF_PROG_TYPE_SCHED_CLS,
> @@ -4271,7 +4271,7 @@ static struct bpf_test tests[] = {
>                         BPF_MOV64_IMM(BPF_REG_0, 0),
>                         BPF_EXIT_INSN(),
>                 },
> -               .fixup_map1 = { 6 },
> +               .fixup_map_hash_8b = { 6 },
>                 .result = REJECT,
>                 .errstr = "invalid access to packet",
>                 .prog_type = BPF_PROG_TYPE_SCHED_CLS,
> @@ -4555,7 +4555,7 @@ static struct bpf_test tests[] = {
>                                    offsetof(struct test_val, foo)),
>                         BPF_EXIT_INSN(),
>                 },
> -               .fixup_map2 = { 3 },
> +               .fixup_map_hash_48b = { 3 },
>                 .errstr_unpriv = "R0 leaks addr",
>                 .result_unpriv = REJECT,
>                 .result = ACCEPT,
> @@ -4577,7 +4577,7 @@ static struct bpf_test tests[] = {
>                                    offsetof(struct test_val, foo)),
>                         BPF_EXIT_INSN(),
>                 },
> -               .fixup_map2 = { 3 },
> +               .fixup_map_hash_48b = { 3 },
>                 .errstr_unpriv = "R0 leaks addr",
>                 .result_unpriv = REJECT,
>                 .result = ACCEPT,
> @@ -4601,7 +4601,7 @@ static struct bpf_test tests[] = {
>                                    offsetof(struct test_val, foo)),
>                         BPF_EXIT_INSN(),
>                 },
> -               .fixup_map2 = { 3 },
> +               .fixup_map_hash_48b = { 3 },
>                 .errstr_unpriv = "R0 leaks addr",
>                 .result_unpriv = REJECT,
>                 .result = ACCEPT,
> @@ -4629,7 +4629,7 @@ static struct bpf_test tests[] = {
>                                    offsetof(struct test_val, foo)),
>                         BPF_EXIT_INSN(),
>                 },
> -               .fixup_map2 = { 3 },
> +               .fixup_map_hash_48b = { 3 },
>                 .errstr_unpriv = "R0 leaks addr",
>                 .result_unpriv = REJECT,
>                 .result = ACCEPT,
> @@ -4649,7 +4649,7 @@ static struct bpf_test tests[] = {
>                                    offsetof(struct test_val, foo)),
>                         BPF_EXIT_INSN(),
>                 },
> -               .fixup_map2 = { 3 },
> +               .fixup_map_hash_48b = { 3 },
>                 .errstr = "invalid access to map value, value_size=48 off=48 size=8",
>                 .result = REJECT,
>         },
> @@ -4670,7 +4670,7 @@ static struct bpf_test tests[] = {
>                                    offsetof(struct test_val, foo)),
>                         BPF_EXIT_INSN(),
>                 },
> -               .fixup_map2 = { 3 },
> +               .fixup_map_hash_48b = { 3 },
>                 .errstr = "R0 min value is outside of the array range",
>                 .result = REJECT,
>                 .flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
> @@ -4692,7 +4692,7 @@ static struct bpf_test tests[] = {
>                                    offsetof(struct test_val, foo)),
>                         BPF_EXIT_INSN(),
>                 },
> -               .fixup_map2 = { 3 },
> +               .fixup_map_hash_48b = { 3 },
>                 .errstr = "R0 unbounded memory access, make sure to bounds check any array access into a map",
>                 .result = REJECT,
>                 .flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
> @@ -4717,7 +4717,7 @@ static struct bpf_test tests[] = {
>                                    offsetof(struct test_val, foo)),
>                         BPF_EXIT_INSN(),
>                 },
> -               .fixup_map2 = { 3 },
> +               .fixup_map_hash_48b = { 3 },
>                 .errstr_unpriv = "R0 leaks addr",
>                 .errstr = "R0 unbounded memory access",
>                 .result_unpriv = REJECT,
> @@ -4744,7 +4744,7 @@ static struct bpf_test tests[] = {
>                                    offsetof(struct test_val, foo)),
>                         BPF_EXIT_INSN(),
>                 },
> -               .fixup_map2 = { 3 },
> +               .fixup_map_hash_48b = { 3 },
>                 .errstr_unpriv = "R0 leaks addr",
>                 .errstr = "invalid access to map value, value_size=48 off=44 size=8",
>                 .result_unpriv = REJECT,
> @@ -4774,7 +4774,7 @@ static struct bpf_test tests[] = {
>                                     offsetof(struct test_val, foo)),
>                         BPF_EXIT_INSN(),
>                 },
> -               .fixup_map2 = { 3, 11 },
> +               .fixup_map_hash_48b = { 3, 11 },
>                 .errstr = "R0 pointer += pointer",
>                 .result = REJECT,
>                 .flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
> @@ -4807,7 +4807,7 @@ static struct bpf_test tests[] = {
>                         BPF_ALU64_IMM(BPF_AND, BPF_REG_0, 1),
>                         BPF_EXIT_INSN(),
>                 },
> -               .fixup_map1 = { 1 },
> +               .fixup_map_hash_8b = { 1 },
>                 .result = REJECT,
>                 .errstr = "cannot pass map_type 1 into func bpf_get_local_storage",
>                 .prog_type = BPF_PROG_TYPE_CGROUP_SKB,
> @@ -4922,7 +4922,7 @@ static struct bpf_test tests[] = {
>                         BPF_ALU64_IMM(BPF_AND, BPF_REG_0, 1),
>                         BPF_EXIT_INSN(),
>                 },
> -               .fixup_map1 = { 1 },
> +               .fixup_map_hash_8b = { 1 },
>                 .result = REJECT,
>                 .errstr = "cannot pass map_type 1 into func bpf_get_local_storage",
>                 .prog_type = BPF_PROG_TYPE_CGROUP_SKB,
> @@ -5024,7 +5024,7 @@ static struct bpf_test tests[] = {
>                         BPF_ST_MEM(BPF_DW, BPF_REG_4, 0, 0),
>                         BPF_EXIT_INSN(),
>                 },
> -               .fixup_map1 = { 4 },
> +               .fixup_map_hash_8b = { 4 },
>                 .result = ACCEPT,
>                 .prog_type = BPF_PROG_TYPE_SCHED_CLS
>         },
> @@ -5045,7 +5045,7 @@ static struct bpf_test tests[] = {
>                         BPF_ST_MEM(BPF_DW, BPF_REG_4, 0, 0),
>                         BPF_EXIT_INSN(),
>                 },
> -               .fixup_map1 = { 4 },
> +               .fixup_map_hash_8b = { 4 },
>                 .errstr = "R4 pointer arithmetic on map_value_or_null",
>                 .result = REJECT,
>                 .prog_type = BPF_PROG_TYPE_SCHED_CLS
> @@ -5066,7 +5066,7 @@ static struct bpf_test tests[] = {
>                         BPF_ST_MEM(BPF_DW, BPF_REG_4, 0, 0),
>                         BPF_EXIT_INSN(),
>                 },
> -               .fixup_map1 = { 4 },
> +               .fixup_map_hash_8b = { 4 },
>                 .errstr = "R4 pointer arithmetic on map_value_or_null",
>                 .result = REJECT,
>                 .prog_type = BPF_PROG_TYPE_SCHED_CLS
> @@ -5087,7 +5087,7 @@ static struct bpf_test tests[] = {
>                         BPF_ST_MEM(BPF_DW, BPF_REG_4, 0, 0),
>                         BPF_EXIT_INSN(),
>                 },
> -               .fixup_map1 = { 4 },
> +               .fixup_map_hash_8b = { 4 },
>                 .errstr = "R4 pointer arithmetic on map_value_or_null",
>                 .result = REJECT,
>                 .prog_type = BPF_PROG_TYPE_SCHED_CLS
> @@ -5113,7 +5113,7 @@ static struct bpf_test tests[] = {
>                         BPF_ST_MEM(BPF_DW, BPF_REG_4, 0, 0),
>                         BPF_EXIT_INSN(),
>                 },
> -               .fixup_map1 = { 4 },
> +               .fixup_map_hash_8b = { 4 },
>                 .result = REJECT,
>                 .errstr = "R4 !read_ok",
>                 .prog_type = BPF_PROG_TYPE_SCHED_CLS
> @@ -5141,7 +5141,7 @@ static struct bpf_test tests[] = {
>                         BPF_ST_MEM(BPF_DW, BPF_REG_4, 0, 0),
>                         BPF_EXIT_INSN(),
>                 },
> -               .fixup_map1 = { 4 },
> +               .fixup_map_hash_8b = { 4 },
>                 .result = ACCEPT,
>                 .prog_type = BPF_PROG_TYPE_SCHED_CLS
>         },
> @@ -5162,7 +5162,7 @@ static struct bpf_test tests[] = {
>                         BPF_ST_MEM(BPF_DW, BPF_REG_0, 0, offsetof(struct test_val, foo)),
>                         BPF_EXIT_INSN(),
>                 },
> -               .fixup_map2 = { 3 },
> +               .fixup_map_hash_48b = { 3 },
>                 .errstr = "R0 unbounded memory access",
>                 .result = REJECT,
>                 .errstr_unpriv = "R0 leaks addr",
> @@ -5412,7 +5412,7 @@ static struct bpf_test tests[] = {
>                                       offsetof(struct __sk_buff, cb[0])),
>                         BPF_EXIT_INSN(),
>                 },
> -               .fixup_map1 = { 2 },
> +               .fixup_map_hash_8b = { 2 },
>                 .errstr_unpriv = "R2 leaks addr into mem",
>                 .result_unpriv = REJECT,
>                 .result = REJECT,
> @@ -5442,7 +5442,7 @@ static struct bpf_test tests[] = {
>                                       offsetof(struct __sk_buff, cb[0])),
>                         BPF_EXIT_INSN(),
>                 },
> -               .fixup_map1 = { 1 },
> +               .fixup_map_hash_8b = { 1 },
>                 .errstr_unpriv = "R2 leaks addr into ctx",
>                 .result_unpriv = REJECT,
>                 .result = ACCEPT,
> @@ -5464,7 +5464,7 @@ static struct bpf_test tests[] = {
>                         BPF_MOV64_IMM(BPF_REG_0, 0),
>                         BPF_EXIT_INSN(),
>                 },
> -               .fixup_map1 = { 4 },
> +               .fixup_map_hash_8b = { 4 },
>                 .errstr_unpriv = "R6 leaks addr into mem",
>                 .result_unpriv = REJECT,
>                 .result = ACCEPT,
> @@ -5484,7 +5484,7 @@ static struct bpf_test tests[] = {
>                         BPF_EMIT_CALL(BPF_FUNC_probe_read),
>                         BPF_EXIT_INSN(),
>                 },
> -               .fixup_map2 = { 3 },
> +               .fixup_map_hash_48b = { 3 },
>                 .result = ACCEPT,
>                 .prog_type = BPF_PROG_TYPE_TRACEPOINT,
>         },
> @@ -5503,7 +5503,7 @@ static struct bpf_test tests[] = {
>                         BPF_EMIT_CALL(BPF_FUNC_probe_read),
>                         BPF_EXIT_INSN(),
>                 },
> -               .fixup_map2 = { 3 },
> +               .fixup_map_hash_48b = { 3 },
>                 .result = ACCEPT,
>                 .prog_type = BPF_PROG_TYPE_TRACEPOINT,
>         },
> @@ -5521,7 +5521,7 @@ static struct bpf_test tests[] = {
>                         BPF_EMIT_CALL(BPF_FUNC_trace_printk),
>                         BPF_EXIT_INSN(),
>                 },
> -               .fixup_map2 = { 3 },
> +               .fixup_map_hash_48b = { 3 },
>                 .errstr = "invalid access to map value, value_size=48 off=0 size=0",
>                 .result = REJECT,
>                 .prog_type = BPF_PROG_TYPE_TRACEPOINT,
> @@ -5541,7 +5541,7 @@ static struct bpf_test tests[] = {
>                         BPF_EMIT_CALL(BPF_FUNC_probe_read),
>                         BPF_EXIT_INSN(),
>                 },
> -               .fixup_map2 = { 3 },
> +               .fixup_map_hash_48b = { 3 },
>                 .errstr = "invalid access to map value, value_size=48 off=0 size=56",
>                 .result = REJECT,
>                 .prog_type = BPF_PROG_TYPE_TRACEPOINT,
> @@ -5561,7 +5561,7 @@ static struct bpf_test tests[] = {
>                         BPF_EMIT_CALL(BPF_FUNC_probe_read),
>                         BPF_EXIT_INSN(),
>                 },
> -               .fixup_map2 = { 3 },
> +               .fixup_map_hash_48b = { 3 },
>                 .errstr = "R2 min value is negative",
>                 .result = REJECT,
>                 .prog_type = BPF_PROG_TYPE_TRACEPOINT,
> @@ -5585,7 +5585,7 @@ static struct bpf_test tests[] = {
>                         BPF_EMIT_CALL(BPF_FUNC_probe_read),
>                         BPF_EXIT_INSN(),
>                 },
> -               .fixup_map2 = { 3 },
> +               .fixup_map_hash_48b = { 3 },
>                 .result = ACCEPT,
>                 .prog_type = BPF_PROG_TYPE_TRACEPOINT,
>         },
> @@ -5606,7 +5606,7 @@ static struct bpf_test tests[] = {
>                         BPF_EMIT_CALL(BPF_FUNC_probe_read),
>                         BPF_EXIT_INSN(),
>                 },
> -               .fixup_map2 = { 3 },
> +               .fixup_map_hash_48b = { 3 },
>                 .result = ACCEPT,
>                 .prog_type = BPF_PROG_TYPE_TRACEPOINT,
>         },
> @@ -5626,7 +5626,7 @@ static struct bpf_test tests[] = {
>                         BPF_EMIT_CALL(BPF_FUNC_trace_printk),
>                         BPF_EXIT_INSN(),
>                 },
> -               .fixup_map2 = { 3 },
> +               .fixup_map_hash_48b = { 3 },
>                 .errstr = "invalid access to map value, value_size=48 off=4 size=0",
>                 .result = REJECT,
>                 .prog_type = BPF_PROG_TYPE_TRACEPOINT,
> @@ -5650,7 +5650,7 @@ static struct bpf_test tests[] = {
>                         BPF_EMIT_CALL(BPF_FUNC_probe_read),
>                         BPF_EXIT_INSN(),
>                 },
> -               .fixup_map2 = { 3 },
> +               .fixup_map_hash_48b = { 3 },
>                 .errstr = "invalid access to map value, value_size=48 off=4 size=52",
>                 .result = REJECT,
>                 .prog_type = BPF_PROG_TYPE_TRACEPOINT,
> @@ -5672,7 +5672,7 @@ static struct bpf_test tests[] = {
>                         BPF_EMIT_CALL(BPF_FUNC_probe_read),
>                         BPF_EXIT_INSN(),
>                 },
> -               .fixup_map2 = { 3 },
> +               .fixup_map_hash_48b = { 3 },
>                 .errstr = "R2 min value is negative",
>                 .result = REJECT,
>                 .prog_type = BPF_PROG_TYPE_TRACEPOINT,
> @@ -5694,7 +5694,7 @@ static struct bpf_test tests[] = {
>                         BPF_EMIT_CALL(BPF_FUNC_probe_read),
>                         BPF_EXIT_INSN(),
>                 },
> -               .fixup_map2 = { 3 },
> +               .fixup_map_hash_48b = { 3 },
>                 .errstr = "R2 min value is negative",
>                 .result = REJECT,
>                 .prog_type = BPF_PROG_TYPE_TRACEPOINT,
> @@ -5719,7 +5719,7 @@ static struct bpf_test tests[] = {
>                         BPF_EMIT_CALL(BPF_FUNC_probe_read),
>                         BPF_EXIT_INSN(),
>                 },
> -               .fixup_map2 = { 3 },
> +               .fixup_map_hash_48b = { 3 },
>                 .result = ACCEPT,
>                 .prog_type = BPF_PROG_TYPE_TRACEPOINT,
>         },
> @@ -5741,7 +5741,7 @@ static struct bpf_test tests[] = {
>                         BPF_EMIT_CALL(BPF_FUNC_probe_read),
>                         BPF_EXIT_INSN(),
>                 },
> -               .fixup_map2 = { 3 },
> +               .fixup_map_hash_48b = { 3 },
>                 .result = ACCEPT,
>                 .prog_type = BPF_PROG_TYPE_TRACEPOINT,
>         },
> @@ -5761,7 +5761,7 @@ static struct bpf_test tests[] = {
>                         BPF_EMIT_CALL(BPF_FUNC_trace_printk),
>                         BPF_EXIT_INSN(),
>                 },
> -               .fixup_map2 = { 3 },
> +               .fixup_map_hash_48b = { 3 },
>                 .errstr = "R1 min value is outside of the array range",
>                 .result = REJECT,
>                 .prog_type = BPF_PROG_TYPE_TRACEPOINT,
> @@ -5786,7 +5786,7 @@ static struct bpf_test tests[] = {
>                         BPF_EMIT_CALL(BPF_FUNC_probe_read),
>                         BPF_EXIT_INSN(),
>                 },
> -               .fixup_map2 = { 3 },
> +               .fixup_map_hash_48b = { 3 },
>                 .errstr = "invalid access to map value, value_size=48 off=4 size=52",
>                 .result = REJECT,
>                 .prog_type = BPF_PROG_TYPE_TRACEPOINT,
> @@ -5809,7 +5809,7 @@ static struct bpf_test tests[] = {
>                         BPF_EMIT_CALL(BPF_FUNC_probe_read),
>                         BPF_EXIT_INSN(),
>                 },
> -               .fixup_map2 = { 3 },
> +               .fixup_map_hash_48b = { 3 },
>                 .errstr = "R2 min value is negative",
>                 .result = REJECT,
>                 .prog_type = BPF_PROG_TYPE_TRACEPOINT,
> @@ -5832,7 +5832,7 @@ static struct bpf_test tests[] = {
>                         BPF_EMIT_CALL(BPF_FUNC_probe_read),
>                         BPF_EXIT_INSN(),
>                 },
> -               .fixup_map2 = { 3 },
> +               .fixup_map_hash_48b = { 3 },
>                 .errstr = "R2 min value is negative",
>                 .result = REJECT,
>                 .prog_type = BPF_PROG_TYPE_TRACEPOINT,
> @@ -5858,7 +5858,7 @@ static struct bpf_test tests[] = {
>                         BPF_EMIT_CALL(BPF_FUNC_probe_read),
>                         BPF_EXIT_INSN(),
>                 },
> -               .fixup_map2 = { 3 },
> +               .fixup_map_hash_48b = { 3 },
>                 .result = ACCEPT,
>                 .prog_type = BPF_PROG_TYPE_TRACEPOINT,
>         },
> @@ -5881,7 +5881,7 @@ static struct bpf_test tests[] = {
>                         BPF_EMIT_CALL(BPF_FUNC_probe_read),
>                         BPF_EXIT_INSN(),
>                 },
> -               .fixup_map2 = { 3 },
> +               .fixup_map_hash_48b = { 3 },
>                 .result = ACCEPT,
>                 .prog_type = BPF_PROG_TYPE_TRACEPOINT,
>         },
> @@ -5903,7 +5903,7 @@ static struct bpf_test tests[] = {
>                         BPF_EMIT_CALL(BPF_FUNC_trace_printk),
>                         BPF_EXIT_INSN(),
>                 },
> -               .fixup_map2 = { 3 },
> +               .fixup_map_hash_48b = { 3 },
>                 .errstr = "R1 min value is outside of the array range",
>                 .result = REJECT,
>                 .prog_type = BPF_PROG_TYPE_TRACEPOINT,
> @@ -5925,7 +5925,7 @@ static struct bpf_test tests[] = {
>                         BPF_EMIT_CALL(BPF_FUNC_probe_read),
>                         BPF_EXIT_INSN(),
>                 },
> -               .fixup_map2 = { 3 },
> +               .fixup_map_hash_48b = { 3 },
>                 .errstr = "R1 unbounded memory access",
>                 .result = REJECT,
>                 .prog_type = BPF_PROG_TYPE_TRACEPOINT,
> @@ -5951,7 +5951,7 @@ static struct bpf_test tests[] = {
>                         BPF_EMIT_CALL(BPF_FUNC_probe_read),
>                         BPF_EXIT_INSN(),
>                 },
> -               .fixup_map2 = { 3 },
> +               .fixup_map_hash_48b = { 3 },
>                 .errstr = "invalid access to map value, value_size=48 off=4 size=45",
>                 .result = REJECT,
>                 .prog_type = BPF_PROG_TYPE_TRACEPOINT,
> @@ -5975,7 +5975,7 @@ static struct bpf_test tests[] = {
>                         BPF_MOV64_IMM(BPF_REG_0, 0),
>                         BPF_EXIT_INSN(),
>                 },
> -               .fixup_map2 = { 3 },
> +               .fixup_map_hash_48b = { 3 },
>                 .result = ACCEPT,
>                 .prog_type = BPF_PROG_TYPE_TRACEPOINT,
>         },
> @@ -5998,7 +5998,7 @@ static struct bpf_test tests[] = {
>                         BPF_MOV64_IMM(BPF_REG_0, 0),
>                         BPF_EXIT_INSN(),
>                 },
> -               .fixup_map2 = { 3 },
> +               .fixup_map_hash_48b = { 3 },
>                 .result = REJECT,
>                 .errstr = "R1 unbounded memory access",
>                 .prog_type = BPF_PROG_TYPE_TRACEPOINT,
> @@ -6022,7 +6022,7 @@ static struct bpf_test tests[] = {
>                         BPF_MOV64_IMM(BPF_REG_0, 0),
>                         BPF_EXIT_INSN(),
>                 },
> -               .fixup_map2 = { 3 },
> +               .fixup_map_hash_48b = { 3 },
>                 .result = ACCEPT,
>                 .prog_type = BPF_PROG_TYPE_TRACEPOINT,
>         },
> @@ -6045,7 +6045,7 @@ static struct bpf_test tests[] = {
>                         BPF_MOV64_IMM(BPF_REG_0, 0),
>                         BPF_EXIT_INSN(),
>                 },
> -               .fixup_map2 = { 3 },
> +               .fixup_map_hash_48b = { 3 },
>                 .result = REJECT,
>                 .errstr = "R1 unbounded memory access",
>                 .prog_type = BPF_PROG_TYPE_TRACEPOINT,
> @@ -6070,7 +6070,7 @@ static struct bpf_test tests[] = {
>                         BPF_MOV64_IMM(BPF_REG_0, 0),
>                         BPF_EXIT_INSN(),
>                 },
> -               .fixup_map2 = { 3 },
> +               .fixup_map_hash_48b = { 3 },
>                 .result = ACCEPT,
>                 .prog_type = BPF_PROG_TYPE_TRACEPOINT,
>         },
> @@ -6094,7 +6094,7 @@ static struct bpf_test tests[] = {
>                         BPF_MOV64_IMM(BPF_REG_0, 0),
>                         BPF_EXIT_INSN(),
>                 },
> -               .fixup_map2 = { 3 },
> +               .fixup_map_hash_48b = { 3 },
>                 .result = ACCEPT,
>                 .prog_type = BPF_PROG_TYPE_TRACEPOINT,
>         },
> @@ -6118,7 +6118,7 @@ static struct bpf_test tests[] = {
>                         BPF_MOV64_IMM(BPF_REG_0, 0),
>                         BPF_EXIT_INSN(),
>                 },
> -               .fixup_map2 = { 3 },
> +               .fixup_map_hash_48b = { 3 },
>                 .result = REJECT,
>                 .errstr = "R1 min value is negative",
>                 .prog_type = BPF_PROG_TYPE_TRACEPOINT,
> @@ -6143,7 +6143,7 @@ static struct bpf_test tests[] = {
>                         BPF_MOV64_IMM(BPF_REG_0, 0),
>                         BPF_EXIT_INSN(),
>                 },
> -               .fixup_map2 = { 3 },
> +               .fixup_map_hash_48b = { 3 },
>                 .result = ACCEPT,
>                 .prog_type = BPF_PROG_TYPE_TRACEPOINT,
>         },
> @@ -6167,7 +6167,7 @@ static struct bpf_test tests[] = {
>                         BPF_MOV64_IMM(BPF_REG_0, 0),
>                         BPF_EXIT_INSN(),
>                 },
> -               .fixup_map2 = { 3 },
> +               .fixup_map_hash_48b = { 3 },
>                 .result = ACCEPT,
>                 .prog_type = BPF_PROG_TYPE_TRACEPOINT,
>         },
> @@ -6191,7 +6191,7 @@ static struct bpf_test tests[] = {
>                         BPF_MOV64_IMM(BPF_REG_0, 0),
>                         BPF_EXIT_INSN(),
>                 },
> -               .fixup_map2 = { 3 },
> +               .fixup_map_hash_48b = { 3 },
>                 .result = REJECT,
>                 .errstr = "R1 min value is negative",
>                 .prog_type = BPF_PROG_TYPE_TRACEPOINT,
> @@ -6210,7 +6210,7 @@ static struct bpf_test tests[] = {
>                         BPF_EMIT_CALL(BPF_FUNC_map_lookup_elem),
>                         BPF_EXIT_INSN(),
>                 },
> -               .fixup_map3 = { 3, 8 },
> +               .fixup_map_hash_16b = { 3, 8 },
>                 .result = ACCEPT,
>                 .prog_type = BPF_PROG_TYPE_TRACEPOINT,
>         },
> @@ -6230,7 +6230,7 @@ static struct bpf_test tests[] = {
>                         BPF_EMIT_CALL(BPF_FUNC_map_update_elem),
>                         BPF_EXIT_INSN(),
>                 },
> -               .fixup_map3 = { 3, 10 },
> +               .fixup_map_hash_16b = { 3, 10 },
>                 .result = ACCEPT,
>                 .prog_type = BPF_PROG_TYPE_TRACEPOINT,
>         },
> @@ -6250,8 +6250,8 @@ static struct bpf_test tests[] = {
>                         BPF_EMIT_CALL(BPF_FUNC_map_update_elem),
>                         BPF_EXIT_INSN(),
>                 },
> -               .fixup_map1 = { 3 },
> -               .fixup_map3 = { 10 },
> +               .fixup_map_hash_8b = { 3 },
> +               .fixup_map_hash_16b = { 10 },
>                 .result = REJECT,
>                 .errstr = "invalid access to map value, value_size=8 off=0 size=16",
>                 .prog_type = BPF_PROG_TYPE_TRACEPOINT,
> @@ -6272,7 +6272,7 @@ static struct bpf_test tests[] = {
>                         BPF_EMIT_CALL(BPF_FUNC_map_lookup_elem),
>                         BPF_EXIT_INSN(),
>                 },
> -               .fixup_map3 = { 3, 9 },
> +               .fixup_map_hash_16b = { 3, 9 },
>                 .result = ACCEPT,
>                 .prog_type = BPF_PROG_TYPE_TRACEPOINT,
>         },
> @@ -6292,7 +6292,7 @@ static struct bpf_test tests[] = {
>                         BPF_EMIT_CALL(BPF_FUNC_map_lookup_elem),
>                         BPF_EXIT_INSN(),
>                 },
> -               .fixup_map3 = { 3, 9 },
> +               .fixup_map_hash_16b = { 3, 9 },
>                 .result = REJECT,
>                 .errstr = "invalid access to map value, value_size=16 off=12 size=8",
>                 .prog_type = BPF_PROG_TYPE_TRACEPOINT,
> @@ -6312,7 +6312,7 @@ static struct bpf_test tests[] = {
>                         BPF_EMIT_CALL(BPF_FUNC_map_lookup_elem),
>                         BPF_EXIT_INSN(),
>                 },
> -               .fixup_map3 = { 3, 9 },
> +               .fixup_map_hash_16b = { 3, 9 },
>                 .result = REJECT,
>                 .errstr = "invalid access to map value, value_size=16 off=-4 size=8",
>                 .prog_type = BPF_PROG_TYPE_TRACEPOINT,
> @@ -6334,7 +6334,7 @@ static struct bpf_test tests[] = {
>                         BPF_EMIT_CALL(BPF_FUNC_map_lookup_elem),
>                         BPF_EXIT_INSN(),
>                 },
> -               .fixup_map3 = { 3, 10 },
> +               .fixup_map_hash_16b = { 3, 10 },
>                 .result = ACCEPT,
>                 .prog_type = BPF_PROG_TYPE_TRACEPOINT,
>         },
> @@ -6355,7 +6355,7 @@ static struct bpf_test tests[] = {
>                         BPF_EMIT_CALL(BPF_FUNC_map_lookup_elem),
>                         BPF_EXIT_INSN(),
>                 },
> -               .fixup_map3 = { 3, 10 },
> +               .fixup_map_hash_16b = { 3, 10 },
>                 .result = REJECT,
>                 .errstr = "invalid access to map value, value_size=16 off=12 size=8",
>                 .prog_type = BPF_PROG_TYPE_TRACEPOINT,
> @@ -6376,7 +6376,7 @@ static struct bpf_test tests[] = {
>                         BPF_EMIT_CALL(BPF_FUNC_map_lookup_elem),
>                         BPF_EXIT_INSN(),
>                 },
> -               .fixup_map3 = { 3, 10 },
> +               .fixup_map_hash_16b = { 3, 10 },
>                 .result = REJECT,
>                 .errstr = "invalid access to map value, value_size=16 off=-4 size=8",
>                 .prog_type = BPF_PROG_TYPE_TRACEPOINT,
> @@ -6399,7 +6399,7 @@ static struct bpf_test tests[] = {
>                         BPF_EMIT_CALL(BPF_FUNC_map_lookup_elem),
>                         BPF_EXIT_INSN(),
>                 },
> -               .fixup_map3 = { 3, 11 },
> +               .fixup_map_hash_16b = { 3, 11 },
>                 .result = ACCEPT,
>                 .prog_type = BPF_PROG_TYPE_TRACEPOINT,
>         },
> @@ -6419,7 +6419,7 @@ static struct bpf_test tests[] = {
>                         BPF_EMIT_CALL(BPF_FUNC_map_lookup_elem),
>                         BPF_EXIT_INSN(),
>                 },
> -               .fixup_map3 = { 3, 10 },
> +               .fixup_map_hash_16b = { 3, 10 },
>                 .result = REJECT,
>                 .errstr = "R2 unbounded memory access, make sure to bounds check any array access into a map",
>                 .prog_type = BPF_PROG_TYPE_TRACEPOINT,
> @@ -6442,7 +6442,7 @@ static struct bpf_test tests[] = {
>                         BPF_EMIT_CALL(BPF_FUNC_map_lookup_elem),
>                         BPF_EXIT_INSN(),
>                 },
> -               .fixup_map3 = { 3, 11 },
> +               .fixup_map_hash_16b = { 3, 11 },
>                 .result = REJECT,
>                 .errstr = "invalid access to map value, value_size=16 off=9 size=8",
>                 .prog_type = BPF_PROG_TYPE_TRACEPOINT,
> @@ -6464,7 +6464,7 @@ static struct bpf_test tests[] = {
>                         BPF_ST_MEM(BPF_DW, BPF_REG_3, 0, 42),
>                         BPF_EXIT_INSN(),
>                 },
> -               .fixup_map2 = { 3 },
> +               .fixup_map_hash_48b = { 3 },
>                 .errstr_unpriv = "R0 leaks addr",
>                 .result = ACCEPT,
>                 .result_unpriv = REJECT,
> @@ -6485,7 +6485,7 @@ static struct bpf_test tests[] = {
>                         BPF_ST_MEM(BPF_DW, BPF_REG_3, 0, 42),
>                         BPF_EXIT_INSN(),
>                 },
> -               .fixup_map2 = { 3 },
> +               .fixup_map_hash_48b = { 3 },
>                 .errstr_unpriv = "R0 leaks addr",
>                 .result = ACCEPT,
>                 .result_unpriv = REJECT,
> @@ -6502,7 +6502,7 @@ static struct bpf_test tests[] = {
>                         BPF_STX_MEM(BPF_DW, BPF_REG_0, BPF_REG_1, 0),
>                         BPF_EXIT_INSN(),
>                 },
> -               .fixup_map2 = { 3 },
> +               .fixup_map_hash_48b = { 3 },
>                 .errstr_unpriv = "R1 !read_ok",
>                 .errstr = "R1 !read_ok",
>                 .result = REJECT,
> @@ -6536,7 +6536,7 @@ static struct bpf_test tests[] = {
>                         BPF_ST_MEM(BPF_DW, BPF_REG_7, -4, 24),
>                         BPF_EXIT_INSN(),
>                 },
> -               .fixup_map2 = { 3 },
> +               .fixup_map_hash_48b = { 3 },
>                 .errstr_unpriv = "R0 leaks addr",
>                 .result = ACCEPT,
>                 .result_unpriv = REJECT,
> @@ -6564,7 +6564,7 @@ static struct bpf_test tests[] = {
>                         BPF_LDX_MEM(BPF_DW, BPF_REG_7, BPF_REG_0, 4),
>                         BPF_EXIT_INSN(),
>                 },
> -               .fixup_map2 = { 3 },
> +               .fixup_map_hash_48b = { 3 },
>                 .errstr_unpriv = "R0 leaks addr",
>                 .result = ACCEPT,
>                 .result_unpriv = REJECT,
> @@ -6583,7 +6583,7 @@ static struct bpf_test tests[] = {
>                         BPF_ST_MEM(BPF_DW, BPF_REG_0, 0, 22),
>                         BPF_EXIT_INSN(),
>                 },
> -               .fixup_map2 = { 3 },
> +               .fixup_map_hash_48b = { 3 },
>                 .errstr = "R0 bitwise operator &= on pointer",
>                 .result = REJECT,
>         },
> @@ -6600,7 +6600,7 @@ static struct bpf_test tests[] = {
>                         BPF_ST_MEM(BPF_DW, BPF_REG_0, 0, 22),
>                         BPF_EXIT_INSN(),
>                 },
> -               .fixup_map2 = { 3 },
> +               .fixup_map_hash_48b = { 3 },
>                 .errstr = "R0 32-bit pointer arithmetic prohibited",
>                 .result = REJECT,
>         },
> @@ -6617,7 +6617,7 @@ static struct bpf_test tests[] = {
>                         BPF_ST_MEM(BPF_DW, BPF_REG_0, 0, 22),
>                         BPF_EXIT_INSN(),
>                 },
> -               .fixup_map2 = { 3 },
> +               .fixup_map_hash_48b = { 3 },
>                 .errstr = "R0 pointer arithmetic with /= operator",
>                 .result = REJECT,
>         },
> @@ -6634,7 +6634,7 @@ static struct bpf_test tests[] = {
>                         BPF_ST_MEM(BPF_DW, BPF_REG_0, 0, 22),
>                         BPF_EXIT_INSN(),
>                 },
> -               .fixup_map2 = { 3 },
> +               .fixup_map_hash_48b = { 3 },
>                 .errstr_unpriv = "R0 pointer arithmetic prohibited",
>                 .errstr = "invalid mem access 'inv'",
>                 .result = REJECT,
> @@ -6658,7 +6658,7 @@ static struct bpf_test tests[] = {
>                         BPF_ST_MEM(BPF_DW, BPF_REG_0, 0, 22),
>                         BPF_EXIT_INSN(),
>                 },
> -               .fixup_map2 = { 3 },
> +               .fixup_map_hash_48b = { 3 },
>                 .errstr = "R0 invalid mem access 'inv'",
>                 .result = REJECT,
>         },
> @@ -6681,7 +6681,7 @@ static struct bpf_test tests[] = {
>                         BPF_ST_MEM(BPF_DW, BPF_REG_3, 0, 42),
>                         BPF_EXIT_INSN(),
>                 },
> -               .fixup_map2 = { 3 },
> +               .fixup_map_hash_48b = { 3 },
>                 .errstr_unpriv = "R0 leaks addr",
>                 .result = ACCEPT,
>                 .result_unpriv = REJECT,
> @@ -6927,7 +6927,7 @@ static struct bpf_test tests[] = {
>                         BPF_MOV64_IMM(BPF_REG_0, 0),
>                         BPF_EXIT_INSN(),
>                 },
> -               .fixup_map2 = { 3 },
> +               .fixup_map_hash_48b = { 3 },
>                 .result = ACCEPT,
>                 .prog_type = BPF_PROG_TYPE_TRACEPOINT,
>         },
> @@ -6953,7 +6953,7 @@ static struct bpf_test tests[] = {
>                         BPF_MOV64_IMM(BPF_REG_0, 0),
>                         BPF_EXIT_INSN(),
>                 },
> -               .fixup_map2 = { 3 },
> +               .fixup_map_hash_48b = { 3 },
>                 .errstr = "invalid access to map value, value_size=48 off=0 size=49",
>                 .result = REJECT,
>                 .prog_type = BPF_PROG_TYPE_TRACEPOINT,
> @@ -6981,7 +6981,7 @@ static struct bpf_test tests[] = {
>                         BPF_MOV64_IMM(BPF_REG_0, 0),
>                         BPF_EXIT_INSN(),
>                 },
> -               .fixup_map2 = { 3 },
> +               .fixup_map_hash_48b = { 3 },
>                 .result = ACCEPT,
>                 .prog_type = BPF_PROG_TYPE_TRACEPOINT,
>         },
> @@ -7008,7 +7008,7 @@ static struct bpf_test tests[] = {
>                         BPF_MOV64_IMM(BPF_REG_0, 0),
>                         BPF_EXIT_INSN(),
>                 },
> -               .fixup_map2 = { 3 },
> +               .fixup_map_hash_48b = { 3 },
>                 .errstr = "R1 min value is outside of the array range",
>                 .result = REJECT,
>                 .prog_type = BPF_PROG_TYPE_TRACEPOINT,
> @@ -7080,7 +7080,7 @@ static struct bpf_test tests[] = {
>                         BPF_EMIT_CALL(BPF_FUNC_csum_diff),
>                         BPF_EXIT_INSN(),
>                 },
> -               .fixup_map1 = { 3 },
> +               .fixup_map_hash_8b = { 3 },
>                 .result = ACCEPT,
>                 .prog_type = BPF_PROG_TYPE_SCHED_CLS,
>         },
> @@ -7105,7 +7105,7 @@ static struct bpf_test tests[] = {
>                         BPF_EMIT_CALL(BPF_FUNC_csum_diff),
>                         BPF_EXIT_INSN(),
>                 },
> -               .fixup_map1 = { 3 },
> +               .fixup_map_hash_8b = { 3 },
>                 .result = ACCEPT,
>                 .prog_type = BPF_PROG_TYPE_SCHED_CLS,
>         },
> @@ -7128,7 +7128,7 @@ static struct bpf_test tests[] = {
>                         BPF_EMIT_CALL(BPF_FUNC_csum_diff),
>                         BPF_EXIT_INSN(),
>                 },
> -               .fixup_map1 = { 3 },
> +               .fixup_map_hash_8b = { 3 },
>                 .result = ACCEPT,
>                 .prog_type = BPF_PROG_TYPE_SCHED_CLS,
>         },
> @@ -7209,7 +7209,7 @@ static struct bpf_test tests[] = {
>                         BPF_EMIT_CALL(BPF_FUNC_probe_read),
>                         BPF_EXIT_INSN(),
>                 },
> -               .fixup_map1 = { 3 },
> +               .fixup_map_hash_8b = { 3 },
>                 .result = ACCEPT,
>                 .prog_type = BPF_PROG_TYPE_TRACEPOINT,
>         },
> @@ -7230,7 +7230,7 @@ static struct bpf_test tests[] = {
>                         BPF_EMIT_CALL(BPF_FUNC_probe_read),
>                         BPF_EXIT_INSN(),
>                 },
> -               .fixup_map1 = { 3 },
> +               .fixup_map_hash_8b = { 3 },
>                 .result = ACCEPT,
>                 .prog_type = BPF_PROG_TYPE_TRACEPOINT,
>         },
> @@ -7250,7 +7250,7 @@ static struct bpf_test tests[] = {
>                         BPF_EMIT_CALL(BPF_FUNC_probe_read),
>                         BPF_EXIT_INSN(),
>                 },
> -               .fixup_map1 = { 3 },
> +               .fixup_map_hash_8b = { 3 },
>                 .result = ACCEPT,
>                 .prog_type = BPF_PROG_TYPE_TRACEPOINT,
>         },
> @@ -7325,7 +7325,7 @@ static struct bpf_test tests[] = {
>                                    offsetof(struct test_val, foo)),
>                         BPF_EXIT_INSN(),
>                 },
> -               .fixup_map2 = { 3 },
> +               .fixup_map_hash_48b = { 3 },
>                 .errstr = "R0 max value is outside of the array range",
>                 .result = REJECT,
>                 .flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
> @@ -7355,7 +7355,7 @@ static struct bpf_test tests[] = {
>                         BPF_MOV64_REG(BPF_REG_0, 0),
>                         BPF_EXIT_INSN(),
>                 },
> -               .fixup_map2 = { 3 },
> +               .fixup_map_hash_48b = { 3 },
>                 .errstr = "R0 max value is outside of the array range",
>                 .result = REJECT,
>                 .flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
> @@ -7708,7 +7708,7 @@ static struct bpf_test tests[] = {
>                         BPF_MOV64_IMM(BPF_REG_0, 0),
>                         BPF_EXIT_INSN(),
>                 },
> -               .fixup_map1 = { 3 },
> +               .fixup_map_hash_8b = { 3 },
>                 .errstr = "unbounded min value",
>                 .result = REJECT,
>         },
> @@ -7732,7 +7732,7 @@ static struct bpf_test tests[] = {
>                         BPF_MOV64_IMM(BPF_REG_0, 0),
>                         BPF_EXIT_INSN(),
>                 },
> -               .fixup_map1 = { 3 },
> +               .fixup_map_hash_8b = { 3 },
>                 .errstr = "unbounded min value",
>                 .result = REJECT,
>         },
> @@ -7758,7 +7758,7 @@ static struct bpf_test tests[] = {
>                         BPF_MOV64_IMM(BPF_REG_0, 0),
>                         BPF_EXIT_INSN(),
>                 },
> -               .fixup_map1 = { 3 },
> +               .fixup_map_hash_8b = { 3 },
>                 .errstr = "unbounded min value",
>                 .result = REJECT,
>         },
> @@ -7783,7 +7783,7 @@ static struct bpf_test tests[] = {
>                         BPF_MOV64_IMM(BPF_REG_0, 0),
>                         BPF_EXIT_INSN(),
>                 },
> -               .fixup_map1 = { 3 },
> +               .fixup_map_hash_8b = { 3 },
>                 .errstr = "unbounded min value",
>                 .result = REJECT,
>         },
> @@ -7807,7 +7807,7 @@ static struct bpf_test tests[] = {
>                         BPF_MOV64_IMM(BPF_REG_0, 0),
>                         BPF_EXIT_INSN(),
>                 },
> -               .fixup_map1 = { 3 },
> +               .fixup_map_hash_8b = { 3 },
>                 .result = ACCEPT,
>         },
>         {
> @@ -7831,7 +7831,7 @@ static struct bpf_test tests[] = {
>                         BPF_MOV64_IMM(BPF_REG_0, 0),
>                         BPF_EXIT_INSN(),
>                 },
> -               .fixup_map1 = { 3 },
> +               .fixup_map_hash_8b = { 3 },
>                 .errstr = "unbounded min value",
>                 .result = REJECT,
>         },
> @@ -7877,7 +7877,7 @@ static struct bpf_test tests[] = {
>                         BPF_MOV64_IMM(BPF_REG_0, 0),
>                         BPF_EXIT_INSN(),
>                 },
> -               .fixup_map1 = { 3 },
> +               .fixup_map_hash_8b = { 3 },
>                 .result = ACCEPT,
>         },
>         {
> @@ -7902,7 +7902,7 @@ static struct bpf_test tests[] = {
>                         BPF_MOV64_IMM(BPF_REG_0, 0),
>                         BPF_EXIT_INSN(),
>                 },
> -               .fixup_map1 = { 3 },
> +               .fixup_map_hash_8b = { 3 },
>                 .errstr = "unbounded min value",
>                 .result = REJECT,
>         },
> @@ -7928,7 +7928,7 @@ static struct bpf_test tests[] = {
>                         BPF_MOV64_IMM(BPF_REG_0, 0),
>                         BPF_EXIT_INSN(),
>                 },
> -               .fixup_map1 = { 3 },
> +               .fixup_map_hash_8b = { 3 },
>                 .result = ACCEPT,
>         },
>         {
> @@ -7953,7 +7953,7 @@ static struct bpf_test tests[] = {
>                         BPF_MOV64_IMM(BPF_REG_0, 0),
>                         BPF_EXIT_INSN(),
>                 },
> -               .fixup_map1 = { 3 },
> +               .fixup_map_hash_8b = { 3 },
>                 .errstr = "unbounded min value",
>                 .result = REJECT,
>         },
> @@ -7980,7 +7980,7 @@ static struct bpf_test tests[] = {
>                         BPF_MOV64_IMM(BPF_REG_0, 0),
>                         BPF_EXIT_INSN(),
>                 },
> -               .fixup_map1 = { 3 },
> +               .fixup_map_hash_8b = { 3 },
>                 .errstr = "unbounded min value",
>                 .result = REJECT,
>         },
> @@ -8006,7 +8006,7 @@ static struct bpf_test tests[] = {
>                         BPF_MOV64_IMM(BPF_REG_0, 0),
>                         BPF_EXIT_INSN(),
>                 },
> -               .fixup_map1 = { 3 },
> +               .fixup_map_hash_8b = { 3 },
>                 .errstr = "unbounded min value",
>                 .result = REJECT,
>         },
> @@ -8035,7 +8035,7 @@ static struct bpf_test tests[] = {
>                         BPF_MOV64_IMM(BPF_REG_0, 0),
>                         BPF_EXIT_INSN(),
>                 },
> -               .fixup_map1 = { 3 },
> +               .fixup_map_hash_8b = { 3 },
>                 .errstr = "unbounded min value",
>

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH bpf-next 6/6] selftests/bpf: test_verifier, check bpf_map_lookup_elem access in bpf prog
  2018-10-09  1:04 ` [PATCH bpf-next 6/6] selftests/bpf: test_verifier, check bpf_map_lookup_elem access in bpf prog Prashant Bhole
@ 2018-10-09  7:02   ` Song Liu
  2018-10-25  8:54     ` Naresh Kamboju
  0 siblings, 1 reply; 16+ messages in thread
From: Song Liu @ 2018-10-09  7:02 UTC (permalink / raw)
  To: Prashant Bhole
  Cc: Alexei Starovoitov, Daniel Borkmann, Jakub Kicinski,
	David S . Miller, Quentin Monnet, Networking

On Mon, Oct 8, 2018 at 6:07 PM Prashant Bhole
<bhole_prashant_q7@lab.ntt.co.jp> wrote:
>
> map_lookup_elem isn't supported by certain map types like:
> - BPF_MAP_TYPE_PROG_ARRAY
> - BPF_MAP_TYPE_STACK_TRACE
> - BPF_MAP_TYPE_XSKMAP
> - BPF_MAP_TYPE_SOCKMAP/BPF_MAP_TYPE_SOCKHASH
> Let's add verfier tests to check whether verifier prevents
> bpf_map_lookup_elem call on above programs from bpf program.
>
> Signed-off-by: Prashant Bhole <bhole_prashant_q7@lab.ntt.co.jp>
> Acked-by: Alexei Starovoitov <ast@kernel.org>
Acked-by: Song Liu <songliubraving@fb.com>

> ---
>  tools/testing/selftests/bpf/test_verifier.c | 121 +++++++++++++++++++-
>  1 file changed, 120 insertions(+), 1 deletion(-)
>
> diff --git a/tools/testing/selftests/bpf/test_verifier.c b/tools/testing/selftests/bpf/test_verifier.c
> index 65ae44c85d27..cf4cd32b6772 100644
> --- a/tools/testing/selftests/bpf/test_verifier.c
> +++ b/tools/testing/selftests/bpf/test_verifier.c
> @@ -48,7 +48,7 @@
>
>  #define MAX_INSNS      BPF_MAXINSNS
>  #define MAX_FIXUPS     8
> -#define MAX_NR_MAPS    8
> +#define MAX_NR_MAPS    13
>  #define POINTER_VALUE  0xcafe4all
>  #define TEST_DATA_LEN  64
>
> @@ -65,6 +65,10 @@ struct bpf_test {
>         int fixup_map_hash_48b[MAX_FIXUPS];
>         int fixup_map_hash_16b[MAX_FIXUPS];
>         int fixup_map_array_48b[MAX_FIXUPS];
> +       int fixup_map_sockmap[MAX_FIXUPS];
> +       int fixup_map_sockhash[MAX_FIXUPS];
> +       int fixup_map_xskmap[MAX_FIXUPS];
> +       int fixup_map_stacktrace[MAX_FIXUPS];
>         int fixup_prog1[MAX_FIXUPS];
>         int fixup_prog2[MAX_FIXUPS];
>         int fixup_map_in_map[MAX_FIXUPS];
> @@ -4541,6 +4545,85 @@ static struct bpf_test tests[] = {
>                 .errstr = "invalid access to packet",
>                 .prog_type = BPF_PROG_TYPE_SCHED_CLS,
>         },
> +       {
> +               "prevent map lookup in sockmap",
> +               .insns = {
> +                       BPF_ST_MEM(BPF_DW, BPF_REG_10, -8, 0),
> +                       BPF_MOV64_REG(BPF_REG_2, BPF_REG_10),
> +                       BPF_ALU64_IMM(BPF_ADD, BPF_REG_2, -8),
> +                       BPF_LD_MAP_FD(BPF_REG_1, 0),
> +                       BPF_RAW_INSN(BPF_JMP | BPF_CALL, 0, 0, 0,
> +                                    BPF_FUNC_map_lookup_elem),
> +                       BPF_EXIT_INSN(),
> +               },
> +               .fixup_map_sockmap = { 3 },
> +               .result = REJECT,
> +               .errstr = "cannot pass map_type 15 into func bpf_map_lookup_elem",
> +               .prog_type = BPF_PROG_TYPE_SOCK_OPS,
> +       },
> +       {
> +               "prevent map lookup in sockhash",
> +               .insns = {
> +                       BPF_ST_MEM(BPF_DW, BPF_REG_10, -8, 0),
> +                       BPF_MOV64_REG(BPF_REG_2, BPF_REG_10),
> +                       BPF_ALU64_IMM(BPF_ADD, BPF_REG_2, -8),
> +                       BPF_LD_MAP_FD(BPF_REG_1, 0),
> +                       BPF_RAW_INSN(BPF_JMP | BPF_CALL, 0, 0, 0,
> +                                    BPF_FUNC_map_lookup_elem),
> +                       BPF_EXIT_INSN(),
> +               },
> +               .fixup_map_sockhash = { 3 },
> +               .result = REJECT,
> +               .errstr = "cannot pass map_type 18 into func bpf_map_lookup_elem",
> +               .prog_type = BPF_PROG_TYPE_SOCK_OPS,
> +       },
> +       {
> +               "prevent map lookup in xskmap",
> +               .insns = {
> +                       BPF_ST_MEM(BPF_DW, BPF_REG_10, -8, 0),
> +                       BPF_MOV64_REG(BPF_REG_2, BPF_REG_10),
> +                       BPF_ALU64_IMM(BPF_ADD, BPF_REG_2, -8),
> +                       BPF_LD_MAP_FD(BPF_REG_1, 0),
> +                       BPF_RAW_INSN(BPF_JMP | BPF_CALL, 0, 0, 0,
> +                                    BPF_FUNC_map_lookup_elem),
> +                       BPF_EXIT_INSN(),
> +               },
> +               .fixup_map_xskmap = { 3 },
> +               .result = REJECT,
> +               .errstr = "cannot pass map_type 17 into func bpf_map_lookup_elem",
> +               .prog_type = BPF_PROG_TYPE_XDP,
> +       },
> +       {
> +               "prevent map lookup in stack trace",
> +               .insns = {
> +                       BPF_ST_MEM(BPF_DW, BPF_REG_10, -8, 0),
> +                       BPF_MOV64_REG(BPF_REG_2, BPF_REG_10),
> +                       BPF_ALU64_IMM(BPF_ADD, BPF_REG_2, -8),
> +                       BPF_LD_MAP_FD(BPF_REG_1, 0),
> +                       BPF_RAW_INSN(BPF_JMP | BPF_CALL, 0, 0, 0,
> +                                    BPF_FUNC_map_lookup_elem),
> +                       BPF_EXIT_INSN(),
> +               },
> +               .fixup_map_stacktrace = { 3 },
> +               .result = REJECT,
> +               .errstr = "cannot pass map_type 7 into func bpf_map_lookup_elem",
> +               .prog_type = BPF_PROG_TYPE_PERF_EVENT,
> +       },
> +       {
> +               "prevent map lookup in prog array",
> +               .insns = {
> +                       BPF_ST_MEM(BPF_DW, BPF_REG_10, -8, 0),
> +                       BPF_MOV64_REG(BPF_REG_2, BPF_REG_10),
> +                       BPF_ALU64_IMM(BPF_ADD, BPF_REG_2, -8),
> +                       BPF_LD_MAP_FD(BPF_REG_1, 0),
> +                       BPF_RAW_INSN(BPF_JMP | BPF_CALL, 0, 0, 0,
> +                                    BPF_FUNC_map_lookup_elem),
> +                       BPF_EXIT_INSN(),
> +               },
> +               .fixup_prog2 = { 3 },
> +               .result = REJECT,
> +               .errstr = "cannot pass map_type 3 into func bpf_map_lookup_elem",
> +       },
>         {
>                 "valid map access into an array with a constant",
>                 .insns = {
> @@ -13515,6 +13598,10 @@ static void do_test_fixup(struct bpf_test *test, enum bpf_map_type prog_type,
>         int *fixup_map_hash_48b = test->fixup_map_hash_48b;
>         int *fixup_map_hash_16b = test->fixup_map_hash_16b;
>         int *fixup_map_array_48b = test->fixup_map_array_48b;
> +       int *fixup_map_sockmap = test->fixup_map_sockmap;
> +       int *fixup_map_sockhash = test->fixup_map_sockhash;
> +       int *fixup_map_xskmap = test->fixup_map_xskmap;
> +       int *fixup_map_stacktrace = test->fixup_map_stacktrace;
>         int *fixup_prog1 = test->fixup_prog1;
>         int *fixup_prog2 = test->fixup_prog2;
>         int *fixup_map_in_map = test->fixup_map_in_map;
> @@ -13603,6 +13690,38 @@ static void do_test_fixup(struct bpf_test *test, enum bpf_map_type prog_type,
>                         fixup_percpu_cgroup_storage++;
>                 } while (*fixup_percpu_cgroup_storage);
>         }
> +       if (*fixup_map_sockmap) {
> +               map_fds[9] = create_map(BPF_MAP_TYPE_SOCKMAP, sizeof(int),
> +                                       sizeof(int), 1);
> +               do {
> +                       prog[*fixup_map_sockmap].imm = map_fds[9];
> +                       fixup_map_sockmap++;
> +               } while (*fixup_map_sockmap);
> +       }
> +       if (*fixup_map_sockhash) {
> +               map_fds[10] = create_map(BPF_MAP_TYPE_SOCKHASH, sizeof(int),
> +                                       sizeof(int), 1);
> +               do {
> +                       prog[*fixup_map_sockhash].imm = map_fds[10];
> +                       fixup_map_sockhash++;
> +               } while (*fixup_map_sockhash);
> +       }
> +       if (*fixup_map_xskmap) {
> +               map_fds[11] = create_map(BPF_MAP_TYPE_XSKMAP, sizeof(int),
> +                                       sizeof(int), 1);
> +               do {
> +                       prog[*fixup_map_xskmap].imm = map_fds[11];
> +                       fixup_map_xskmap++;
> +               } while (*fixup_map_xskmap);
> +       }
> +       if (*fixup_map_stacktrace) {
> +               map_fds[12] = create_map(BPF_MAP_TYPE_STACK_TRACE, sizeof(u32),
> +                                        sizeof(u64), 1);
> +               do {
> +                       prog[*fixup_map_stacktrace].imm = map_fds[12];
> +                       fixup_map_stacktrace++;
> +               } while (fixup_map_stacktrace);
> +       }
>  }
>
>  static void do_test_single(struct bpf_test *test, bool unpriv,
> --
> 2.17.1
>
>

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH bpf-next 0/6] Error handling when map lookup isn't supported
  2018-10-09  1:04 [PATCH bpf-next 0/6] Error handling when map lookup isn't supported Prashant Bhole
                   ` (5 preceding siblings ...)
  2018-10-09  1:04 ` [PATCH bpf-next 6/6] selftests/bpf: test_verifier, check bpf_map_lookup_elem access in bpf prog Prashant Bhole
@ 2018-10-10  4:55 ` Alexei Starovoitov
  6 siblings, 0 replies; 16+ messages in thread
From: Alexei Starovoitov @ 2018-10-10  4:55 UTC (permalink / raw)
  To: Prashant Bhole
  Cc: Alexei Starovoitov, Daniel Borkmann, Jakub Kicinski,
	David S . Miller, Quentin Monnet, netdev

On Tue, Oct 09, 2018 at 10:04:48AM +0900, Prashant Bhole wrote:
> Currently when map a lookup fails, user space API can not make any
> distinction whether given key was not found or lookup is not supported
> by particular map.
> 
> In this series we modify return value of maps which do not support
> lookup. Lookup on such map implementation will return -EOPNOTSUPP.
> bpf() syscall with BPF_MAP_LOOKUP_ELEM command will set EOPNOTSUPP
> errno. We also handle this error in bpftool to print appropriate
> message.
> 
> Patch 1: adds handling of BPF_MAP_LOOKUP ELEM command of bpf syscall
> such that errno will set to EOPNOTSUPP when map doesn't support lookup
> 
> Patch 2: Modifies the return value of map_lookup_elem() to EOPNOTSUPP
> for maps which do not support lookup
> 
> Patch 3: Splits do_dump() in bpftool/map.c. Element printing code is
> moved out into new function dump_map_elem(). This was done in order to
> reduce deep indentation and accomodate further changes.
> 
> Patch 4: Changes in bpftool to print strerror() message when lookup
> error is occured. This will result in appropriate message like
> "Operation not supported" when map doesn't support lookup.
> 
> Patch 5: test_verifier: change fixup map naming convention as
> suggested by Alexei
> 
> Patch 6: Added verifier tests to check whether verifier rejects call 
> to bpf_map_lookup_elem from bpf program. For all map types those
> do not support map lookup.

Applied, Thanks

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH bpf-next 6/6] selftests/bpf: test_verifier, check bpf_map_lookup_elem access in bpf prog
  2018-10-09  7:02   ` Song Liu
@ 2018-10-25  8:54     ` Naresh Kamboju
  2018-10-25  9:09       ` Prashant Bhole
  0 siblings, 1 reply; 16+ messages in thread
From: Naresh Kamboju @ 2018-10-25  8:54 UTC (permalink / raw)
  To: liu.song.a23, bhole_prashant_q7
  Cc: ast, Daniel Borkmann, jakub.kicinski, David S. Miller,
	quentin.monnet, netdev, open list:KERNEL SELFTEST FRAMEWORK

On Tue, 9 Oct 2018 at 12:32, Song Liu <liu.song.a23@gmail.com> wrote:
>
> On Mon, Oct 8, 2018 at 6:07 PM Prashant Bhole
> <bhole_prashant_q7@lab.ntt.co.jp> wrote:
> >
> > map_lookup_elem isn't supported by certain map types like:
> > - BPF_MAP_TYPE_PROG_ARRAY
> > - BPF_MAP_TYPE_STACK_TRACE
> > - BPF_MAP_TYPE_XSKMAP
> > - BPF_MAP_TYPE_SOCKMAP/BPF_MAP_TYPE_SOCKHASH
> > Let's add verfier tests to check whether verifier prevents
> > bpf_map_lookup_elem call on above programs from bpf program.
> >
> > Signed-off-by: Prashant Bhole <bhole_prashant_q7@lab.ntt.co.jp>
> > Acked-by: Alexei Starovoitov <ast@kernel.org>
> Acked-by: Song Liu <songliubraving@fb.com>
>
> > ---
> >  tools/testing/selftests/bpf/test_verifier.c | 121 +++++++++++++++++++-
> >  1 file changed, 120 insertions(+), 1 deletion(-)
> >
> > diff --git a/tools/testing/selftests/bpf/test_verifier.c b/tools/testing/selftests/bpf/test_verifier.c
> > index 65ae44c85d27..cf4cd32b6772 100644
> > --- a/tools/testing/selftests/bpf/test_verifier.c
> > +++ b/tools/testing/selftests/bpf/test_verifier.c
> > @@ -48,7 +48,7 @@
> >
> >  #define MAX_INSNS      BPF_MAXINSNS
> >  #define MAX_FIXUPS     8
> > -#define MAX_NR_MAPS    8
> > +#define MAX_NR_MAPS    13
> >  #define POINTER_VALUE  0xcafe4all
> >  #define TEST_DATA_LEN  64
> >
> > @@ -65,6 +65,10 @@ struct bpf_test {
> >         int fixup_map_hash_48b[MAX_FIXUPS];
> >         int fixup_map_hash_16b[MAX_FIXUPS];
> >         int fixup_map_array_48b[MAX_FIXUPS];
> > +       int fixup_map_sockmap[MAX_FIXUPS];
> > +       int fixup_map_sockhash[MAX_FIXUPS];
> > +       int fixup_map_xskmap[MAX_FIXUPS];
> > +       int fixup_map_stacktrace[MAX_FIXUPS];
> >         int fixup_prog1[MAX_FIXUPS];
> >         int fixup_prog2[MAX_FIXUPS];
> >         int fixup_map_in_map[MAX_FIXUPS];
> > @@ -4541,6 +4545,85 @@ static struct bpf_test tests[] = {
> >                 .errstr = "invalid access to packet",
> >                 .prog_type = BPF_PROG_TYPE_SCHED_CLS,
> >         },
> > +       {
> > +               "prevent map lookup in sockmap",
> > +               .insns = {
> > +                       BPF_ST_MEM(BPF_DW, BPF_REG_10, -8, 0),
> > +                       BPF_MOV64_REG(BPF_REG_2, BPF_REG_10),
> > +                       BPF_ALU64_IMM(BPF_ADD, BPF_REG_2, -8),
> > +                       BPF_LD_MAP_FD(BPF_REG_1, 0),
> > +                       BPF_RAW_INSN(BPF_JMP | BPF_CALL, 0, 0, 0,
> > +                                    BPF_FUNC_map_lookup_elem),
> > +                       BPF_EXIT_INSN(),
> > +               },
> > +               .fixup_map_sockmap = { 3 },
> > +               .result = REJECT,
> > +               .errstr = "cannot pass map_type 15 into func bpf_map_lookup_elem",
> > +               .prog_type = BPF_PROG_TYPE_SOCK_OPS,
> > +       },
> > +       {
> > +               "prevent map lookup in sockhash",
> > +               .insns = {
> > +                       BPF_ST_MEM(BPF_DW, BPF_REG_10, -8, 0),
> > +                       BPF_MOV64_REG(BPF_REG_2, BPF_REG_10),
> > +                       BPF_ALU64_IMM(BPF_ADD, BPF_REG_2, -8),
> > +                       BPF_LD_MAP_FD(BPF_REG_1, 0),
> > +                       BPF_RAW_INSN(BPF_JMP | BPF_CALL, 0, 0, 0,
> > +                                    BPF_FUNC_map_lookup_elem),
> > +                       BPF_EXIT_INSN(),
> > +               },
> > +               .fixup_map_sockhash = { 3 },
> > +               .result = REJECT,
> > +               .errstr = "cannot pass map_type 18 into func bpf_map_lookup_elem",
> > +               .prog_type = BPF_PROG_TYPE_SOCK_OPS,
> > +       },
> > +       {
> > +               "prevent map lookup in xskmap",
> > +               .insns = {
> > +                       BPF_ST_MEM(BPF_DW, BPF_REG_10, -8, 0),
> > +                       BPF_MOV64_REG(BPF_REG_2, BPF_REG_10),
> > +                       BPF_ALU64_IMM(BPF_ADD, BPF_REG_2, -8),
> > +                       BPF_LD_MAP_FD(BPF_REG_1, 0),
> > +                       BPF_RAW_INSN(BPF_JMP | BPF_CALL, 0, 0, 0,
> > +                                    BPF_FUNC_map_lookup_elem),
> > +                       BPF_EXIT_INSN(),
> > +               },
> > +               .fixup_map_xskmap = { 3 },
> > +               .result = REJECT,
> > +               .errstr = "cannot pass map_type 17 into func bpf_map_lookup_elem",
> > +               .prog_type = BPF_PROG_TYPE_XDP,
> > +       },
> > +       {
> > +               "prevent map lookup in stack trace",
> > +               .insns = {
> > +                       BPF_ST_MEM(BPF_DW, BPF_REG_10, -8, 0),
> > +                       BPF_MOV64_REG(BPF_REG_2, BPF_REG_10),
> > +                       BPF_ALU64_IMM(BPF_ADD, BPF_REG_2, -8),
> > +                       BPF_LD_MAP_FD(BPF_REG_1, 0),
> > +                       BPF_RAW_INSN(BPF_JMP | BPF_CALL, 0, 0, 0,
> > +                                    BPF_FUNC_map_lookup_elem),
> > +                       BPF_EXIT_INSN(),
> > +               },
> > +               .fixup_map_stacktrace = { 3 },
> > +               .result = REJECT,
> > +               .errstr = "cannot pass map_type 7 into func bpf_map_lookup_elem",
> > +               .prog_type = BPF_PROG_TYPE_PERF_EVENT,
> > +       },
> > +       {
> > +               "prevent map lookup in prog array",
> > +               .insns = {
> > +                       BPF_ST_MEM(BPF_DW, BPF_REG_10, -8, 0),
> > +                       BPF_MOV64_REG(BPF_REG_2, BPF_REG_10),
> > +                       BPF_ALU64_IMM(BPF_ADD, BPF_REG_2, -8),
> > +                       BPF_LD_MAP_FD(BPF_REG_1, 0),
> > +                       BPF_RAW_INSN(BPF_JMP | BPF_CALL, 0, 0, 0,
> > +                                    BPF_FUNC_map_lookup_elem),
> > +                       BPF_EXIT_INSN(),
> > +               },
> > +               .fixup_prog2 = { 3 },
> > +               .result = REJECT,
> > +               .errstr = "cannot pass map_type 3 into func bpf_map_lookup_elem",
> > +       },
> >         {
> >                 "valid map access into an array with a constant",
> >                 .insns = {
> > @@ -13515,6 +13598,10 @@ static void do_test_fixup(struct bpf_test *test, enum bpf_map_type prog_type,
> >         int *fixup_map_hash_48b = test->fixup_map_hash_48b;
> >         int *fixup_map_hash_16b = test->fixup_map_hash_16b;
> >         int *fixup_map_array_48b = test->fixup_map_array_48b;
> > +       int *fixup_map_sockmap = test->fixup_map_sockmap;
> > +       int *fixup_map_sockhash = test->fixup_map_sockhash;
> > +       int *fixup_map_xskmap = test->fixup_map_xskmap;
> > +       int *fixup_map_stacktrace = test->fixup_map_stacktrace;
> >         int *fixup_prog1 = test->fixup_prog1;
> >         int *fixup_prog2 = test->fixup_prog2;
> >         int *fixup_map_in_map = test->fixup_map_in_map;
> > @@ -13603,6 +13690,38 @@ static void do_test_fixup(struct bpf_test *test, enum bpf_map_type prog_type,
> >                         fixup_percpu_cgroup_storage++;
> >                 } while (*fixup_percpu_cgroup_storage);
> >         }
> > +       if (*fixup_map_sockmap) {
> > +               map_fds[9] = create_map(BPF_MAP_TYPE_SOCKMAP, sizeof(int),
> > +                                       sizeof(int), 1);
> > +               do {
> > +                       prog[*fixup_map_sockmap].imm = map_fds[9];
> > +                       fixup_map_sockmap++;
> > +               } while (*fixup_map_sockmap);
> > +       }
> > +       if (*fixup_map_sockhash) {
> > +               map_fds[10] = create_map(BPF_MAP_TYPE_SOCKHASH, sizeof(int),
> > +                                       sizeof(int), 1);
> > +               do {
> > +                       prog[*fixup_map_sockhash].imm = map_fds[10];
> > +                       fixup_map_sockhash++;
> > +               } while (*fixup_map_sockhash);
> > +       }
> > +       if (*fixup_map_xskmap) {
> > +               map_fds[11] = create_map(BPF_MAP_TYPE_XSKMAP, sizeof(int),
> > +                                       sizeof(int), 1);
> > +               do {
> > +                       prog[*fixup_map_xskmap].imm = map_fds[11];
> > +                       fixup_map_xskmap++;
> > +               } while (*fixup_map_xskmap);
> > +       }

selftests: bpf: test_verifier sockmap, sockhash, xskmap failed on
mainline and next
(from 4.19.0-rc7-next-20181011 to till date )
Are we missing any pre-required kernel configs ?

Test log,
------------
selftests: bpf: test_verifier
<>
#274/p prevent map lookup in sockmap Failed to create hash map
'Invalid argument'!
FAIL
Unexpected error message!
EXP: cannot pass map_type 15 into func bpf_map_lookup_elem
RES: fd -1 is not pointing to valid bpf_map
fd -1 is not pointing to valid bpf_map
#275/p prevent map lookup in sockhash Failed to create hash map
'Invalid argument'!
FAIL
Unexpected error message!
EXP: cannot pass map_type 18 into func bpf_map_lookup_elem
RES: fd -1 is not pointing to valid bpf_map
fd -1 is not pointing to valid bpf_map
#276/p prevent map lookup in xskmap Failed to create hash map 'Invalid
argument'!
FAIL
Unexpected error message!
EXP: cannot pass map_type 17 into func bpf_map_lookup_elem
RES: fd -1 is not pointing to valid bpf_map
fd -1 is not pointing to valid bpf_map
<>
Summary: 962 PASSED, 0 SKIPPED, 3 FAILED
not ok 1..1 selftests: bpf: test_verifier [FAIL]
selftests: bpf_test_verifier [FAIL]

-mainline results history,
https://qa-reports.linaro.org/lkft/linux-next-oe/tests/kselftest/bpf_test_verifier

-next results history,
https://qa-reports.linaro.org/lkft/linux-next-oe/tests/kselftest/bpf_test_verifier

Test case full log,
https://lkft.validation.linaro.org/scheduler/job/461881#L1655

Best regards
Naresh Kamboju

> > +       if (*fixup_map_stacktrace) {
> > +               map_fds[12] = create_map(BPF_MAP_TYPE_STACK_TRACE, sizeof(u32),
> > +                                        sizeof(u64), 1);
> > +               do {
> > +                       prog[*fixup_map_stacktrace].imm = map_fds[12];
> > +                       fixup_map_stacktrace++;
> > +               } while (fixup_map_stacktrace);
> > +       }
> >  }
> >
> >  static void do_test_single(struct bpf_test *test, bool unpriv,
> > --
> > 2.17.1
> >
> >

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH bpf-next 6/6] selftests/bpf: test_verifier, check bpf_map_lookup_elem access in bpf prog
  2018-10-25  8:54     ` Naresh Kamboju
@ 2018-10-25  9:09       ` Prashant Bhole
  0 siblings, 0 replies; 16+ messages in thread
From: Prashant Bhole @ 2018-10-25  9:09 UTC (permalink / raw)
  To: Naresh Kamboju, liu.song.a23
  Cc: ast, Daniel Borkmann, jakub.kicinski, David S. Miller,
	quentin.monnet, netdev, open list:KERNEL SELFTEST FRAMEWORK



On 10/25/2018 5:54 PM, Naresh Kamboju wrote:
> On Tue, 9 Oct 2018 at 12:32, Song Liu <liu.song.a23@gmail.com> wrote:
>>
>> On Mon, Oct 8, 2018 at 6:07 PM Prashant Bhole
>> <bhole_prashant_q7@lab.ntt.co.jp> wrote:
>>>
>>> map_lookup_elem isn't supported by certain map types like:
>>> - BPF_MAP_TYPE_PROG_ARRAY
>>> - BPF_MAP_TYPE_STACK_TRACE
>>> - BPF_MAP_TYPE_XSKMAP
>>> - BPF_MAP_TYPE_SOCKMAP/BPF_MAP_TYPE_SOCKHASH
>>> Let's add verfier tests to check whether verifier prevents
>>> bpf_map_lookup_elem call on above programs from bpf program.
>>>
>>> Signed-off-by: Prashant Bhole <bhole_prashant_q7@lab.ntt.co.jp>
>>> Acked-by: Alexei Starovoitov <ast@kernel.org>
>> Acked-by: Song Liu <songliubraving@fb.com>
>>
>>> ---
>>>   tools/testing/selftests/bpf/test_verifier.c | 121 +++++++++++++++++++-
>>>   1 file changed, 120 insertions(+), 1 deletion(-)
>>>
>>> diff --git a/tools/testing/selftests/bpf/test_verifier.c b/tools/testing/selftests/bpf/test_verifier.c
>>> index 65ae44c85d27..cf4cd32b6772 100644
>>> --- a/tools/testing/selftests/bpf/test_verifier.c
>>> +++ b/tools/testing/selftests/bpf/test_verifier.c
>>> @@ -48,7 +48,7 @@
>>>
>>>   #define MAX_INSNS      BPF_MAXINSNS
>>>   #define MAX_FIXUPS     8
>>> -#define MAX_NR_MAPS    8
>>> +#define MAX_NR_MAPS    13
>>>   #define POINTER_VALUE  0xcafe4all
>>>   #define TEST_DATA_LEN  64
>>>
>>> @@ -65,6 +65,10 @@ struct bpf_test {
>>>          int fixup_map_hash_48b[MAX_FIXUPS];
>>>          int fixup_map_hash_16b[MAX_FIXUPS];
>>>          int fixup_map_array_48b[MAX_FIXUPS];
>>> +       int fixup_map_sockmap[MAX_FIXUPS];
>>> +       int fixup_map_sockhash[MAX_FIXUPS];
>>> +       int fixup_map_xskmap[MAX_FIXUPS];
>>> +       int fixup_map_stacktrace[MAX_FIXUPS];
>>>          int fixup_prog1[MAX_FIXUPS];
>>>          int fixup_prog2[MAX_FIXUPS];
>>>          int fixup_map_in_map[MAX_FIXUPS];
>>> @@ -4541,6 +4545,85 @@ static struct bpf_test tests[] = {
>>>                  .errstr = "invalid access to packet",
>>>                  .prog_type = BPF_PROG_TYPE_SCHED_CLS,
>>>          },
>>> +       {
>>> +               "prevent map lookup in sockmap",
>>> +               .insns = {
>>> +                       BPF_ST_MEM(BPF_DW, BPF_REG_10, -8, 0),
>>> +                       BPF_MOV64_REG(BPF_REG_2, BPF_REG_10),
>>> +                       BPF_ALU64_IMM(BPF_ADD, BPF_REG_2, -8),
>>> +                       BPF_LD_MAP_FD(BPF_REG_1, 0),
>>> +                       BPF_RAW_INSN(BPF_JMP | BPF_CALL, 0, 0, 0,
>>> +                                    BPF_FUNC_map_lookup_elem),
>>> +                       BPF_EXIT_INSN(),
>>> +               },
>>> +               .fixup_map_sockmap = { 3 },
>>> +               .result = REJECT,
>>> +               .errstr = "cannot pass map_type 15 into func bpf_map_lookup_elem",
>>> +               .prog_type = BPF_PROG_TYPE_SOCK_OPS,
>>> +       },
>>> +       {
>>> +               "prevent map lookup in sockhash",
>>> +               .insns = {
>>> +                       BPF_ST_MEM(BPF_DW, BPF_REG_10, -8, 0),
>>> +                       BPF_MOV64_REG(BPF_REG_2, BPF_REG_10),
>>> +                       BPF_ALU64_IMM(BPF_ADD, BPF_REG_2, -8),
>>> +                       BPF_LD_MAP_FD(BPF_REG_1, 0),
>>> +                       BPF_RAW_INSN(BPF_JMP | BPF_CALL, 0, 0, 0,
>>> +                                    BPF_FUNC_map_lookup_elem),
>>> +                       BPF_EXIT_INSN(),
>>> +               },
>>> +               .fixup_map_sockhash = { 3 },
>>> +               .result = REJECT,
>>> +               .errstr = "cannot pass map_type 18 into func bpf_map_lookup_elem",
>>> +               .prog_type = BPF_PROG_TYPE_SOCK_OPS,
>>> +       },
>>> +       {
>>> +               "prevent map lookup in xskmap",
>>> +               .insns = {
>>> +                       BPF_ST_MEM(BPF_DW, BPF_REG_10, -8, 0),
>>> +                       BPF_MOV64_REG(BPF_REG_2, BPF_REG_10),
>>> +                       BPF_ALU64_IMM(BPF_ADD, BPF_REG_2, -8),
>>> +                       BPF_LD_MAP_FD(BPF_REG_1, 0),
>>> +                       BPF_RAW_INSN(BPF_JMP | BPF_CALL, 0, 0, 0,
>>> +                                    BPF_FUNC_map_lookup_elem),
>>> +                       BPF_EXIT_INSN(),
>>> +               },
>>> +               .fixup_map_xskmap = { 3 },
>>> +               .result = REJECT,
>>> +               .errstr = "cannot pass map_type 17 into func bpf_map_lookup_elem",
>>> +               .prog_type = BPF_PROG_TYPE_XDP,
>>> +       },
>>> +       {
>>> +               "prevent map lookup in stack trace",
>>> +               .insns = {
>>> +                       BPF_ST_MEM(BPF_DW, BPF_REG_10, -8, 0),
>>> +                       BPF_MOV64_REG(BPF_REG_2, BPF_REG_10),
>>> +                       BPF_ALU64_IMM(BPF_ADD, BPF_REG_2, -8),
>>> +                       BPF_LD_MAP_FD(BPF_REG_1, 0),
>>> +                       BPF_RAW_INSN(BPF_JMP | BPF_CALL, 0, 0, 0,
>>> +                                    BPF_FUNC_map_lookup_elem),
>>> +                       BPF_EXIT_INSN(),
>>> +               },
>>> +               .fixup_map_stacktrace = { 3 },
>>> +               .result = REJECT,
>>> +               .errstr = "cannot pass map_type 7 into func bpf_map_lookup_elem",
>>> +               .prog_type = BPF_PROG_TYPE_PERF_EVENT,
>>> +       },
>>> +       {
>>> +               "prevent map lookup in prog array",
>>> +               .insns = {
>>> +                       BPF_ST_MEM(BPF_DW, BPF_REG_10, -8, 0),
>>> +                       BPF_MOV64_REG(BPF_REG_2, BPF_REG_10),
>>> +                       BPF_ALU64_IMM(BPF_ADD, BPF_REG_2, -8),
>>> +                       BPF_LD_MAP_FD(BPF_REG_1, 0),
>>> +                       BPF_RAW_INSN(BPF_JMP | BPF_CALL, 0, 0, 0,
>>> +                                    BPF_FUNC_map_lookup_elem),
>>> +                       BPF_EXIT_INSN(),
>>> +               },
>>> +               .fixup_prog2 = { 3 },
>>> +               .result = REJECT,
>>> +               .errstr = "cannot pass map_type 3 into func bpf_map_lookup_elem",
>>> +       },
>>>          {
>>>                  "valid map access into an array with a constant",
>>>                  .insns = {
>>> @@ -13515,6 +13598,10 @@ static void do_test_fixup(struct bpf_test *test, enum bpf_map_type prog_type,
>>>          int *fixup_map_hash_48b = test->fixup_map_hash_48b;
>>>          int *fixup_map_hash_16b = test->fixup_map_hash_16b;
>>>          int *fixup_map_array_48b = test->fixup_map_array_48b;
>>> +       int *fixup_map_sockmap = test->fixup_map_sockmap;
>>> +       int *fixup_map_sockhash = test->fixup_map_sockhash;
>>> +       int *fixup_map_xskmap = test->fixup_map_xskmap;
>>> +       int *fixup_map_stacktrace = test->fixup_map_stacktrace;
>>>          int *fixup_prog1 = test->fixup_prog1;
>>>          int *fixup_prog2 = test->fixup_prog2;
>>>          int *fixup_map_in_map = test->fixup_map_in_map;
>>> @@ -13603,6 +13690,38 @@ static void do_test_fixup(struct bpf_test *test, enum bpf_map_type prog_type,
>>>                          fixup_percpu_cgroup_storage++;
>>>                  } while (*fixup_percpu_cgroup_storage);
>>>          }
>>> +       if (*fixup_map_sockmap) {
>>> +               map_fds[9] = create_map(BPF_MAP_TYPE_SOCKMAP, sizeof(int),
>>> +                                       sizeof(int), 1);
>>> +               do {
>>> +                       prog[*fixup_map_sockmap].imm = map_fds[9];
>>> +                       fixup_map_sockmap++;
>>> +               } while (*fixup_map_sockmap);
>>> +       }
>>> +       if (*fixup_map_sockhash) {
>>> +               map_fds[10] = create_map(BPF_MAP_TYPE_SOCKHASH, sizeof(int),
>>> +                                       sizeof(int), 1);
>>> +               do {
>>> +                       prog[*fixup_map_sockhash].imm = map_fds[10];
>>> +                       fixup_map_sockhash++;
>>> +               } while (*fixup_map_sockhash);
>>> +       }
>>> +       if (*fixup_map_xskmap) {
>>> +               map_fds[11] = create_map(BPF_MAP_TYPE_XSKMAP, sizeof(int),
>>> +                                       sizeof(int), 1);
>>> +               do {
>>> +                       prog[*fixup_map_xskmap].imm = map_fds[11];
>>> +                       fixup_map_xskmap++;
>>> +               } while (*fixup_map_xskmap);
>>> +       }
> 
> selftests: bpf: test_verifier sockmap, sockhash, xskmap failed on
> mainline and next
> (from 4.19.0-rc7-next-20181011 to till date )
> Are we missing any pre-required kernel configs ?

sockmap/hashmap is dependent on CONFIG_BPF_STREAM_PARSER and xskmap is 
dependent on CONFIG_XDP_SOCKETS.

Reference: include/linux/bpf_types.h

-Prashant

> 
> Test log,
> ------------
> selftests: bpf: test_verifier
> <>
> #274/p prevent map lookup in sockmap Failed to create hash map
> 'Invalid argument'!
> FAIL
> Unexpected error message!
> EXP: cannot pass map_type 15 into func bpf_map_lookup_elem
> RES: fd -1 is not pointing to valid bpf_map
> fd -1 is not pointing to valid bpf_map
> #275/p prevent map lookup in sockhash Failed to create hash map
> 'Invalid argument'!
> FAIL
> Unexpected error message!
> EXP: cannot pass map_type 18 into func bpf_map_lookup_elem
> RES: fd -1 is not pointing to valid bpf_map
> fd -1 is not pointing to valid bpf_map
> #276/p prevent map lookup in xskmap Failed to create hash map 'Invalid
> argument'!
> FAIL
> Unexpected error message!
> EXP: cannot pass map_type 17 into func bpf_map_lookup_elem
> RES: fd -1 is not pointing to valid bpf_map
> fd -1 is not pointing to valid bpf_map
> <>
> Summary: 962 PASSED, 0 SKIPPED, 3 FAILED
> not ok 1..1 selftests: bpf: test_verifier [FAIL]
> selftests: bpf_test_verifier [FAIL]
> 
> -mainline results history,
> https://qa-reports.linaro.org/lkft/linux-next-oe/tests/kselftest/bpf_test_verifier
> 
> -next results history,
> https://qa-reports.linaro.org/lkft/linux-next-oe/tests/kselftest/bpf_test_verifier
> 
> Test case full log,
> https://lkft.validation.linaro.org/scheduler/job/461881#L1655
> 
> Best regards
> Naresh Kamboju
> 
>>> +       if (*fixup_map_stacktrace) {
>>> +               map_fds[12] = create_map(BPF_MAP_TYPE_STACK_TRACE, sizeof(u32),
>>> +                                        sizeof(u64), 1);
>>> +               do {
>>> +                       prog[*fixup_map_stacktrace].imm = map_fds[12];
>>> +                       fixup_map_stacktrace++;
>>> +               } while (fixup_map_stacktrace);
>>> +       }
>>>   }
>>>
>>>   static void do_test_single(struct bpf_test *test, bool unpriv,
>>> --
>>> 2.17.1
>>>
>>>
> 
> 

^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2018-10-25 17:42 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-10-09  1:04 [PATCH bpf-next 0/6] Error handling when map lookup isn't supported Prashant Bhole
2018-10-09  1:04 ` [PATCH bpf-next 1/6] bpf: error handling when map_lookup_elem " Prashant Bhole
2018-10-09  6:57   ` Song Liu
2018-10-09  1:04 ` [PATCH bpf-next 2/6] bpf: return EOPNOTSUPP when map lookup " Prashant Bhole
2018-10-09  6:58   ` Song Liu
2018-10-09  1:04 ` [PATCH bpf-next 3/6] tools/bpf: bpftool, split the function do_dump() Prashant Bhole
2018-10-09  6:58   ` Song Liu
2018-10-09  1:04 ` [PATCH bpf-next 4/6] tools/bpf: bpftool, print strerror when map lookup error occurs Prashant Bhole
2018-10-09  7:00   ` Song Liu
2018-10-09  1:04 ` [PATCH bpf-next 5/6] selftests/bpf: test_verifier, change names of fixup maps Prashant Bhole
2018-10-09  7:01   ` Song Liu
2018-10-09  1:04 ` [PATCH bpf-next 6/6] selftests/bpf: test_verifier, check bpf_map_lookup_elem access in bpf prog Prashant Bhole
2018-10-09  7:02   ` Song Liu
2018-10-25  8:54     ` Naresh Kamboju
2018-10-25  9:09       ` Prashant Bhole
2018-10-10  4:55 ` [PATCH bpf-next 0/6] Error handling when map lookup isn't supported Alexei Starovoitov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).