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]
Date:   Wed, 22 May 2019 23:16:20 +0000
From:   Roman Gushchin <guro@...com>
To:     Stanislav Fomichev <sdf@...ichev.me>
CC:     "bpf@...r.kernel.org" <bpf@...r.kernel.org>,
        Alexei Starovoitov <ast@...nel.org>,
        Daniel Borkmann <daniel@...earbox.net>,
        "netdev@...r.kernel.org" <netdev@...r.kernel.org>,
        Tejun Heo <tj@...nel.org>, Kernel Team <Kernel-team@...com>,
        "cgroups@...r.kernel.org" <cgroups@...r.kernel.org>,
        "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH bpf-next 3/4] selftests/bpf: enable all available cgroup
 v2 controllers

On Wed, May 22, 2019 at 03:18:43PM -0700, Stanislav Fomichev wrote:
> On 05/22, Roman Gushchin wrote:
> > Enable all available cgroup v2 controllers when setting up
> > the environment for the bpf kselftests. It's required to properly test
> > the bpf prog auto-detach feature. Also it will generally increase
> > the code coverage.
> > 
> > Signed-off-by: Roman Gushchin <guro@...com>
> > ---
> >  tools/testing/selftests/bpf/cgroup_helpers.c | 58 ++++++++++++++++++++
> >  1 file changed, 58 insertions(+)
> > 
> > diff --git a/tools/testing/selftests/bpf/cgroup_helpers.c b/tools/testing/selftests/bpf/cgroup_helpers.c
> > index 6692a40a6979..4533839c0ce0 100644
> > --- a/tools/testing/selftests/bpf/cgroup_helpers.c
> > +++ b/tools/testing/selftests/bpf/cgroup_helpers.c
> > @@ -33,6 +33,61 @@
> >  	snprintf(buf, sizeof(buf), "%s%s%s", CGROUP_MOUNT_PATH, \
> >  		 CGROUP_WORK_DIR, path)
> >  
> > +/**
> > + * enable_all_controllers() - Enable all available cgroup v2 controllers
> > + *
> > + * Enable all available cgroup v2 controllers in order to increase
> > + * the code coverage.
> > + *
> > + * If successful, 0 is returned.
> > + */
> > +int enable_all_controllers(char *cgroup_path)
> > +{
> > +	char path[PATH_MAX + 1];
> > +	char buf[PATH_MAX];
> > +	char *c, *c2;
> > +	int fd, cfd;
> > +	size_t len;
> > +
> > +	snprintf(path, sizeof(path), "%s/cgroup.controllers", cgroup_path);
> > +	fd = open(path, O_RDONLY);
> > +	if (fd < 0) {
> > +		log_err("Opening cgroup.controllers: %s", path);
> > +		return -1;
> > +	}
> > +
> > +	len = read(fd, buf, sizeof(buf) - 1);
> > +	if (len < 0) {
> > +		close(fd);
> > +		log_err("Reading cgroup.controllers: %s", path);
> > +		return -1;
> > +	}
> > +
> > +	close(fd);
> > +
> > +	/* No controllers available? We're probably on cgroup v1. */
> > +	if (len == 0)
> > +		return 0;
> > +
> > +	snprintf(path, sizeof(path), "%s/cgroup.subtree_control", cgroup_path);
> > +	cfd = open(path, O_RDWR);
> > +	if (cfd < 0) {
> > +		log_err("Opening cgroup.subtree_control: %s", path);
> > +		return -1;
> > +	}
> > +
> 
> [..]
> > +	buf[len] = 0;
> nit: move this up a bit? Right after:

Ok, np. Thanks!

Powered by blists - more mailing lists