netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Davide Caratti <dcaratti@redhat.com>
To: Cong Wang <xiyou.wangcong@gmail.com>,
	Jiri Pirko <jiri@resnulli.us>,
	Jamal Hadi Salim <jhs@mojatatu.com>,
	"David S. Miller" <davem@davemloft.net>
Cc: netdev@vger.kernel.org
Subject: [PATCH net v2 1/7] net/sched: fix idr leak on the error path of tcf_bpf_init()
Date: Mon, 19 Mar 2018 15:31:22 +0100	[thread overview]
Message-ID: <e502026d380fb06c3e020bdaa2bcbb0ebfc74d62.1521465261.git.dcaratti@redhat.com> (raw)
In-Reply-To: <cover.1521465261.git.dcaratti@redhat.com>

when the following command sequence is entered

 # tc action add action bpf bytecode '4,40 0 0 12,31 0 1 2048,6 0 0 262144,6 0 0 0' index 100
 RTNETLINK answers: Invalid argument
 We have an error talking to the kernel
 # tc action add action bpf bytecode '4,40 0 0 12,21 0 1 2048,6 0 0 262144,6 0 0 0' index 100
 RTNETLINK answers: No space left on device
 We have an error talking to the kernel

act_bpf correctly refuses to install the first TC rule, because 31 is not
a valid instruction. However, it refuses to install the second TC rule,
even if the BPF code is correct. Furthermore, it's no more possible to
install any other rule having the same value of 'index' until act_bpf
module is unloaded/inserted again. After the idr has been reserved, call
tcf_idr_release() instead of tcf_idr_cleanup(), to fix this issue.

Fixes: 65a206c01e8e ("net/sched: Change act_api and act_xxx modules to use IDR")
Acked-by: Jamal Hadi Salim <jhs@mojatatu.com>
Signed-off-by: Davide Caratti <dcaratti@redhat.com>
---
 net/sched/act_bpf.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/sched/act_bpf.c b/net/sched/act_bpf.c
index b3f2c15affa7..9d2cabf1dc7e 100644
--- a/net/sched/act_bpf.c
+++ b/net/sched/act_bpf.c
@@ -352,7 +352,7 @@ static int tcf_bpf_init(struct net *net, struct nlattr *nla,
 	return res;
 out:
 	if (res == ACT_P_CREATED)
-		tcf_idr_cleanup(*act, est);
+		tcf_idr_release(*act, bind);
 
 	return ret;
 }
-- 
2.14.3

  reply	other threads:[~2018-03-19 15:10 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-19 14:31 [PATCH net v2 0/7] fix idr leak in actions Davide Caratti
2018-03-19 14:31 ` Davide Caratti [this message]
2018-03-19 14:31 ` [PATCH net v2 2/7] net/sched: fix idr leak in the error path of tcf_simp_init() Davide Caratti
2018-03-19 14:31 ` [PATCH net v2 3/7] net/sched: fix idr leak in the error path of tcf_act_police_init() Davide Caratti
2018-03-19 14:31 ` [PATCH net v2 4/7] net/sched: fix idr leak in the error path of tcp_pedit_init() Davide Caratti
2018-03-19 14:31 ` [PATCH net v2 5/7] net/sched: fix idr leak in the error path of __tcf_ipt_init() Davide Caratti
2018-03-19 14:31 ` [PATCH net v2 6/7] net/sched: fix idr leak in the error path of tcf_vlan_init() Davide Caratti
2018-03-19 14:31 ` [PATCH net v2 7/7] net/sched: fix idr leak in the error path of tcf_skbmod_init() Davide Caratti
2018-03-20 17:23 ` [PATCH net v2 0/7] fix idr leak in actions Cong Wang
2018-03-21 22:13 ` David Miller

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=e502026d380fb06c3e020bdaa2bcbb0ebfc74d62.1521465261.git.dcaratti@redhat.com \
    --to=dcaratti@redhat.com \
    --cc=davem@davemloft.net \
    --cc=jhs@mojatatu.com \
    --cc=jiri@resnulli.us \
    --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).