From: Roman Mashak <mrv@mojatatu.com>
To: Davide Caratti <dcaratti@redhat.com>
Cc: Cong Wang <xiyou.wangcong@gmail.com>,
Manish Kurup <kurup.manish@gmail.com>,
Jiri Pirko <jiri@resnulli.us>,
"David S. Miller" <davem@davemloft.net>,
netdev@vger.kernel.org
Subject: Re: [PATCH net] net/sched: fix NULL dereference in the error path of tcf_vlan_init()
Date: Thu, 15 Mar 2018 10:28:24 -0400 [thread overview]
Message-ID: <851sglifav.fsf@mojatatu.com> (raw)
In-Reply-To: <1d301fb86becf863283ee1be107f17e837ef4255.1521122595.git.dcaratti@redhat.com> (Davide Caratti's message of "Thu, 15 Mar 2018 15:06:30 +0100")
Davide Caratti <dcaratti@redhat.com> writes:
> when the following command
>
> # tc actions replace action vlan pop index 100
>
> is run for the first time, and tcf_vlan_init() fails allocating struct
> tcf_vlan_params, tcf_vlan_cleanup() calls kfree_rcu(NULL, ...). This causes
> the following error:
>
[...]
> fix this in tcf_vlan_cleanup(), ensuring that kfree_rcu(p, ...) is called
> only when p is not NULL.
>
> Fixes: 4c5b9d9642c8 ("act_vlan: VLAN action rewrite to use RCU lock/unlock and update")
> Signed-off-by: Davide Caratti <dcaratti@redhat.com>
> ---
> net/sched/act_vlan.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/net/sched/act_vlan.c b/net/sched/act_vlan.c
> index e1a1b3f3983a..c2914e9a4a6f 100644
> --- a/net/sched/act_vlan.c
> +++ b/net/sched/act_vlan.c
> @@ -225,7 +225,8 @@ static void tcf_vlan_cleanup(struct tc_action *a)
> struct tcf_vlan_params *p;
>
> p = rcu_dereference_protected(v->vlan_p, 1);
> - kfree_rcu(p, rcu);
> + if (p)
> + kfree_rcu(p, rcu);
> }
>
> static int tcf_vlan_dump(struct sk_buff *skb, struct tc_action *a,
Good catch. I think you can propagate the fix on the other actions
->cleanup(), where private parameters structure may not be present at
cleanup time, e.g. csum, ife.
prev parent reply other threads:[~2018-03-15 14:28 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-03-15 14:06 [PATCH net] net/sched: fix NULL dereference in the error path of tcf_vlan_init() Davide Caratti
2018-03-15 14:21 ` Jiri Pirko
2018-03-15 14:29 ` Davide Caratti
2018-03-15 22:21 ` Davide Caratti
2018-03-15 14:28 ` Roman Mashak [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=851sglifav.fsf@mojatatu.com \
--to=mrv@mojatatu.com \
--cc=davem@davemloft.net \
--cc=dcaratti@redhat.com \
--cc=jiri@resnulli.us \
--cc=kurup.manish@gmail.com \
--cc=netdev@vger.kernel.org \
--cc=xiyou.wangcong@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).