netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Florian Westphal <fw@strlen.de>
To: Paul Blakey <paulb@mellanox.com>
Cc: Jiri Pirko <jiri@mellanox.com>, Roi Dayan <roid@mellanox.com>,
	Yossi Kuperman <yossiku@mellanox.com>,
	Oz Shlomo <ozsh@mellanox.com>,
	Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>,
	netdev@vger.kernel.org, David Miller <davem@davemloft.net>,
	Aaron Conole <aconole@redhat.com>, Zhike Wang <wangzhike@jd.com>,
	Rony Efraim <ronye@mellanox.com>,
	nst-kernel@redhat.com, John Hurley <john.hurley@netronome.com>,
	Simon Horman <simon.horman@netronome.com>,
	Justin Pettit <jpettit@ovn.org>
Subject: Re: [PATCH net-next v4 1/4] net/sched: Introduce action ct
Date: Sun, 7 Jul 2019 14:04:55 +0200	[thread overview]
Message-ID: <20190707120455.6li4tfb5ppht4xy7@breakpoint.cc> (raw)
In-Reply-To: <1562486612-22770-2-git-send-email-paulb@mellanox.com>

Paul Blakey <paulb@mellanox.com> wrote:
> +/* Determine whether skb->_nfct is equal to the result of conntrack lookup. */
> +static bool tcf_ct_skb_nfct_cached(struct net *net, struct sk_buff *skb,
> +				   u16 zone_id, bool force)
> +{
> +	enum ip_conntrack_info ctinfo;
> +	struct nf_conn *ct;
> +
> +	ct = nf_ct_get(skb, &ctinfo);
> +	if (!ct)
> +		return false;
> +	if (!net_eq(net, read_pnet(&ct->ct_net)))
> +		return false;
> +	if (nf_ct_zone(ct)->id != zone_id)
> +		return false;
> +
> +	/* Force conntrack entry direction. */
> +	if (force && CTINFO2DIR(ctinfo) != IP_CT_DIR_ORIGINAL) {
> +		nf_conntrack_put(&ct->ct_general);
> +		nf_ct_set(skb, NULL, IP_CT_UNTRACKED);
> +
> +		if (nf_ct_is_confirmed(ct))
> +			nf_ct_kill(ct);

This looks like a possible UAF:
nf_conntrack_put() may free the conntrack entry.

It seems better to do do:
	if (nf_ct_is_confirmed(ct))
		nf_ct_kill(ct);

	nf_conntrack_put(&ct->ct_general);
	nf_ct_set(skb, ...


  reply	other threads:[~2019-07-07 12:05 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-07  8:03 [PATCH net-next v4 0/4] net/sched: Introduce tc connection tracking Paul Blakey
2019-07-07  8:03 ` [PATCH net-next v4 1/4] net/sched: Introduce action ct Paul Blakey
2019-07-07 12:04   ` Florian Westphal [this message]
2019-07-08  7:07     ` Paul Blakey
2019-07-08 14:02       ` Florian Westphal
2019-07-07  8:03 ` [PATCH net-next v4 2/4] net/flow_dissector: add connection tracking dissection Paul Blakey
2019-07-07  8:03 ` [PATCH net-next v4 3/4] net/sched: cls_flower: Add matching on conntrack info Paul Blakey
2019-07-07  8:03 ` [PATCH net-next v4 4/4] tc-tests: Add tc action ct tests Paul Blakey

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=20190707120455.6li4tfb5ppht4xy7@breakpoint.cc \
    --to=fw@strlen.de \
    --cc=aconole@redhat.com \
    --cc=davem@davemloft.net \
    --cc=jiri@mellanox.com \
    --cc=john.hurley@netronome.com \
    --cc=jpettit@ovn.org \
    --cc=marcelo.leitner@gmail.com \
    --cc=netdev@vger.kernel.org \
    --cc=nst-kernel@redhat.com \
    --cc=ozsh@mellanox.com \
    --cc=paulb@mellanox.com \
    --cc=roid@mellanox.com \
    --cc=ronye@mellanox.com \
    --cc=simon.horman@netronome.com \
    --cc=wangzhike@jd.com \
    --cc=yossiku@mellanox.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).