From: Stephen Hemminger <shemminger@vyatta.com>
To: Denis Efremov <yefremov.denis@gmail.com>
Cc: "David S. Miller" <davem@davemloft.net>,
pablo@netfilter.org, kaber@trash.net,
netfilter-devel@vger.kernel.org, netfilter@vger.kernel.org,
coreteam@netfilter.org, linux-kernel@vger.kernel.org,
ldv-project@ispras.ru
Subject: [PATCH] bridge: fix rcu dereference outside of rcu_read_lock
Date: Tue, 14 Aug 2012 08:19:33 -0700 [thread overview]
Message-ID: <20120814081933.30f3e868@nehalam.linuxnetplumber.net> (raw)
In-Reply-To: <1344931732-1858-1-git-send-email-yefremov.denis@gmail.com>
Alternative solution for problem found by Linux Driver Verification
project (linuxtesting.org).
As it noted in the comment before the br_handle_frame_finish
function, this function should be called under rcu_read_lock.
The problem callgraph:
br_dev_xmit -> br_nf_pre_routing_finish_bridge_slow ->
-> br_handle_frame_finish -> br_port_get_rcu -> rcu_dereference
And in this case there is no read-lock section.
Reported-by: Denis Efremov <yefremov.denis@gmail.com>
Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>
---
net/bridge/br_device.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/net/bridge/br_device.c b/net/bridge/br_device.c
index 3334845..8a3b50f 100644
--- a/net/bridge/br_device.c
+++ b/net/bridge/br_device.c
@@ -31,9 +31,11 @@ netdev_tx_t br_dev_xmit(struct sk_buff *skb, struct net_device *dev)
struct net_bridge_mdb_entry *mdst;
struct br_cpu_netstats *brstats = this_cpu_ptr(br->stats);
+ rcu_read_lock();
#ifdef CONFIG_BRIDGE_NETFILTER
if (skb->nf_bridge && (skb->nf_bridge->mask & BRNF_BRIDGED_DNAT)) {
br_nf_pre_routing_finish_bridge_slow(skb);
+ rcu_read_unlock();
return NETDEV_TX_OK;
}
#endif
@@ -48,7 +50,6 @@ netdev_tx_t br_dev_xmit(struct sk_buff *skb, struct net_device *dev)
skb_reset_mac_header(skb);
skb_pull(skb, ETH_HLEN);
- rcu_read_lock();
if (is_broadcast_ether_addr(dest))
br_flood_deliver(br, skb);
else if (is_multicast_ether_addr(dest)) {
--
1.7.10.4
next prev parent reply other threads:[~2012-08-14 15:19 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-08-13 22:47 [PATCH] bridge: rcu_deref outside read-lock section Denis Efremov
2012-08-13 22:47 ` [PATCH] [NETFILTER] " Denis Efremov
2012-08-13 23:36 ` Stephen Hemminger
2012-08-14 7:32 ` Denis
2012-08-14 8:08 ` [PATCH v2] " Denis Efremov
2012-08-14 15:19 ` Stephen Hemminger [this message]
2012-08-15 22:10 ` [PATCH] bridge: fix rcu dereference outside of rcu_read_lock David Miller
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=20120814081933.30f3e868@nehalam.linuxnetplumber.net \
--to=shemminger@vyatta.com \
--cc=coreteam@netfilter.org \
--cc=davem@davemloft.net \
--cc=kaber@trash.net \
--cc=ldv-project@ispras.ru \
--cc=linux-kernel@vger.kernel.org \
--cc=netfilter-devel@vger.kernel.org \
--cc=netfilter@vger.kernel.org \
--cc=pablo@netfilter.org \
--cc=yefremov.denis@gmail.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.