* [PATCH net v2] net: sched: Fix one possible panic when no destroy callback
@ 2017-06-28 4:53 gfree.wind
2017-06-28 5:30 ` Eric Dumazet
2017-06-29 16:55 ` David Miller
0 siblings, 2 replies; 3+ messages in thread
From: gfree.wind @ 2017-06-28 4:53 UTC (permalink / raw)
To: jhs, xiyou.wangcong, jiri, davem, netdev; +Cc: Gao Feng
From: Gao Feng <gfree.wind@vip.163.com>
When qdisc fail to init, qdisc_create would invoke the destroy callback
to cleanup. But there is no check if the callback exists really. So it
would cause the panic if there is no real destroy callback like the qdisc
codel, fq, and so on.
Take codel as an example following:
When a malicious user constructs one invalid netlink msg, it would cause
codel_init->codel_change->nla_parse_nested failed.
Then kernel would invoke the destroy callback directly but qdisc codel
doesn't define one. It causes one panic as a result.
Now add one the check for destroy to avoid the possible panic.
Fixes: 87b60cfacf9f ("net_sched: fix error recovery at qdisc creation")
Signed-off-by: Gao Feng <gfree.wind@vip.163.com>
---
v2: Add the Fixes and an example in changelog, Per Cong Wang & Eric
v1: initial version
net/sched/sch_api.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/net/sched/sch_api.c b/net/sched/sch_api.c
index e88342f..cfdbfa1 100644
--- a/net/sched/sch_api.c
+++ b/net/sched/sch_api.c
@@ -1019,7 +1019,8 @@ static struct Qdisc *qdisc_create(struct net_device *dev,
return sch;
}
/* ops->init() failed, we call ->destroy() like qdisc_create_dflt() */
- ops->destroy(sch);
+ if (ops->destroy)
+ ops->destroy(sch);
err_out3:
dev_put(dev);
kfree((char *) sch - sch->padded);
--
1.9.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH net v2] net: sched: Fix one possible panic when no destroy callback
2017-06-28 4:53 [PATCH net v2] net: sched: Fix one possible panic when no destroy callback gfree.wind
@ 2017-06-28 5:30 ` Eric Dumazet
2017-06-29 16:55 ` David Miller
1 sibling, 0 replies; 3+ messages in thread
From: Eric Dumazet @ 2017-06-28 5:30 UTC (permalink / raw)
To: gfree.wind; +Cc: jhs, xiyou.wangcong, jiri, davem, netdev
On Wed, 2017-06-28 at 12:53 +0800, gfree.wind@vip.163.com wrote:
> From: Gao Feng <gfree.wind@vip.163.com>
>
> When qdisc fail to init, qdisc_create would invoke the destroy callback
> to cleanup. But there is no check if the callback exists really. So it
> would cause the panic if there is no real destroy callback like the qdisc
> codel, fq, and so on.
>
> Take codel as an example following:
> When a malicious user constructs one invalid netlink msg, it would cause
> codel_init->codel_change->nla_parse_nested failed.
> Then kernel would invoke the destroy callback directly but qdisc codel
> doesn't define one. It causes one panic as a result.
>
> Now add one the check for destroy to avoid the possible panic.
>
> Fixes: 87b60cfacf9f ("net_sched: fix error recovery at qdisc creation")
> Signed-off-by: Gao Feng <gfree.wind@vip.163.com>
> ---
Acked-by: Eric Dumazet <edumazet@google.com>
Thanks !
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH net v2] net: sched: Fix one possible panic when no destroy callback
2017-06-28 4:53 [PATCH net v2] net: sched: Fix one possible panic when no destroy callback gfree.wind
2017-06-28 5:30 ` Eric Dumazet
@ 2017-06-29 16:55 ` David Miller
1 sibling, 0 replies; 3+ messages in thread
From: David Miller @ 2017-06-29 16:55 UTC (permalink / raw)
To: gfree.wind; +Cc: jhs, xiyou.wangcong, jiri, netdev
From: gfree.wind@vip.163.com
Date: Wed, 28 Jun 2017 12:53:54 +0800
> From: Gao Feng <gfree.wind@vip.163.com>
>
> When qdisc fail to init, qdisc_create would invoke the destroy callback
> to cleanup. But there is no check if the callback exists really. So it
> would cause the panic if there is no real destroy callback like the qdisc
> codel, fq, and so on.
>
> Take codel as an example following:
> When a malicious user constructs one invalid netlink msg, it would cause
> codel_init->codel_change->nla_parse_nested failed.
> Then kernel would invoke the destroy callback directly but qdisc codel
> doesn't define one. It causes one panic as a result.
>
> Now add one the check for destroy to avoid the possible panic.
>
> Fixes: 87b60cfacf9f ("net_sched: fix error recovery at qdisc creation")
> Signed-off-by: Gao Feng <gfree.wind@vip.163.com>
Applied and queued up for -stable.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2017-06-29 16:55 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-06-28 4:53 [PATCH net v2] net: sched: Fix one possible panic when no destroy callback gfree.wind
2017-06-28 5:30 ` Eric Dumazet
2017-06-29 16:55 ` David Miller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox