Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

net_sched: qdisc_get_rtab() must check data[] array

qdisc_get_rtab() should check not only the keys in struct tc_ratespec,
but also the full data[] array.

"tc ... linklayer atm " only perturbs values in the 256 slots array.

Signed-off-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Eric Dumazet and committed by
David S. Miller
40edeff6 1612e111

+6 -5
+6 -5
net/sched/sch_api.c
··· 291 291 { 292 292 struct qdisc_rate_table *rtab; 293 293 294 + if (tab == NULL || r->rate == 0 || r->cell_log == 0 || 295 + nla_len(tab) != TC_RTAB_SIZE) 296 + return NULL; 297 + 294 298 for (rtab = qdisc_rtab_list; rtab; rtab = rtab->next) { 295 - if (memcmp(&rtab->rate, r, sizeof(struct tc_ratespec)) == 0) { 299 + if (!memcmp(&rtab->rate, r, sizeof(struct tc_ratespec)) && 300 + !memcmp(&rtab->data, nla_data(tab), 1024)) { 296 301 rtab->refcnt++; 297 302 return rtab; 298 303 } 299 304 } 300 - 301 - if (tab == NULL || r->rate == 0 || r->cell_log == 0 || 302 - nla_len(tab) != TC_RTAB_SIZE) 303 - return NULL; 304 305 305 306 rtab = kmalloc(sizeof(*rtab), GFP_KERNEL); 306 307 if (rtab) {