Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1644580 > unrolled thread

[PATCH] net: sched: fix a use-after-free error on chain on the error exit path

Started byColin King <colin.king@canonical.com>
First post2017-05-18 16:10 +0200
Last post2017-05-20 09:20 +0200
Articles 4 — 4 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH] net: sched: fix a use-after-free error on chain on the error exit path Colin King <colin.king@canonical.com> - 2017-05-18 16:10 +0200
    Re: [PATCH] net: sched: fix a use-after-free error on chain on the  error exit path David Miller <davem@davemloft.net> - 2017-05-18 17:40 +0200
    Re: [PATCH] net: sched: fix a use-after-free error on chain on the  error exit path Cong Wang <xiyou.wangcong@gmail.com> - 2017-05-19 19:20 +0200
      Re: [PATCH] net: sched: fix a use-after-free error on chain on the  error exit path Jiri Pirko <jiri@resnulli.us> - 2017-05-20 09:20 +0200

#1644580 — [PATCH] net: sched: fix a use-after-free error on chain on the error exit path

FromColin King <colin.king@canonical.com>
Date2017-05-18 16:10 +0200
Subject[PATCH] net: sched: fix a use-after-free error on chain on the error exit path
Message-ID<tIuhQ-3NF-11@gated-at.bofh.it>
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

[toc] | [next] | [standalone]


#1644693 — Re: [PATCH] net: sched: fix a use-after-free error on chain on the error exit path

FromDavid Miller <davem@davemloft.net>
Date2017-05-18 17:40 +0200
SubjectRe: [PATCH] net: sched: fix a use-after-free error on chain on the error exit path
Message-ID<tIvGW-4Cy-9@gated-at.bofh.it>
In reply to#1644580
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.

[toc] | [prev] | [next] | [standalone]


#1645778 — Re: [PATCH] net: sched: fix a use-after-free error on chain on the error exit path

FromCong Wang <xiyou.wangcong@gmail.com>
Date2017-05-19 19:20 +0200
SubjectRe: [PATCH] net: sched: fix a use-after-free error on chain on the error exit path
Message-ID<tITJf-5fr-3@gated-at.bofh.it>
In reply to#1644580
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.

[toc] | [prev] | [next] | [standalone]


#1646074 — Re: [PATCH] net: sched: fix a use-after-free error on chain on the error exit path

FromJiri Pirko <jiri@resnulli.us>
Date2017-05-20 09:20 +0200
SubjectRe: [PATCH] net: sched: fix a use-after-free error on chain on the error exit path
Message-ID<tJ6Q9-6jt-5@gated-at.bofh.it>
In reply to#1645778
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.

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web