diff options
| author | Dave Airlie <[email protected]> | 2020-03-11 07:27:21 +1000 | 
|---|---|---|
| committer | Dave Airlie <[email protected]> | 2020-03-11 07:27:21 +1000 | 
| commit | d3bd37f587b4438d47751d0f1d5aaae3d39bd416 (patch) | |
| tree | 9414a8fd1ca74c47fe1a3966e0a22469ac0b73a3 /tools/lib/bpf/libbpf.c | |
| parent | 60347451ddb0646c1a9cc5b9581e5bcf648ad1aa (diff) | |
| parent | 2c523b344dfa65a3738e7039832044aa133c75fb (diff) | |
Merge v5.6-rc5 into drm-next
Requested my mripard for some misc patches that need this as a base.
Signed-off-by: Dave Airlie <[email protected]>
Diffstat (limited to 'tools/lib/bpf/libbpf.c')
| -rw-r--r-- | tools/lib/bpf/libbpf.c | 8 | 
1 files changed, 7 insertions, 1 deletions
diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c index 514b1a524abb..7469c7dcc15e 100644 --- a/tools/lib/bpf/libbpf.c +++ b/tools/lib/bpf/libbpf.c @@ -24,6 +24,7 @@  #include <endian.h>  #include <fcntl.h>  #include <errno.h> +#include <ctype.h>  #include <asm/unistd.h>  #include <linux/err.h>  #include <linux/kernel.h> @@ -1283,7 +1284,7 @@ static size_t bpf_map_mmap_sz(const struct bpf_map *map)  static char *internal_map_name(struct bpf_object *obj,  			       enum libbpf_map_type type)  { -	char map_name[BPF_OBJ_NAME_LEN]; +	char map_name[BPF_OBJ_NAME_LEN], *p;  	const char *sfx = libbpf_type_to_btf_name[type];  	int sfx_len = max((size_t)7, strlen(sfx));  	int pfx_len = min((size_t)BPF_OBJ_NAME_LEN - sfx_len - 1, @@ -1292,6 +1293,11 @@ static char *internal_map_name(struct bpf_object *obj,  	snprintf(map_name, sizeof(map_name), "%.*s%.*s", pfx_len, obj->name,  		 sfx_len, libbpf_type_to_btf_name[type]); +	/* sanitise map name to characters allowed by kernel */ +	for (p = map_name; *p && p < map_name + sizeof(map_name); p++) +		if (!isalnum(*p) && *p != '_' && *p != '.') +			*p = '_'; +  	return strdup(map_name);  }  |