lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <d1cb4093-f20a-45c7-bfe3-5be6fd93c844@linux.dev>
Date: Tue, 28 Nov 2023 15:42:15 -0800
From: Martin KaFai Lau <martin.lau@...ux.dev>
To: Quentin Deslandes <qde@...cy.de>
Cc: David Ahern <dsahern@...il.com>, Martin KaFai Lau
 <martin.lau@...nel.org>, netdev@...r.kernel.org
Subject: Re: [PATCH 3/3] ss: pretty-print BPF socket-local storage

On 11/27/23 6:30 PM, Quentin Deslandes wrote:
> +static int bpf_maps_opts_load_btf(struct bpf_map_info *info, struct btf **btf)
> +{
> +	if (info->btf_vmlinux_value_type_id) {
> +		if (!bpf_map_opts.kernel_btf) {
> +			bpf_map_opts.kernel_btf = libbpf_find_kernel_btf();
> +			if (!bpf_map_opts.kernel_btf) {
> +				fprintf(stderr, "ss: failed to load kernel BTF\n");
> +				return -1;
> +			}
> +		}
> +
> +		*btf = bpf_map_opts.kernel_btf;
> +	} else if (info->btf_value_type_id) {
> +		*btf = btf__load_from_kernel_by_id(info->btf_id);
> +		if (!*btf) {
> +			fprintf(stderr, "ss: failed to load BTF for map ID %u\n",
> +				info->id);
> +			return -1;
> +		}
> +	} else {
> +		*btf = NULL;
> +	}
> +
> +	return 0;
> +}

[ ... ]

> +static void out_bpf_sk_storage(int map_id, const void *data, size_t len,
> +	out_prefix_t *prefix)
> +{
> +	uint32_t type_id;
> +	struct bpf_sk_storage_map_info *map_info;
> +
> +	map_info = bpf_map_opts_get_info(map_id);
> +	if (!map_info) {
> +		OUT_P(prefix, "map_id: %d: missing map info", map_id);
> +		return;
> +	}
> +
> +	if (map_info->info.value_size != len) {
> +		OUT_P(prefix, "map_id: %d: invalid value size, expecting %u, got %lu\n",
> +			map_id, map_info->info.value_size, len);
> +		return;
> +	}
> +
> +	type_id = map_info->info.btf_vmlinux_value_type_id ?: map_info->info.btf_value_type_id;

sk_storage does not use info.btf_vmlinux_value_type_id, so no need to handle 
this case. Only info.btf_value_type_id is used.

> +
> +	OUT_P(prefix, "map_id: %d [\n", map_id);
> +	out_prefix_push(prefix);
> +
> +	out_btf_dump_type(map_info->btf, 0, type_id, data, len, prefix);
> +
> +	out_prefix_pop(prefix);
> +	OUT_P(prefix, "]");
> +}
> +



Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ