public inbox for linux-rdma@vger.kernel.org
 help / color / mirror / Atom feed
From: Eric Dumazet <eric.dumazet-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
To: Marc Aurele La France
	<tsi-yfeSBMgouQgsA/PxXw9srA@public.gmane.org>,
	Neil Horman <nhorman-2XuSBdqkA4R54TAoqtyWWQ@public.gmane.org>
Cc: Roland Dreier <roland-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>,
	David Miller <davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org>,
	netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: [PATCH net-next] net: proper locking in skb_update_prio()
Date: Wed, 30 Nov 2011 00:24:38 +0100	[thread overview]
Message-ID: <1322609078.2596.53.camel@edumazet-laptop> (raw)
In-Reply-To: <1322608261.2596.48.camel@edumazet-laptop>

Le mercredi 30 novembre 2011 à 00:11 +0100, Eric Dumazet a écrit :

> Some changes are needed now rcu_read_lock_bh() doesnt imply
> rcu_read_lock().
> 
> For example, recently added skb_update_prio() is buggy, since it uses
> rcu_dereference() while its caller, dev_queue_xmit() called
> rcu_read_lock_bh()
> 
> 

[PATCH net-next] net: proper locking in skb_update_prio()

We must use rcu_read_lock() in skb_update_prio(), since dev_queue_xmit()
uses rcu_read_lock_bh()

[   15.441620] [ INFO: suspicious RCU usage. ]
[   15.441622] -------------------------------
[   15.441624] net/core/dev.c:2476 suspicious rcu_dereference_check() usage!
[   15.441625] 
[   15.441626] other info that might help us debug this:
[   15.441626] 
[   15.441628] 
[   15.441628] rcu_scheduler_active = 1, debug_locks = 1
[   15.441630] 1 lock held by arping/4373:
[   15.441632]  #0:  (rcu_read_lock_bh){......}, at: [<c13049b0>] dev_queue_xmit+0x0/0xa90
[   15.441641] 
[   15.441642] stack backtrace:
[   15.441644] Pid: 4373, comm: arping Not tainted 3.2.0-rc2-12727-gd69d22a-dirty #1261
[   15.441646] Call Trace:
[   15.441651]  [<c13bae42>] ? printk+0x18/0x1e
[   15.441656]  [<c107f1aa>] lockdep_rcu_suspicious+0xaa/0xc0
[   15.441658]  [<c130507a>] dev_queue_xmit+0x6ca/0xa90
[   15.441661]  [<c13049b0>] ? dev_hard_start_xmit+0x810/0x810
[   15.441665]  [<c131cb84>] ? eth_header+0x24/0xb0
[   15.441668]  [<c139c4f8>] packet_sendmsg+0x978/0x9d0
[   15.441671]  [<c131cb60>] ? eth_rebuild_header+0x80/0x80
[   15.441675]  [<c12f3173>] ? sock_update_netprioidx+0xa3/0x110
[   15.441678]  [<c12ee93e>] sock_sendmsg+0xce/0x100
[   15.441682]  [<c10e354e>] ? might_fault+0x2e/0x80
[   15.441684]  [<c10e354e>] ? might_fault+0x2e/0x80
[   15.441687]  [<c10e3594>] ? might_fault+0x74/0x80
[   15.441691]  [<c11ce55f>] ? _copy_from_user+0x3f/0x60
[   15.441693]  [<c12f03e2>] sys_sendto+0xb2/0xe0
[   15.441696]  [<c108288b>] ? lock_release_non_nested+0x8b/0x300
[   15.441699]  [<c10e354e>] ? might_fault+0x2e/0x80
[   15.441701]  [<c10e354e>] ? might_fault+0x2e/0x80
[   15.441704]  [<c12f0cd0>] sys_socketcall+0x1a0/0x280
[   15.441708]  [<c13bfc90>] sysenter_do_call+0x12/0x36

Signed-off-by: Eric Dumazet <eric.dumazet-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
CC: Neil Horman <nhorman-2XuSBdqkA4R54TAoqtyWWQ@public.gmane.org>
---
 net/core/dev.c |   11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/net/core/dev.c b/net/core/dev.c
index 91a5991..903fd9d 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -2473,10 +2473,15 @@ static inline int __dev_xmit_skb(struct sk_buff *skb, struct Qdisc *q,
 #if IS_ENABLED(CONFIG_NETPRIO_CGROUP)
 static void skb_update_prio(struct sk_buff *skb)
 {
-	struct netprio_map *map = rcu_dereference(skb->dev->priomap);
+	if (!skb->priority && skb->sk) {
+		struct netprio_map *map;
 
-	if ((!skb->priority) && (skb->sk) && map)
-		skb->priority = map->priomap[skb->sk->sk_cgrp_prioidx];
+		rcu_read_lock();
+		map = rcu_dereference(skb->dev->priomap);
+		if (map)
+			skb->priority = map->priomap[skb->sk->sk_cgrp_prioidx];
+		rcu_read_unlock();
+	}
 }
 #else
 #define skb_update_prio(skb)


--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

  reply	other threads:[~2011-11-29 23:24 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <alpine.WNT.2.00.1111291027320.1036@TSI>
     [not found] ` <1322589661.2596.2.camel@edumazet-laptop>
2011-11-29 20:43   ` RCU'ed dst_get_neighbour() Eric Dumazet
2011-11-29 20:47     ` Roland Dreier
     [not found]       ` <CAG4TOxNJfr3X1p358LBWdNQKdkw8KOSekcKpNu6K5_phPEiR4A-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2011-11-29 20:53         ` Eric Dumazet
2011-11-29 20:56           ` Roland Dreier
2011-11-29 21:00           ` Marc Aurele La France
2011-11-29 21:17             ` Eric Dumazet
2011-11-29 21:31               ` Eric Dumazet
2011-11-29 21:35                 ` Roland Dreier
     [not found]                   ` <CAL1RGDUcYJKBSCthTL1AFgpRvzjoaEpHjGFhratKP-98ufRKnw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2011-11-30  1:17                     ` Marc Aurele La France
2011-11-30  2:00                       ` Roland Dreier
2011-11-30  5:15                         ` Marc Aurele La France
2011-11-30  5:26                           ` Eric Dumazet
2011-11-30 12:16                             ` Marc Aurele La France
2011-11-29 22:32                 ` Marc Aurele La France
2011-11-29 22:42                   ` Eric Dumazet
2011-11-29 23:03                     ` Marc Aurele La France
2011-11-29 23:11                       ` Eric Dumazet
2011-11-29 23:24                         ` Eric Dumazet [this message]
2011-11-30 11:41                           ` [PATCH net-next] net: proper locking in skb_update_prio() Neil Horman
2011-11-29 23:24                         ` RCU'ed dst_get_neighbour() David Miller
     [not found]                           ` <20111129.182441.956675970003939556.davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org>
2011-11-29 23:25                             ` Eric Dumazet

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=1322609078.2596.53.camel@edumazet-laptop \
    --to=eric.dumazet-re5jqeeqqe8avxtiumwx3w@public.gmane.org \
    --cc=davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org \
    --cc=linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=nhorman-2XuSBdqkA4R54TAoqtyWWQ@public.gmane.org \
    --cc=roland-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
    --cc=tsi-yfeSBMgouQgsA/PxXw9srA@public.gmane.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