From: Cong Wang <hidden> Date: 2015-03-10 00:03:47
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: 1ce87720d456 ("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 <redacted>
---
net/sched/cls_u32.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
@@ -78,8 +78,11 @@ struct tc_u_hnode {structtc_u_common*tp_c;intrefcnt;unsignedintdivisor;-structtc_u_knode__rcu*ht[1];structrcu_headrcu;+/* The 'ht' field MUST be the last field in structure to allow for+*moreentriesallocatedatendofstructure.+*/+structtc_u_knode__rcu*ht[1];};structtc_u_common{
From: Eric Dumazet <hidden> Date: 2015-03-10 00:13:15
On Mon, 2015-03-09 at 17:03 -0700, Cong Wang wrote:
quoted hunk
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: 1ce87720d456 ("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 <redacted>
---
net/sched/cls_u32.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
@@ -78,8 +78,11 @@ struct tc_u_hnode {structtc_u_common*tp_c;intrefcnt;unsignedintdivisor;-structtc_u_knode__rcu*ht[1];structrcu_headrcu;+/* The 'ht' field MUST be the last field in structure to allow for+*moreentriesallocatedatendofstructure.+*/+structtc_u_knode__rcu*ht[1];};
Good catch.
Definitely a call to make this a flexible array in net-next (ht[]), so
that compiler would have catch the bug.
Acked-by: Eric Dumazet <edumazet@google.com>
From: David Miller <davem@davemloft.net> Date: 2015-03-10 03:45:22
From: Cong Wang <redacted>
Date: Mon, 9 Mar 2015 17:03:40 -0700
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: 1ce87720d456 ("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 <redacted>