bpf.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Daniel Borkmann <daniel@iogearbox.net>
To: Magnus Karlsson <magnus.karlsson@gmail.com>,
	Fletcher Dunn <fletcherd@valvesoftware.com>
Cc: Alexei Starovoitov <ast@kernel.org>,
	Martin KaFai Lau <kafai@fb.com>, Song Liu <songliubraving@fb.com>,
	Yonghong Song <yhs@fb.com>, Andrii Nakryiko <andriin@fb.com>,
	"netdev@vger.kernel.org" <netdev@vger.kernel.org>,
	"bpf@vger.kernel.org" <bpf@vger.kernel.org>,
	Brandon Gilmore <bgilmore@valvesoftware.com>,
	Steven Noonan <steven@valvesoftware.com>
Subject: Re: [PATCH bpf-next] xsk: Init all ring members in xsk_umem__create and xsk_socket__create
Date: Sat, 28 Mar 2020 18:14:25 +0100	[thread overview]
Message-ID: <ae371400-e37f-bbac-691e-cc50235f1ee0@iogearbox.net> (raw)
In-Reply-To: <CAJ8uoz2M0Xj_maD3jZeZedrUXGNJqvbV_DyC2A8Yh9R6z7gfsg@mail.gmail.com>

On 3/28/20 10:18 AM, Magnus Karlsson wrote:
> On Fri, Mar 27, 2020 at 4:40 AM Fletcher Dunn
> <fletcherd@valvesoftware.com> wrote:
>>
>> Fix a sharp edge in xsk_umem__create and xsk_socket__create.  Almost all of
>> the members of the ring buffer structs are initialized, but the "cached_xxx"
>> variables are not all initialized.  The caller is required to zero them.
>> This is needlessly dangerous.  The results if you don't do it can be very bad.
>> For example, they can cause xsk_prod_nb_free and xsk_cons_nb_avail to return
>> values greater than the size of the queue.  xsk_ring_cons__peek can return an
>> index that does not refer to an item that has been queued.
>>
>> I have confirmed that without this change, my program misbehaves unless I
>> memset the ring buffers to zero before calling the function.  Afterwards,
>> my program works without (or with) the memset.
> 
> Thank you Flecther for catching this. Appreciated.
> 
> /Magnus
> 
> Acked-by: Magnus Karlsson <magnus.karlsson@intel.com>

Applied, thanks!

      reply	other threads:[~2020-03-28 17:14 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-27  3:24 [PATCH bpf-next] xsk: Init all ring members in xsk_umem__create and xsk_socket__create Fletcher Dunn
2020-03-28  9:18 ` Magnus Karlsson
2020-03-28 17:14   ` Daniel Borkmann [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ae371400-e37f-bbac-691e-cc50235f1ee0@iogearbox.net \
    --to=daniel@iogearbox.net \
    --cc=andriin@fb.com \
    --cc=ast@kernel.org \
    --cc=bgilmore@valvesoftware.com \
    --cc=bpf@vger.kernel.org \
    --cc=fletcherd@valvesoftware.com \
    --cc=kafai@fb.com \
    --cc=magnus.karlsson@gmail.com \
    --cc=netdev@vger.kernel.org \
    --cc=songliubraving@fb.com \
    --cc=steven@valvesoftware.com \
    --cc=yhs@fb.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).