* [PATCH net 1/1] net sched actions: fix dumping which requires several messages to user space
@ 2018-03-26 18:58 Craig Dillabaugh
2018-03-27 11:26 ` Jamal Hadi Salim
2018-03-27 14:59 ` David Miller
0 siblings, 2 replies; 3+ messages in thread
From: Craig Dillabaugh @ 2018-03-26 18:58 UTC (permalink / raw)
To: davem; +Cc: netdev, kernel, jhs, xiyou.wangcong, jiri, Craig Dillabaugh
Fixes a bug in the tcf_dump_walker function that can cause some actions
to not be reported when dumping a large number of actions. This issue
became more aggrevated when cookies feature was added. In particular
this issue is manifest when large cookie values are assigned to the
actions and when enough actions are created that the resulting table
must be dumped in multiple batches.
The number of actions returned in each batch is limited by the total
number of actions and the memory buffer size. With small cookies
the numeric limit is reached before the buffer size limit, which avoids
the code path triggering this bug. When large cookies are used buffer
fills before the numeric limit, and the erroneous code path is hit.
For example after creating 32 csum actions with the cookie
aaaabbbbccccdddd
$ tc actions ls action csum
total acts 26
action order 0: csum (tcp) action continue
index 1 ref 1 bind 0
cookie aaaabbbbccccdddd
.....
action order 25: csum (tcp) action continue
index 26 ref 1 bind 0
cookie aaaabbbbccccdddd
total acts 6
action order 0: csum (tcp) action continue
index 28 ref 1 bind 0
cookie aaaabbbbccccdddd
......
action order 5: csum (tcp) action continue
index 32 ref 1 bind 0
cookie aaaabbbbccccdddd
Note that the action with index 27 is omitted from the report.
Fixes: 4b3550ef530c ("[NET_SCHED]: Use nla_nest_start/nla_nest_end")"
Signed-off-by: Craig Dillabaugh <cdillaba@mojatatu.com>
---
net/sched/act_api.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/net/sched/act_api.c b/net/sched/act_api.c
index eba6682..efc6bfb 100644
--- a/net/sched/act_api.c
+++ b/net/sched/act_api.c
@@ -135,8 +135,10 @@ static int tcf_dump_walker(struct tcf_idrinfo *idrinfo, struct sk_buff *skb,
continue;
nest = nla_nest_start(skb, n_i);
- if (!nest)
+ if (!nest) {
+ index--;
goto nla_put_failure;
+ }
err = tcf_action_dump_1(skb, p, 0, 0);
if (err < 0) {
index--;
--
1.9.1
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH net 1/1] net sched actions: fix dumping which requires several messages to user space
2018-03-26 18:58 [PATCH net 1/1] net sched actions: fix dumping which requires several messages to user space Craig Dillabaugh
@ 2018-03-27 11:26 ` Jamal Hadi Salim
2018-03-27 14:59 ` David Miller
1 sibling, 0 replies; 3+ messages in thread
From: Jamal Hadi Salim @ 2018-03-27 11:26 UTC (permalink / raw)
To: Craig Dillabaugh, davem; +Cc: netdev, kernel, xiyou.wangcong, jiri
On 18-03-26 02:58 PM, Craig Dillabaugh wrote:
> Fixes a bug in the tcf_dump_walker function that can cause some actions
> to not be reported when dumping a large number of actions. This issue
> became more aggrevated when cookies feature was added. In particular
> this issue is manifest when large cookie values are assigned to the
> actions and when enough actions are created that the resulting table
> must be dumped in multiple batches.
>
> The number of actions returned in each batch is limited by the total
> number of actions and the memory buffer size. With small cookies
> the numeric limit is reached before the buffer size limit, which avoids
> the code path triggering this bug. When large cookies are used buffer
> fills before the numeric limit, and the erroneous code path is hit.
>
> For example after creating 32 csum actions with the cookie
> aaaabbbbccccdddd
>
> $ tc actions ls action csum
> total acts 26
>
> action order 0: csum (tcp) action continue
> index 1 ref 1 bind 0
> cookie aaaabbbbccccdddd
>
> .....
>
> action order 25: csum (tcp) action continue
> index 26 ref 1 bind 0
> cookie aaaabbbbccccdddd
> total acts 6
>
> action order 0: csum (tcp) action continue
> index 28 ref 1 bind 0
> cookie aaaabbbbccccdddd
>
> ......
>
> action order 5: csum (tcp) action continue
> index 32 ref 1 bind 0
> cookie aaaabbbbccccdddd
>
> Note that the action with index 27 is omitted from the report.
>
> Fixes: 4b3550ef530c ("[NET_SCHED]: Use nla_nest_start/nla_nest_end")"
> Signed-off-by: Craig Dillabaugh <cdillaba@mojatatu.com>
Good catch.
Acked-by: Jamal Hadi Salim <jhs@mojatatu.com>
cheers,
jamal
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH net 1/1] net sched actions: fix dumping which requires several messages to user space
2018-03-26 18:58 [PATCH net 1/1] net sched actions: fix dumping which requires several messages to user space Craig Dillabaugh
2018-03-27 11:26 ` Jamal Hadi Salim
@ 2018-03-27 14:59 ` David Miller
1 sibling, 0 replies; 3+ messages in thread
From: David Miller @ 2018-03-27 14:59 UTC (permalink / raw)
To: cdillaba; +Cc: netdev, kernel, jhs, xiyou.wangcong, jiri
From: Craig Dillabaugh <cdillaba@mojatatu.com>
Date: Mon, 26 Mar 2018 14:58:32 -0400
> Fixes a bug in the tcf_dump_walker function that can cause some actions
> to not be reported when dumping a large number of actions. This issue
> became more aggrevated when cookies feature was added. In particular
> this issue is manifest when large cookie values are assigned to the
> actions and when enough actions are created that the resulting table
> must be dumped in multiple batches.
>
> The number of actions returned in each batch is limited by the total
> number of actions and the memory buffer size. With small cookies
> the numeric limit is reached before the buffer size limit, which avoids
> the code path triggering this bug. When large cookies are used buffer
> fills before the numeric limit, and the erroneous code path is hit.
>
> For example after creating 32 csum actions with the cookie
> aaaabbbbccccdddd
...
> Note that the action with index 27 is omitted from the report.
>
> Fixes: 4b3550ef530c ("[NET_SCHED]: Use nla_nest_start/nla_nest_end")"
> Signed-off-by: Craig Dillabaugh <cdillaba@mojatatu.com>
Applied and queued up for -stable.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2018-03-27 14:59 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-03-26 18:58 [PATCH net 1/1] net sched actions: fix dumping which requires several messages to user space Craig Dillabaugh
2018-03-27 11:26 ` Jamal Hadi Salim
2018-03-27 14:59 ` David Miller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox