From mboxrd@z Thu Jan 1 00:00:00 1970 From: Denis Efremov Subject: [PATCH] bridge: rcu_deref outside read-lock section Date: Tue, 14 Aug 2012 02:47:42 +0400 Message-ID: <1344898062-23633-1-git-send-email-yefremov.denis@gmail.com> Return-path: DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer; bh=vGZDjqBl86lA09aNR/ySl68vgXya7Qi+gypRI0YFCKk=; b=qlQida+PrP+ah/ke2zG8NJ9aQCdGtTkSVNYV+t1wN5uLKsPreMN5XzXe0I/vgb9atn B/xsvjGkuIEyvU+e2qCF3R/dhRBdC3ijdVe7+7lON7yboB0kaFmfnSYu7iJZJ+wQmU4Y sBQeRMsCaFIo8v74WcY2RLyXzriE+BQ3Vehkf5k9L2ctMcL7UoC3QVg15otsTiNWHSyX NA+2QeAeJJ3SUznZZECv3BgFc0XcEor+kZaZOTcon3WnlxJnw1Bq2ck3ycrVY3/DmCLS cf4VV207/oaR44klrGYI/Tlf9EmA5HhW1Ua3QLU1FCZAujA2IeqgJnBKwWAMkMpBykis miPw== Sender: netfilter-owner@vger.kernel.org List-ID: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: Pablo Neira Ayuso Cc: Denis Efremov , Patrick McHardy , netfilter-devel@vger.kernel.org, netfilter@vger.kernel.org, coreteam@netfilter.org, linux-kernel@vger.kernel.org, ldv-project@ispras.ru 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. I have put lock/unlock in br_nf_pre_routing_finish_bridge_slow, as the only function that calls it(for now) - is br_dev_xmit. Found by Linux Driver Verification project (linuxtesting.org). Signed-off-by: Denis Efremov --- include/linux/netfilter_bridge.h | 6 +++++- 1 files changed, 5 insertions(+), 1 deletions(-) diff --git a/include/linux/netfilter_bridge.h b/include/linux/netfilter_bridge.h index 31d2844..ceb048e 100644 --- a/include/linux/netfilter_bridge.h +++ b/include/linux/netfilter_bridge.h @@ -79,6 +79,7 @@ extern int br_handle_frame_finish(struct sk_buff *skb); /* Only used in br_device.c */ static inline int br_nf_pre_routing_finish_bridge_slow(struct sk_buff *skb) { + int res; struct nf_bridge_info *nf_bridge = skb->nf_bridge; skb_pull(skb, ETH_HLEN); @@ -86,7 +87,10 @@ static inline int br_nf_pre_routing_finish_bridge_slow(struct sk_buff *skb) skb_copy_to_linear_data_offset(skb, -(ETH_HLEN-ETH_ALEN), skb->nf_bridge->data, ETH_HLEN-ETH_ALEN); skb->dev = nf_bridge->physindev; - return br_handle_frame_finish(skb); + rcu_read_lock(); + res = br_handle_frame_finish(skb); + rcu_read_unlock(); + return res; } /* This is called by the IP fragmenting code and it ensures there is -- 1.7.7