From owner-svn-src-all@FreeBSD.ORG Thu May 24 00:18:46 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id BC889106564A; Thu, 24 May 2012 00:18:46 +0000 (UTC) (envelope-from jkim@FreeBSD.org) Received: from hammer.pct.niksun.com (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id 3BC128FC0A; Thu, 24 May 2012 00:18:46 +0000 (UTC) Message-ID: <4FBD7E65.1060205@FreeBSD.org> Date: Wed, 23 May 2012 20:18:45 -0400 From: Jung-uk Kim User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:12.0) Gecko/20120502 Thunderbird/12.0.1 MIME-Version: 1.0 To: "Alexander V. Chernikov" References: <201205212219.q4LMJKR9076035@svn.freebsd.org> In-Reply-To: <201205212219.q4LMJKR9076035@svn.freebsd.org> X-Enigmail-Version: 1.5pre Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org Subject: Re: svn commit: r235746 - head/sys/net X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 24 May 2012 00:18:46 -0000 -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On 2012-05-21 18:19:20 -0400, Alexander V. Chernikov wrote: > Author: melifaro Date: Mon May 21 22:19:19 2012 New Revision: > 235746 URL: http://svn.freebsd.org/changeset/base/235746 > > Log: Call bpf_jitter() before acquiring BPF global lock due to > malloc() being used inside bpf_jitter. > > Eliminate bpf_buffer_alloc() and allocate BPF buffers on descriptor > creation and BIOCSBLEN ioctl. This permits us not to allocate > buffers inside bpf_attachd() which is protected by global lock. > > Approved by: kib(mentor) MFC in: 4 weeks > > Modified: head/sys/net/bpf.c head/sys/net/bpf_buffer.c > head/sys/net/bpf_buffer.h > > Modified: head/sys/net/bpf.c > ============================================================================== > > - --- head/sys/net/bpf.c Mon May 21 22:17:29 2012 (r235745) > +++ head/sys/net/bpf.c Mon May 21 22:19:19 2012 (r235746) ... > @@ -1664,7 +1668,7 @@ bpf_setf(struct bpf_d *d, struct bpf_pro > struct bpf_insn *fcode, *old; u_int wfilter, flen, size; #ifdef > BPF_JITTER - bpf_jit_filter *ofunc; + bpf_jit_filter *ofunc, > *jfunc; #endif int need_upgrade; #ifdef COMPAT_FREEBSD32 @@ -1695,6 > +1699,13 @@ bpf_setf(struct bpf_d *d, struct bpf_pro else fcode = > NULL; /* Make compiler happy */ > > +#ifdef BPF_JITTER + if (fp->bf_insns != NULL) + jfunc = > bpf_jitter(fcode, flen); + else + jfunc = NULL; /* Make compiler > happy */ +#endif + BPF_LOCK(); > > if (cmd == BIOCSETWF) { ... This is completely wrong. First, fcode has not been initialized with copyin(). Second, you must not compile random filter code without validation, i.e., bpf_validate(). Jung-uk Kim -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.19 (FreeBSD) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAk+9fmUACgkQmlay1b9qnVOlBACgtljVNwOiFb7Ds7GgeoQMyRRr jU4An3b43yEND8yPs8GSn20ZeCRrI9pu =z4sw -----END PGP SIGNATURE-----