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: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <0370e35c-a06b-40dd-90b4-50cc30db224c@kernel.org>
Date: Thu, 28 Nov 2024 09:58:52 +0000
From: Quentin Monnet <qmo@...nel.org>
To: liujing <liujing@...s.chinamobile.com>, ast@...nel.org,
 daniel@...earbox.net, andrii@...nel.org, martin.lau@...ux.dev,
 eddyz87@...il.com, song@...nel.org, yonghong.song@...ux.dev,
 john.fastabend@...il.com, kpsingh@...nel.org, sdf@...ichev.me,
 haoluo@...gle.com, jolsa@...nel.org
Cc: bpf@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] tools/bpf: bpftool:Fix the wrong format specifier

Please drop the "tools/bpf: " part of the prefix in your patch title,
it's enough to keep "bpftool: ".


2024-11-28 10:55 UTC+0800 ~ liujing <liujing@...s.chinamobile.com>
> The output format of unsigned int should be %u, and the output
> format of int should be %d, so fix it.
> 
> Signed-off-by: liujing <liujing@...s.chinamobile.com>
> 
> diff --git a/tools/bpf/bpftool/netlink_dumper.c b/tools/bpf/bpftool/netlink_dumper.c
> index 5f65140b003b..97e1e1dbc842 100644
> --- a/tools/bpf/bpftool/netlink_dumper.c
> +++ b/tools/bpf/bpftool/netlink_dumper.c
> @@ -45,7 +45,7 @@ static int do_xdp_dump_one(struct nlattr *attr, unsigned int ifindex,
>  	NET_START_OBJECT;
>  	if (name)
>  		NET_DUMP_STR("devname", "%s", name);
> -	NET_DUMP_UINT("ifindex", "(%d)", ifindex);
> +	NET_DUMP_UINT("ifindex", "(%u)", ifindex);
>  
>  	if (mode == XDP_ATTACHED_MULTI) {
>  		if (json_output) {
> @@ -168,7 +168,7 @@ int do_filter_dump(struct tcmsg *info, struct nlattr **tb, const char *kind,
>  		NET_START_OBJECT;
>  		if (devname[0] != '\0')
>  			NET_DUMP_STR("devname", "%s", devname);
> -		NET_DUMP_UINT("ifindex", "(%u)", ifindex);
> +		NET_DUMP_UINT("ifindex", "(%d)", ifindex);
>  		NET_DUMP_STR("kind", " %s", kind);
>  		ret = do_bpf_filter_dump(tb[TCA_OPTIONS]);
>  		NET_END_OBJECT_FINAL;


Thanks for this. The second chunk is not enough to fix the format
specifier cleanly, because NET_DUMP_UINT() may end up calling:

	jsonw_printf(self, "%"PRIu64, num);

So you probably need to add a NET_DUMP_INT() wrapper and call it here.

There's also another occurrence of the macro called on a signed
"ifindex" in net.c, in __show_dev_tc_bpf(), using "(%u)". Let's fix it
in the same patch, please?

Thanks,
Quentin

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ