diff mbox

net: flow: Guard against accessing non-existent attributes

Message ID 1419819455-19109-1-git-send-email-simon.horman@netronome.com
State Awaiting Upstream, archived
Delegated to: David Miller
Headers show

Commit Message

Simon Horman Dec. 29, 2014, 2:17 a.m. UTC
Signed-off-by: Simon Horman <simon.horman@netronome.com>
---
 net/core/flow_table.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

Comments

John Fastabend Dec. 29, 2014, 5:53 p.m. UTC | #1
On 12/28/2014 06:17 PM, Simon Horman wrote:
> Signed-off-by: Simon Horman <simon.horman@netronome.com>
> ---
>   net/core/flow_table.c | 11 +++++++++++
>   1 file changed, 11 insertions(+)

Great thanks. I rolled it into the patches I should hopefully have
ready to submit later today.

By the way I got this working on rocker now so we can test it easier,
I'll post the driver updates as well.

.John
Simon Horman Jan. 5, 2015, 2:04 a.m. UTC | #2
On Mon, Dec 29, 2014 at 09:53:30AM -0800, John Fastabend wrote:
> On 12/28/2014 06:17 PM, Simon Horman wrote:
> >Signed-off-by: Simon Horman <simon.horman@netronome.com>
> >---
> >  net/core/flow_table.c | 11 +++++++++++
> >  1 file changed, 11 insertions(+)
> 
> Great thanks. I rolled it into the patches I should hopefully have
> ready to submit later today.
> 
> By the way I got this working on rocker now so we can test it easier,
> I'll post the driver updates as well.

Great, excellent news.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

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])