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: <20150911145916.GK27574@smitten>
Date:	Fri, 11 Sep 2015 08:59:16 -0600
From:	Tycho Andersen <tycho.andersen@...onical.com>
To:	Alexei Starovoitov <alexei.starovoitov@...il.com>
Cc:	Kees Cook <keescook@...omium.org>,
	Alexei Starovoitov <ast@...nel.org>,
	"David S. Miller" <davem@...emloft.net>,
	Will Drewry <wad@...omium.org>,
	Oleg Nesterov <oleg@...hat.com>,
	Andy Lutomirski <luto@...capital.net>,
	Pavel Emelyanov <xemul@...allels.com>,
	"Serge E. Hallyn" <serge.hallyn@...ntu.com>,
	Daniel Borkmann <daniel@...earbox.net>,
	linux-kernel@...r.kernel.org, netdev@...r.kernel.org,
	linux-api@...r.kernel.org
Subject: Re: [PATCH v2 3/5] ebpf: add a way to dump an eBPF program

On Thu, Sep 10, 2015 at 07:29:42PM -0700, Alexei Starovoitov wrote:
> On Thu, Sep 10, 2015 at 06:21:00PM -0600, Tycho Andersen wrote:
> > +static int bpf_prog_dump(union bpf_attr *attr, union bpf_attr __user *uattr)
> > +{
> > +	int ufd = attr->prog_fd;
> > +	struct fd f = fdget(ufd);
> > +	struct bpf_prog *prog;
> > +	int ret = -EINVAL;
> > +
> > +	prog = get_prog(f);
> > +	if (IS_ERR(prog))
> > +		return PTR_ERR(prog);
> > +
> > +	/* For now, let's refuse to dump anything that isn't a seccomp program.
> > +	 * Other program types have support for maps, which our current dump
> > +	 * code doesn't support.
> > +	 */
> > +	if (prog->type != BPF_PROG_TYPE_SECCOMP)
> > +		goto out;
> > +
> > +	ret = -EFAULT;
> > +	if (put_user(prog->len, &uattr->dump_insn_cnt))
> > +		goto out;
> > +
> > +	if (put_user((u8) prog->gpl_compatible, &uattr->gpl_compatible))
> > +		goto out;
> > +
> > +	if (attr->dump_insns) {
> > +		u32 len = prog->len * sizeof(struct bpf_insn);
> > +
> > +		if (copy_to_user(u64_to_ptr(attr->dump_insns),
> > +				 prog->insns, len) != 0)
> > +			goto out;
> > +	}
> > +
> > +	ret = 0;
> > +out:
> > +	return ret;
> 
> fdput() is missing in all error paths.

So it is, thanks!

Tycho
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ