netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Simon Horman <simon.horman@netronome.com>
To: John Fastabend <john.r.fastabend@intel.com>, netdev@vger.kernel.org
Cc: Simon Horman <simon.horman@netronome.com>
Subject: [PATCH] net: flow: Guard against accessing non-existent attributes
Date: Mon, 29 Dec 2014 11:17:35 +0900	[thread overview]
Message-ID: <1419819455-19109-1-git-send-email-simon.horman@netronome.com> (raw)

Signed-off-by: Simon Horman <simon.horman@netronome.com>
---
 net/core/flow_table.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/net/core/flow_table.c b/net/core/flow_table.c
index 5937fb7..df2adf6 100644
--- a/net/core/flow_table.c
+++ b/net/core/flow_table.c
@@ -480,6 +480,10 @@ static int net_flow_get_action(struct net_flow_action *a, struct nlattr *attr)
 	if (err < 0)
 		return err;
 
+	if (!act[NET_FLOW_ACTION_ATTR_UID] ||
+	    !act[NET_FLOW_ACTION_ATTR_SIGNATURE])
+		return -EINVAL;
+
 	a->uid = nla_get_u32(act[NET_FLOW_ACTION_ATTR_UID]);
 
 	nla_for_each_nested(args, act[NET_FLOW_ACTION_ATTR_SIGNATURE], rem)
@@ -513,6 +517,10 @@ static int net_flow_get_flow(struct net_flow_flow *flow, struct nlattr *attr)
 	if (err < 0)
 		return -EINVAL;
 
+	if (!f[NET_FLOW_ATTR_TABLE] || !f[NET_FLOW_ATTR_UID] ||
+	    !f[NET_FLOW_ATTR_PRIORITY])
+		return -EINVAL;
+
 	flow->table_id = nla_get_u32(f[NET_FLOW_ATTR_TABLE]);
 	flow->uid = nla_get_u32(f[NET_FLOW_ATTR_UID]);
 	flow->priority = nla_get_u32(f[NET_FLOW_ATTR_PRIORITY]);
@@ -1209,6 +1217,9 @@ static int net_flow_table_cmd_get_flows(struct sk_buff *skb,
 	if (err)
 		goto out;
 
+	if (!tb[NET_FLOW_TABLE_FLOWS_TABLE])
+		goto out;
+
 	table = nla_get_u32(tb[NET_FLOW_TABLE_FLOWS_TABLE]);
 
 	if (tb[NET_FLOW_TABLE_FLOWS_MINPRIO])
-- 
2.1.3

             reply	other threads:[~2014-12-29  2:17 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-12-29  2:17 Simon Horman [this message]
2014-12-29 17:53 ` [PATCH] net: flow: Guard against accessing non-existent attributes John Fastabend
2015-01-05  2:04   ` Simon Horman

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=1419819455-19109-1-git-send-email-simon.horman@netronome.com \
    --to=simon.horman@netronome.com \
    --cc=john.r.fastabend@intel.com \
    --cc=netdev@vger.kernel.org \
    /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).