Skip to content

Commit 1c87733

Browse files
Eric Dumazetdavem330
authored andcommitted
net_ns: add __rcu annotations
add __rcu annotation to (struct net)->gen, and use rcu_dereference_protected() in net_assign_generic() Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 6e3f7fa commit 1c87733

2 files changed

Lines changed: 4 additions & 2 deletions

File tree

‎include/net/net_namespace.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ struct net {
8888
#ifdef CONFIG_WEXT_CORE
8989
struct sk_buff_head wext_nlevents;
9090
#endif
91-
struct net_generic *gen;
91+
struct net_generic __rcu *gen;
9292

9393
/* Note : following structs are cache line aligned */
9494
#ifdef CONFIG_XFRM

‎net/core/net_namespace.c‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,9 @@ static int net_assign_generic(struct net *net, int id, void *data)
4242
BUG_ON(!mutex_is_locked(&net_mutex));
4343
BUG_ON(id == 0);
4444

45-
ng = old_ng = net->gen;
45+
old_ng = rcu_dereference_protected(net->gen,
46+
lockdep_is_held(&net_mutex));
47+
ng = old_ng;
4648
if (old_ng->len >= id)
4749
goto assign;
4850

0 commit comments

Comments
 (0)