public inbox for kernel-janitors@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] net: sched: fix a use-after-free error on chain on the error exit path
@ 2017-05-18 14:07 Colin King
  2017-05-18 15:31 ` David Miller
  2017-05-19 17:17 ` Cong Wang
  0 siblings, 2 replies; 4+ messages in thread
From: Colin King @ 2017-05-18 14:07 UTC (permalink / raw)
  To: Jamal Hadi Salim, Cong Wang, Jiri Pirko, David S . Miller, netdev
  Cc: kernel-janitors, linux-kernel

From: Colin Ian King <colin.king@canonical.com>

Set chain to null after the call to tcf_chain_destroy so that we don't
call tcf_chain_put on the error exit path, thus avoiding a use-after-free
error.

Detected by CoverityScan, CID#1436357 ("Use after free")

Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 net/sched/cls_api.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/net/sched/cls_api.c b/net/sched/cls_api.c
index 4020b8d932a1..82ebdc3fcb2e 100644
--- a/net/sched/cls_api.c
+++ b/net/sched/cls_api.c
@@ -511,6 +511,7 @@ static int tc_ctl_tfilter(struct sk_buff *skb, struct nlmsghdr *n,
 	if (n->nlmsg_type = RTM_DELTFILTER && prio = 0) {
 		tfilter_notify_chain(net, skb, n, chain, RTM_DELTFILTER);
 		tcf_chain_destroy(chain);
+		chain = NULL;
 		err = 0;
 		goto errout;
 	}
-- 
2.11.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] net: sched: fix a use-after-free error on chain on the error exit path
  2017-05-18 14:07 [PATCH] net: sched: fix a use-after-free error on chain on the error exit path Colin King
@ 2017-05-18 15:31 ` David Miller
  2017-05-19 17:17 ` Cong Wang
  1 sibling, 0 replies; 4+ messages in thread
From: David Miller @ 2017-05-18 15:31 UTC (permalink / raw)
  To: colin.king
  Cc: jhs, xiyou.wangcong, jiri, netdev, kernel-janitors, linux-kernel

From: Colin King <colin.king@canonical.com>
Date: Thu, 18 May 2017 15:07:02 +0100

> From: Colin Ian King <colin.king@canonical.com>
> 
> Set chain to null after the call to tcf_chain_destroy so that we don't
> call tcf_chain_put on the error exit path, thus avoiding a use-after-free
> error.
> 
> Detected by CoverityScan, CID#1436357 ("Use after free")
> 
> Signed-off-by: Colin Ian King <colin.king@canonical.com>

Colin, you really need to make some adjustments to how you are submitting
these kinds of patches.

First of all, you must indicate the target tree in your Subject line
as "[PATCH net-next] " in this case.

Also, you need to add an appropriate Fixes: tag right before your
signoff.

Thank you.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] net: sched: fix a use-after-free error on chain on the error exit path
  2017-05-18 14:07 [PATCH] net: sched: fix a use-after-free error on chain on the error exit path Colin King
  2017-05-18 15:31 ` David Miller
@ 2017-05-19 17:17 ` Cong Wang
  2017-05-20  7:13   ` Jiri Pirko
  1 sibling, 1 reply; 4+ messages in thread
From: Cong Wang @ 2017-05-19 17:17 UTC (permalink / raw)
  To: Colin King
  Cc: Jamal Hadi Salim, Jiri Pirko, David S . Miller,
	Linux Kernel Network Developers, kernel-janitors, LKML

On Thu, May 18, 2017 at 7:07 AM, Colin King <colin.king@canonical.com> wrote:
> diff --git a/net/sched/cls_api.c b/net/sched/cls_api.c
> index 4020b8d932a1..82ebdc3fcb2e 100644
> --- a/net/sched/cls_api.c
> +++ b/net/sched/cls_api.c
> @@ -511,6 +511,7 @@ static int tc_ctl_tfilter(struct sk_buff *skb, struct nlmsghdr *n,
>         if (n->nlmsg_type = RTM_DELTFILTER && prio = 0) {
>                 tfilter_notify_chain(net, skb, n, chain, RTM_DELTFILTER);
>                 tcf_chain_destroy(chain);


Jiri, how does this work...? An action could hold a refcnt to a filter
chain, but here you destroy a whole chain without respecting
the refcnt???


> +               chain = NULL;
>                 err = 0;
>                 goto errout;

Colin, not your fault, I think we may miss something more serious
when reviewing Jiri's patchset. ;)

Thanks.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] net: sched: fix a use-after-free error on chain on the error exit path
  2017-05-19 17:17 ` Cong Wang
@ 2017-05-20  7:13   ` Jiri Pirko
  0 siblings, 0 replies; 4+ messages in thread
From: Jiri Pirko @ 2017-05-20  7:13 UTC (permalink / raw)
  To: Cong Wang
  Cc: Colin King, Jamal Hadi Salim, David S . Miller,
	Linux Kernel Network Developers, kernel-janitors, LKML

Fri, May 19, 2017 at 07:17:59PM CEST, xiyou.wangcong@gmail.com wrote:
>On Thu, May 18, 2017 at 7:07 AM, Colin King <colin.king@canonical.com> wrote:
>> diff --git a/net/sched/cls_api.c b/net/sched/cls_api.c
>> index 4020b8d932a1..82ebdc3fcb2e 100644
>> --- a/net/sched/cls_api.c
>> +++ b/net/sched/cls_api.c
>> @@ -511,6 +511,7 @@ static int tc_ctl_tfilter(struct sk_buff *skb, struct nlmsghdr *n,
>>         if (n->nlmsg_type = RTM_DELTFILTER && prio = 0) {
>>                 tfilter_notify_chain(net, skb, n, chain, RTM_DELTFILTER);
>>                 tcf_chain_destroy(chain);
>
>
>Jiri, how does this work...? An action could hold a refcnt to a filter
>chain, but here you destroy a whole chain without respecting
>the refcnt???

Correct. I missed this. Will fix, thanks.


>
>
>> +               chain = NULL;
>>                 err = 0;
>>                 goto errout;
>
>Colin, not your fault, I think we may miss something more serious
>when reviewing Jiri's patchset. ;)
>
>Thanks.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2017-05-20  7:13 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-05-18 14:07 [PATCH] net: sched: fix a use-after-free error on chain on the error exit path Colin King
2017-05-18 15:31 ` David Miller
2017-05-19 17:17 ` Cong Wang
2017-05-20  7:13   ` Jiri Pirko

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox