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] [thread-next>] [day] [month] [year] [list]
Message-ID: <ZTCD2v7RuQojbkn-@u94a>
Date: Thu, 19 Oct 2023 09:18:18 +0800
From: Shung-Hsi Yu <shung-hsi.yu@...e.com>
To: David Ahern <dsahern@...nel.org>
Cc: netdev@...r.kernel.org, Stephen Hemminger <stephen@...workplumber.org>,
	Toke Høiland-Jørgensen <toke@...hat.com>
Subject: Re: [PATCH iproute2-next 2/2] bpf: increase verifier verbosity when
 in verbose mode

On Wed, Oct 18, 2023 at 08:35:30AM -0600, David Ahern wrote:
> On 10/18/23 12:22 AM, Shung-Hsi Yu wrote:
> > diff --git a/lib/bpf_libbpf.c b/lib/bpf_libbpf.c
> > index f678a710..08692d30 100644
> > --- a/lib/bpf_libbpf.c
> > +++ b/lib/bpf_libbpf.c
> > @@ -285,11 +285,14 @@ static int load_bpf_object(struct bpf_cfg_in *cfg)
> >  	DECLARE_LIBBPF_OPTS(bpf_object_open_opts, open_opts,
> >  			.relaxed_maps = true,
> >  			.pin_root_path = root_path,
> > -#ifdef (LIBBPF_MAJOR_VERSION > 0) || (LIBBPF_MINOR_VERSION >= 7)
> > -			.kernel_log_level = 1,
> > -#endif
> >  	);
> >  
> > +#if (LIBBPF_MAJOR_VERSION > 0) || (LIBBPF_MINOR_VERSION >= 7)
> > +	open_opts.kernel_log_level = 1;
> > +	if (cfg->verbose)
> > +		open_opts.kernel_log_level |= 2;
> > +#endif
> > +
> >  	obj = bpf_object__open_file(cfg->object, &open_opts);
> >  	if (libbpf_get_error(obj)) {
> >  		fprintf(stderr, "ERROR: opening BPF object file failed\n");
> 
> Why have the first patch if you redo the code here?

Ah, good point. I was trying to separate out libbpf-related changes from
verbosity-increasing changes, hence the first patch. And there I add the
.kernel_log_level field within DECLARE_LIBBPF_OPTS() because that seems to
be how it's usually done.

In the second patch I tried to make log-level changes consistent, having
them all done with `|= 2`, which isn't possible within
DECLARE_LIBBPF_OPTS().

Maybe I should have just have `open_opts.kernel_log_level = 1;` outside of
DECLARE_LIBBPF_OPTS() in the first patch to begin with.

+#if (LIBBPF_MAJOR_VERSION > 0) || (LIBBPF_MINOR_VERSION >= 7)
+	open_opts.kernel_log_level = 1;
+#endif

Followed by

 #if (LIBBPF_MAJOR_VERSION > 0) || (LIBBPF_MINOR_VERSION >= 7)
 	open_opts.kernel_log_level = 1;
+	if (cfg->verbose)
+		open_opts.kernel_log_level |= 2;
 #endif

Would be better than

 	DECLARE_LIBBPF_OPTS(bpf_object_open_opts, open_opts,
 			.relaxed_maps = true,
 			.pin_root_path = root_path,
+#ifdef (LIBBPF_MAJOR_VERSION > 0) || (LIBBPF_MINOR_VERSION >= 7)
+			.kernel_log_level = 1,
+#endif
 	);

Followed by

 	DECLARE_LIBBPF_OPTS(bpf_object_open_opts, open_opts,
 			.relaxed_maps = true,
 			.pin_root_path = root_path,
 #ifdef (LIBBPF_MAJOR_VERSION > 0) || (LIBBPF_MINOR_VERSION >= 7)
-			.kernel_log_level = 1,
+			.kernel_log_level = cfg->verbose ? (2 | 1) : 1,
 #endif
 	);

I suppose. What do you think?

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ