linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] net: sched: sch_taprio: fix memleak in error path for sched list parse
@ 2019-08-06 10:04 Ivan Khoronzhuk
  2019-08-06 16:21 ` Vinicius Costa Gomes
  2019-08-06 18:41 ` David Miller
  0 siblings, 2 replies; 4+ messages in thread
From: Ivan Khoronzhuk @ 2019-08-06 10:04 UTC (permalink / raw)
  To: vinicius.gomes, davem
  Cc: jhs, xiyou.wangcong, jiri, netdev, linux-kernel, Ivan Khoronzhuk

In case off error, all entries should be freed from the sched list
before deleting it. For simplicity use rcu way.

Fixes: 5a781ccbd19e46 ("tc: Add support for configuring the taprio scheduler")
Signed-off-by: Ivan Khoronzhuk <ivan.khoronzhuk@linaro.org>
---

Based on net/master

 net/sched/sch_taprio.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/net/sched/sch_taprio.c b/net/sched/sch_taprio.c
index b55a82c1e1bc..4f6333035841 100644
--- a/net/sched/sch_taprio.c
+++ b/net/sched/sch_taprio.c
@@ -1451,7 +1451,8 @@ static int taprio_change(struct Qdisc *sch, struct nlattr *opt,
 	spin_unlock_bh(qdisc_lock(sch));
 
 free_sched:
-	kfree(new_admin);
+	if (new_admin)
+		call_rcu(&new_admin->rcu, taprio_free_sched_cb);
 
 	return err;
 }
-- 
2.17.1


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

* Re: [PATCH] net: sched: sch_taprio: fix memleak in error path for sched list parse
  2019-08-06 10:04 [PATCH] net: sched: sch_taprio: fix memleak in error path for sched list parse Ivan Khoronzhuk
@ 2019-08-06 16:21 ` Vinicius Costa Gomes
  2019-08-06 18:41 ` David Miller
  1 sibling, 0 replies; 4+ messages in thread
From: Vinicius Costa Gomes @ 2019-08-06 16:21 UTC (permalink / raw)
  To: Ivan Khoronzhuk, davem
  Cc: jhs, xiyou.wangcong, jiri, netdev, linux-kernel, Ivan Khoronzhuk

Ivan Khoronzhuk <ivan.khoronzhuk@linaro.org> writes:

> In case off error, all entries should be freed from the sched list
> before deleting it. For simplicity use rcu way.
>
> Fixes: 5a781ccbd19e46 ("tc: Add support for configuring the taprio scheduler")
> Signed-off-by: Ivan Khoronzhuk <ivan.khoronzhuk@linaro.org>
> ---

Acked-by: Vinicius Costa Gomes <vinicius.gomes@intel.com>



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

* Re: [PATCH] net: sched: sch_taprio: fix memleak in error path for sched list parse
  2019-08-06 10:04 [PATCH] net: sched: sch_taprio: fix memleak in error path for sched list parse Ivan Khoronzhuk
  2019-08-06 16:21 ` Vinicius Costa Gomes
@ 2019-08-06 18:41 ` David Miller
  2019-08-06 22:42   ` Ivan Khoronzhuk
  1 sibling, 1 reply; 4+ messages in thread
From: David Miller @ 2019-08-06 18:41 UTC (permalink / raw)
  To: ivan.khoronzhuk
  Cc: vinicius.gomes, jhs, xiyou.wangcong, jiri, netdev, linux-kernel

From: Ivan Khoronzhuk <ivan.khoronzhuk@linaro.org>
Date: Tue,  6 Aug 2019 13:04:25 +0300

> Based on net/master

I wonder about that because:

> --- a/net/sched/sch_taprio.c
> +++ b/net/sched/sch_taprio.c
> @@ -1451,7 +1451,8 @@ static int taprio_change(struct Qdisc *sch, struct nlattr *opt,
>  	spin_unlock_bh(qdisc_lock(sch));
>  
>  free_sched:
> -	kfree(new_admin);
> +	if (new_admin)
> +		call_rcu(&new_admin->rcu, taprio_free_sched_cb);
>  
>  	return err;

In my tree the context around line 1451 is:

	nla_nest_end(skb, sched_nest);

done:
	rcu_read_unlock();

	return nla_nest_end(skb, nest);


which is part of function taprio_dump().

Please respin this properly against current 'net' sources.

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

* Re: [PATCH] net: sched: sch_taprio: fix memleak in error path for sched list parse
  2019-08-06 18:41 ` David Miller
@ 2019-08-06 22:42   ` Ivan Khoronzhuk
  0 siblings, 0 replies; 4+ messages in thread
From: Ivan Khoronzhuk @ 2019-08-06 22:42 UTC (permalink / raw)
  To: David Miller
  Cc: vinicius.gomes, jhs, xiyou.wangcong, jiri, netdev, linux-kernel

On Tue, Aug 06, 2019 at 11:41:14AM -0700, David Miller wrote:
>From: Ivan Khoronzhuk <ivan.khoronzhuk@linaro.org>
>Date: Tue,  6 Aug 2019 13:04:25 +0300
>
>> Based on net/master
>
>I wonder about that because:
Applies cleanly on net/master, but line num is not correct.
I've sent v2.

>
>> --- a/net/sched/sch_taprio.c
>> +++ b/net/sched/sch_taprio.c
>> @@ -1451,7 +1451,8 @@ static int taprio_change(struct Qdisc *sch, struct nlattr *opt,
>>  	spin_unlock_bh(qdisc_lock(sch));
>>
>>  free_sched:
>> -	kfree(new_admin);
>> +	if (new_admin)
>> +		call_rcu(&new_admin->rcu, taprio_free_sched_cb);
>>
>>  	return err;
>
>In my tree the context around line 1451 is:
>
>	nla_nest_end(skb, sched_nest);
>
>done:
>	rcu_read_unlock();
>
>	return nla_nest_end(skb, nest);
>
>
>which is part of function taprio_dump().
>
>Please respin this properly against current 'net' sources.

-- 
Regards,
Ivan Khoronzhuk

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

end of thread, other threads:[~2019-08-06 22:42 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-08-06 10:04 [PATCH] net: sched: sch_taprio: fix memleak in error path for sched list parse Ivan Khoronzhuk
2019-08-06 16:21 ` Vinicius Costa Gomes
2019-08-06 18:41 ` David Miller
2019-08-06 22:42   ` Ivan Khoronzhuk

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).