public inbox for netdev@vger.kernel.org 
 help / color / mirror / Atom feed
From: Daniel Borkmann <daniel@iogearbox•net>
To: Cong Wang <xiyou.wangcong@gmail•com>, netdev@vger•kernel.org
Cc: davem@davemloft•net, Jamal Hadi Salim <jhs@mojatatu•com>,
	Cong Wang <cwang@twopensource•com>
Subject: Re: [Patch net] act_pedit: check binding before calling tcf_hash_release()
Date: Fri, 31 Jul 2015 13:10:35 +0200	[thread overview]
Message-ID: <55BB57AB.5030003@iogearbox.net> (raw)
In-Reply-To: <1438301541-26192-2-git-send-email-xiyou.wangcong@gmail.com>

On 07/31/2015 02:12 AM, Cong Wang wrote:
> When we share an action within a filter, the bind refcnt
> should increase, therefore we should not call tcf_hash_release().
>
> Cc: Jamal Hadi Salim <jhs@mojatatu•com>
> Cc: Daniel Borkmann <daniel@iogearbox•net>
> Signed-off-by: Cong Wang <xiyou.wangcong@gmail•com>
> Signed-off-by: Cong Wang <cwang@twopensource•com>

Seems like this slipped in via commit 1a29321ed045. The ugly thing is that
this leads to a use-after-free.

# tc actions add action pedit munge offset 2 u16 at 0 0f0000000 22 set 11500
# tc actions show action pedit
   action order 0:  pedit action pass keys 1
   index 1 ref 1 bind 0
   key #0  at 0: val 00002cec mask ffff0000
# tc filter add dev foo parent 1: bpf bytecode "$FOO" flowid 1:1 action pedit index 1
# tc filter show dev foo
   filter parent 1: protocol all pref 49152 bpf
   filter parent 1: protocol all pref 49152 bpf handle 0x1 flowid 1:1 bytecode '1,6 0 0 4294967295'
   action order 1: pedit action pass keys 1
   index 1 ref 1 bind 0
   key #0  at 0: val 00002cec mask ffff0000
# tc actions del action pedit index 1

.... and now you can wait for the next egress packet. ;)

Thanks for the fix Cong!

Fixes: 1a29321ed045 ("net_sched: act: Dont increment refcnt on replace")
Acked-by: Daniel Borkmann <daniel@iogearbox•net>

  reply	other threads:[~2015-07-31 11:10 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-31  0:12 [Patch net] act_mirred: avoid calling tcf_hash_release() when binding Cong Wang
2015-07-31  0:12 ` [Patch net] act_pedit: check binding before calling tcf_hash_release() Cong Wang
2015-07-31 11:10   ` Daniel Borkmann [this message]
2015-07-31 22:23   ` David Miller
2015-07-31 10:06 ` [Patch net] act_mirred: avoid calling tcf_hash_release() when binding Daniel Borkmann
2015-07-31 22:25   ` Cong Wang
2015-07-31 22:33     ` Daniel Borkmann
2015-08-03 21: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=55BB57AB.5030003@iogearbox.net \
    --to=daniel@iogearbox$(echo .)net \
    --cc=cwang@twopensource$(echo .)com \
    --cc=davem@davemloft$(echo .)net \
    --cc=jhs@mojatatu$(echo .)com \
    --cc=netdev@vger$(echo .)kernel.org \
    --cc=xiyou.wangcong@gmail$(echo .)com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
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