mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Joe Stringer <joestringer@nicira.com>
To: netdev@vger.kernel.org, pshelar@nicira.com
Cc: linux-kernel@vger.kernel.org, jesse@nicira.com
Subject: [PATCHv2 5/7] openvswitch: Reject ct_state unsupported bits
Date: Thu,  1 Oct 2015 13:53:28 -0700	[thread overview]
Message-ID: <1443732810-38746-6-git-send-email-joestringer@nicira.com> (raw)
In-Reply-To: <1443732810-38746-1-git-send-email-joestringer@nicira.com>

Previously, if userspace specified ct_state bits in the flow key which
are currently undefined (and therefore unsupported), then they would be
ignored. This could cause unexpected behaviour in future if userspace is
extended to support additional bits but attempts to communicate with the
current version of the kernel. This patch rectifies the situation by
rejecting such ct_state bits.

Fixes: 7f8a436 "openvswitch: Add conntrack action"
Signed-off-by: Joe Stringer <joestringer@nicira.com>
Acked-by: Pravin B Shelar <pshelar@nicira.com>
---
v2: Acked.
---
 net/openvswitch/conntrack.h    | 12 ++++++++++++
 net/openvswitch/flow_netlink.c |  6 ++++++
 2 files changed, 18 insertions(+)

diff --git a/net/openvswitch/conntrack.h b/net/openvswitch/conntrack.h
index 43f5dd7..c658d95 100644
--- a/net/openvswitch/conntrack.h
+++ b/net/openvswitch/conntrack.h
@@ -34,6 +34,13 @@ int ovs_ct_execute(struct net *, struct sk_buff *, struct sw_flow_key *,
 void ovs_ct_fill_key(const struct sk_buff *skb, struct sw_flow_key *key);
 int ovs_ct_put_key(const struct sw_flow_key *key, struct sk_buff *skb);
 void ovs_ct_free_action(const struct nlattr *a);
+
+static inline bool ovs_ct_state_supported(u8 state)
+{
+	return !(state & ~(OVS_CS_F_NEW | OVS_CS_F_ESTABLISHED |
+			 OVS_CS_F_RELATED | OVS_CS_F_REPLY_DIR |
+			 OVS_CS_F_INVALID | OVS_CS_F_TRACKED));
+}
 #else
 #include <linux/errno.h>
 
@@ -46,6 +53,11 @@ static inline bool ovs_ct_verify(struct net *net, int attr)
 	return false;
 }
 
+static inline bool ovs_ct_state_supported(u8 state)
+{
+	return false;
+}
+
 static inline int ovs_ct_copy_action(struct net *net, const struct nlattr *nla,
 				     const struct sw_flow_key *key,
 				     struct sw_flow_actions **acts, bool log)
diff --git a/net/openvswitch/flow_netlink.c b/net/openvswitch/flow_netlink.c
index a60e3b7..d47b5c5 100644
--- a/net/openvswitch/flow_netlink.c
+++ b/net/openvswitch/flow_netlink.c
@@ -816,6 +816,12 @@ static int metadata_from_nlattrs(struct net *net, struct sw_flow_match *match,
 	    ovs_ct_verify(net, OVS_KEY_ATTR_CT_STATE)) {
 		u8 ct_state = nla_get_u8(a[OVS_KEY_ATTR_CT_STATE]);
 
+		if (!is_mask && !ovs_ct_state_supported(ct_state)) {
+			OVS_NLERR(log, "ct_state flags %02x unsupported",
+				  ct_state);
+			return -EINVAL;
+		}
+
 		SW_FLOW_KEY_PUT(match, ct.state, ct_state, is_mask);
 		*attrs &= ~(1ULL << OVS_KEY_ATTR_CT_STATE);
 	}
-- 
2.1.4


  parent reply	other threads:[~2015-10-01 20:53 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-10-01 20:53 [PATCHv2 0/7] OVS conntrack fixes for net Joe Stringer
2015-10-01 20:53 ` [PATCHv2 1/7] openvswitch: Rename LABEL->LABELS Joe Stringer
2015-10-01 21:13   ` kbuild test robot
2015-10-01 22:00     ` [PATCHv3] " Joe Stringer
2015-10-01 22:23       ` Pravin Shelar
2015-10-05 13:34       ` David Miller
2015-10-01 20:53 ` [PATCHv2 2/7] openvswitch: Fix typos in CT headers Joe Stringer
2015-10-01 20:53 ` [PATCHv2 3/7] openvswitch: Fix skb leak in ovs_fragment() Joe Stringer
2015-10-01 22:25   ` Pravin Shelar
2015-10-01 20:53 ` [PATCHv2 4/7] openvswitch: Ensure flow is valid before executing ct Joe Stringer
2015-10-01 20:53 ` Joe Stringer [this message]
2015-10-01 20:53 ` [PATCHv2 6/7] openvswitch: Extend ct_state match field to 32 bits Joe Stringer
2015-10-01 20:53 ` [PATCHv2 7/7] openvswitch: Change CT_ATTR_FLAGS to CT_ATTR_COMMIT Joe Stringer
2015-10-01 22:26   ` Pravin Shelar

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=1443732810-38746-6-git-send-email-joestringer@nicira.com \
    --to=joestringer@nicira.com \
    --cc=jesse@nicira.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pshelar@nicira.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

all inboxes | Powered by JetHome®