netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Magnus Karlsson <magnus.karlsson@gmail.com>
To: Marek Majtyka <alardam@gmail.com>
Cc: "Karlsson, Magnus" <magnus.karlsson@intel.com>,
	"Björn Töpel" <bjorn.topel@intel.com>,
	"Alexei Starovoitov" <ast@kernel.org>,
	"Daniel Borkmann" <daniel@iogearbox.net>,
	"Network Development" <netdev@vger.kernel.org>,
	"Jonathan Lemon" <jonathan.lemon@gmail.com>,
	"Marek Majtyka" <marekx.majtyka@intel.com>,
	bpf <bpf@vger.kernel.org>
Subject: Re: [PATCH bpf] xsk: fix incorrect netdev reference count
Date: Mon, 23 Nov 2020 09:28:29 +0100	[thread overview]
Message-ID: <CAJ8uoz2p4tZVGDjSn5WW3hWne0+4HWvAg8Z0JvkVA5z+hygVNw@mail.gmail.com> (raw)
In-Reply-To: <20201120151443.105903-1-marekx.majtyka@intel.com>

On Fri, Nov 20, 2020 at 4:17 PM <alardam@gmail.com> wrote:
>
> From: Marek Majtyka <marekx.majtyka@intel.com>
>
> Fix incorrect netdev reference count in xsk_bind operation. Incorrect
> reference count of the device appears when a user calls bind with the
> XDP_ZEROCOPY flag on an interface which does not support zero-copy.
> In such a case, an error is returned but the reference count is not
> decreased. This change fixes the fault, by decreasing the reference count
> in case of such an error.
>
> The problem being corrected appeared in '162c820ed896' for the first time,
> and the code was moved to new file location over the time with commit
> 'c2d3d6a47462'. This specific patch applies to all version starting
> from 'c2d3d6a47462'. The same solution should be applied but on different
> file (net/xdp/xdp_umem.c) and function (xdp_umem_assign_dev) for versions
> from '162c820ed896' to 'c2d3d6a47462' excluded.
>
> Fixes: 162c820ed896 ("xdp: hold device for umem regardless of zero- ...")
> Signed-off-by: Marek Majtyka <marekx.majtyka@intel.com>
> ---
>  net/xdp/xsk_buff_pool.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/net/xdp/xsk_buff_pool.c b/net/xdp/xsk_buff_pool.c
> index 8a3bf4e1318e..46d09bfb1923 100644
> --- a/net/xdp/xsk_buff_pool.c
> +++ b/net/xdp/xsk_buff_pool.c
> @@ -185,8 +185,10 @@ static int __xp_assign_dev(struct xsk_buff_pool *pool,
>  err_unreg_pool:
>         if (!force_zc)
>                 err = 0; /* fallback to copy mode */
> -       if (err)
> +       if (err) {
>                 xsk_clear_pool_at_qid(netdev, queue_id);
> +               dev_put(netdev);
> +       }
>         return err;
>  }

Thank you Marek for spotting and fixing this!

Acked-by: Magnus Karlsson <magnus.karlsson@intel.com>

> --
> 2.27.0
>

  reply	other threads:[~2020-11-23  8:29 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-20 15:14 [PATCH bpf] xsk: fix incorrect netdev reference count alardam
2020-11-23  8:28 ` Magnus Karlsson [this message]
2020-11-23 12:30 ` patchwork-bot+netdevbpf

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=CAJ8uoz2p4tZVGDjSn5WW3hWne0+4HWvAg8Z0JvkVA5z+hygVNw@mail.gmail.com \
    --to=magnus.karlsson@gmail.com \
    --cc=alardam@gmail.com \
    --cc=ast@kernel.org \
    --cc=bjorn.topel@intel.com \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=jonathan.lemon@gmail.com \
    --cc=magnus.karlsson@intel.com \
    --cc=marekx.majtyka@intel.com \
    --cc=netdev@vger.kernel.org \
    /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).