All of lore.kernel.org
 help / color / mirror / Atom feed
From: Song Liu <liu.song.a23@gmail.com>
To: Magnus Karlsson <magnus.karlsson@intel.com>
Cc: bjorn.topel@intel.com, ast@fb.com,
	Daniel Borkmann <daniel@iogearbox.net>,
	Networking <netdev@vger.kernel.org>,
	qi.z.zhang@intel.com, pavel@fastnetmon.com
Subject: Re: [PATCH bpf 1/4] xsk: fix potential lost completion message in SKB path
Date: Thu, 28 Jun 2018 10:10:33 -0700	[thread overview]
Message-ID: <CAPhsuW6nkVDtN6b7uBP3vein1GWexgnn9SP6_Rmdw=YtC67OZg@mail.gmail.com> (raw)
In-Reply-To: <1530108136-4984-2-git-send-email-magnus.karlsson@intel.com>

On Wed, Jun 27, 2018 at 7:02 AM, Magnus Karlsson
<magnus.karlsson@intel.com> wrote:
> The code in xskq_produce_addr erroneously checked if there
> was up to LAZY_UPDATE_THRESHOLD amount of space in the completion
> queue. It only needs to check if there is one slot left in the
> queue. This bug could under some circumstances lead to a WARN_ON_ONCE
> being triggered and the completion message to user space being lost.
>
> Fixes: 35fcde7f8deb ("xsk: support for Tx")
> Signed-off-by: Magnus Karlsson <magnus.karlsson@intel.com>
> Reported-by: Pavel Odintsov <pavel@fastnetmon.com>

Acked-by: Song Liu <songliubraving@fb.com>

> ---
>  net/xdp/xsk_queue.h | 9 ++-------
>  1 file changed, 2 insertions(+), 7 deletions(-)
>
> diff --git a/net/xdp/xsk_queue.h b/net/xdp/xsk_queue.h
> index ef6a6f0ec949..52ecaf770642 100644
> --- a/net/xdp/xsk_queue.h
> +++ b/net/xdp/xsk_queue.h
> @@ -62,14 +62,9 @@ static inline u32 xskq_nb_avail(struct xsk_queue *q, u32 dcnt)
>         return (entries > dcnt) ? dcnt : entries;
>  }
>
> -static inline u32 xskq_nb_free_lazy(struct xsk_queue *q, u32 producer)
> -{
> -       return q->nentries - (producer - q->cons_tail);
> -}
> -
>  static inline u32 xskq_nb_free(struct xsk_queue *q, u32 producer, u32 dcnt)
>  {
> -       u32 free_entries = xskq_nb_free_lazy(q, producer);
> +       u32 free_entries = q->nentries - (producer - q->cons_tail);
>
>         if (free_entries >= dcnt)
>                 return free_entries;
> @@ -129,7 +124,7 @@ static inline int xskq_produce_addr(struct xsk_queue *q, u64 addr)
>  {
>         struct xdp_umem_ring *ring = (struct xdp_umem_ring *)q->ring;
>
> -       if (xskq_nb_free(q, q->prod_tail, LAZY_UPDATE_THRESHOLD) == 0)
> +       if (xskq_nb_free(q, q->prod_tail, 1) == 0)
>                 return -ENOSPC;
>
>         ring->desc[q->prod_tail++ & q->ring_mask] = addr;
> --
> 2.7.4
>

  reply	other threads:[~2018-06-28 17:10 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-27 14:02 [PATCH bpf 0/4] Bug fixes to the SKB TX path of AF_XDP Magnus Karlsson
2018-06-27 14:02 ` [PATCH bpf 1/4] xsk: fix potential lost completion message in SKB path Magnus Karlsson
2018-06-28 17:10   ` Song Liu [this message]
2018-06-27 14:02 ` [PATCH bpf 2/4] xsk: frame could be completed more than once " Magnus Karlsson
2018-06-27 18:19   ` Song Liu
2018-06-27 14:02 ` [PATCH bpf 3/4] samples/bpf: deal with EBUSY return code from sendmsg in xdpsock sample Magnus Karlsson
2018-06-27 18:21   ` Song Liu
2018-06-27 14:02 ` [PATCH bpf 4/4] xsk: fix potential race in SKB TX completion code Magnus Karlsson
2018-06-27 15:55   ` Eric Dumazet
2018-06-27 21:00     ` Daniel Borkmann
2018-06-28  8:31     ` Magnus Karlsson

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='CAPhsuW6nkVDtN6b7uBP3vein1GWexgnn9SP6_Rmdw=YtC67OZg@mail.gmail.com' \
    --to=liu.song.a23@gmail.com \
    --cc=ast@fb.com \
    --cc=bjorn.topel@intel.com \
    --cc=daniel@iogearbox.net \
    --cc=magnus.karlsson@intel.com \
    --cc=netdev@vger.kernel.org \
    --cc=pavel@fastnetmon.com \
    --cc=qi.z.zhang@intel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.