Skip to content
This repository has been archived by the owner on Dec 20, 2023. It is now read-only.

Commit

Permalink
net_sched: fix struct tc_u_hnode layout in u32
Browse files Browse the repository at this point in the history
[ Upstream commit 5778d39 ]

We dynamically allocate divisor+1 entries for ->ht[] in tc_u_hnode:

  ht = kzalloc(sizeof(*ht) + divisor*sizeof(void *), GFP_KERNEL);

So ->ht is supposed to be the last field of this struct, however
this is broken, since an rcu head is appended after it.

Fixes: 1ce8772 ("net: sched: make cls_u32 lockless")
Cc: Jamal Hadi Salim <[email protected]>
Cc: John Fastabend <[email protected]>
Signed-off-by: Cong Wang <[email protected]>
Acked-by: Eric Dumazet <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
Signed-off-by: Sasha Levin <[email protected]>
  • Loading branch information
congwang authored and sashalevin committed Mar 24, 2015
1 parent 6226858 commit 06e0dd7
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion net/sched/cls_u32.c
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,11 @@ struct tc_u_hnode {
struct tc_u_common *tp_c;
int refcnt;
unsigned int divisor;
struct tc_u_knode __rcu *ht[1];
struct rcu_head rcu;
/* The 'ht' field MUST be the last field in structure to allow for
* more entries allocated at end of structure.
*/
struct tc_u_knode __rcu *ht[1];
};

struct tc_u_common {
Expand Down

0 comments on commit 06e0dd7

Please sign in to comment.