netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: David Miller <davem@davemloft.net>
To: john.fastabend@gmail.com
Cc: jasowang@redhat.com, mst@redhat.com, john.r.fastabend@intel.com,
	netdev@vger.kernel.org, alexei.starovoitov@gmail.com,
	daniel@iogearbox.net
Subject: Re: [net PATCH v4 2/6] virtio_net: wrap rtnl_lock in test for calling with lock already held
Date: Tue, 17 Jan 2017 11:57:33 -0500 (EST)	[thread overview]
Message-ID: <20170117.115733.428297564258724055.davem@davemloft.net> (raw)
In-Reply-To: <20170115235947.28980.92147.stgit@john-Precision-Tower-5810>

From: John Fastabend <john.fastabend@gmail.com>
Date: Sun, 15 Jan 2017 15:59:47 -0800

> @@ -2358,7 +2371,10 @@ static void remove_vq_common(struct virtnet_info *vi)
>  	/* Free unused buffers in both send and recv, if any. */
>  	free_unused_bufs(vi);
>  
> -	free_receive_bufs(vi);
> +	if (rtnl_is_locked())
> +		_free_receive_bufs(vi);
> +	else
> +		free_receive_bufs(vi);
>  
>  	free_receive_page_frags(vi);
>  

This doesn't work.  rtnl_is_locked() doesn't tell if _you_ own the mutex, it
just says that someone does.

So if we now execute this code without taking the RTNL lock just because some
other thread of control holds it, we introduce a race.

  reply	other threads:[~2017-01-17 17:06 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-01-15 23:59 [net PATCH v4 0/6] virtio_net XDP fixes and adjust_header support John Fastabend
2017-01-15 23:59 ` [net PATCH v4 1/6] virtio_net: use dev_kfree_skb for small buffer XDP receive John Fastabend
2017-01-15 23:59 ` [net PATCH v4 2/6] virtio_net: wrap rtnl_lock in test for calling with lock already held John Fastabend
2017-01-17 16:57   ` David Miller [this message]
2017-01-17 19:03     ` John Fastabend
2017-01-16  0:00 ` [net PATCH v4 3/6] virtio_net: factor out xdp handler for readability John Fastabend
2017-01-16  0:00 ` [net PATCH v4 4/6] virtio_net: remove duplicate queue pair binding in XDP John Fastabend
2017-01-16  0:01 ` [net PATCH v4 5/6] virtio: add pci_down/pci_up configuration John Fastabend
2017-01-16  3:57   ` Jason Wang
2017-01-16  4:04     ` John Fastabend
2017-01-17 18:45       ` John Fastabend
2017-01-16  0:01 ` [net PATCH v4 6/6] virtio_net: XDP support for adjust_head John Fastabend
2017-01-16  5:48   ` Jason Wang
2017-01-16  5:51 ` [net PATCH v4 0/6] virtio_net XDP fixes and adjust_header support Jason Wang

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=20170117.115733.428297564258724055.davem@davemloft.net \
    --to=davem@davemloft.net \
    --cc=alexei.starovoitov@gmail.com \
    --cc=daniel@iogearbox.net \
    --cc=jasowang@redhat.com \
    --cc=john.fastabend@gmail.com \
    --cc=john.r.fastabend@intel.com \
    --cc=mst@redhat.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).