Skip to content

Commit 5778d39

Browse files
congwangdavem330
authored andcommitted
net_sched: fix struct tc_u_hnode layout in u32
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 <jhs@mojatatu.com> Cc: John Fastabend <john.fastabend@gmail.com> Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com> Acked-by: Eric Dumazet <edumazet@google.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent affb817 commit 5778d39

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

net/sched/cls_u32.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,11 @@ struct tc_u_hnode {
7878
struct tc_u_common *tp_c;
7979
int refcnt;
8080
unsigned int divisor;
81-
struct tc_u_knode __rcu *ht[1];
8281
struct rcu_head rcu;
82+
/* The 'ht' field MUST be the last field in structure to allow for
83+
* more entries allocated at end of structure.
84+
*/
85+
struct tc_u_knode __rcu *ht[1];
8386
};
8487

8588
struct tc_u_common {

0 commit comments

Comments
 (0)