Skip to content

Commit 6b69c4a

Browse files
committed
Fix bug in _find_lpm_map_entry() hit by fuzzer
Signed-off-by: Dave Thaler <[email protected]>
1 parent d292184 commit 6b69c4a

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

libs/execution_context/ebpf_maps.c

+6-5
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ _delete_array_map(_In_ _Post_invalid_ ebpf_core_map_t* map)
280280

281281
static ebpf_result_t
282282
_find_array_map_entry(
283-
_In_ ebpf_core_map_t* map, _In_ const uint8_t* key, _In_ bool delete_on_success, _Outptr_ uint8_t** data)
283+
_In_ ebpf_core_map_t* map, _In_opt_ const uint8_t* key, _In_ bool delete_on_success, _Outptr_ uint8_t** data)
284284
{
285285
uint32_t key_value;
286286
if (!map || !key || delete_on_success)
@@ -929,7 +929,7 @@ _delete_hash_map_entry(_In_ ebpf_core_map_t* map, _In_ const uint8_t* key);
929929

930930
static ebpf_result_t
931931
_find_hash_map_entry(
932-
_In_ ebpf_core_map_t* map, _In_ const uint8_t* key, _In_ bool delete_on_success, _Outptr_ uint8_t** data)
932+
_In_ ebpf_core_map_t* map, _In_opt_ const uint8_t* key, _In_ bool delete_on_success, _Outptr_ uint8_t** data)
933933
{
934934
uint8_t* value = NULL;
935935
if (!map || !key)
@@ -1254,14 +1254,15 @@ _create_lpm_map(
12541254

12551255
static ebpf_result_t
12561256
_find_lpm_map_entry(
1257-
_In_ ebpf_core_map_t* map, _In_ const uint8_t* key, _In_ bool delete_on_success, _Outptr_ uint8_t** data)
1257+
_In_ ebpf_core_map_t* map, _In_opt_ const uint8_t* key, _In_ bool delete_on_success, _Outptr_ uint8_t** data)
12581258
{
1259+
if (!map || !key || delete_on_success)
1260+
return EBPF_INVALID_ARGUMENT;
1261+
12591262
uint32_t* prefix_length = (uint32_t*)key;
12601263
uint32_t original_prefix_length = *prefix_length;
12611264
uint8_t* value = NULL;
12621265
ebpf_core_lpm_map_t* trie_map = EBPF_FROM_FIELD(ebpf_core_lpm_map_t, core_map, map);
1263-
if (!map || !key || delete_on_success)
1264-
return EBPF_INVALID_ARGUMENT;
12651266

12661267
ebpf_bitmap_cursor_t cursor;
12671268
ebpf_bitmap_start_reverse_search((ebpf_bitmap_t*)trie_map->data, &cursor);

0 commit comments

Comments
 (0)