netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next] net/sched: cls_flower: reduce fl_change stack size
@ 2017-01-19  9:45 Arnd Bergmann
  2017-01-19  9:55 ` Jiri Pirko
  2017-01-19 16:23 ` David Miller
  0 siblings, 2 replies; 3+ messages in thread
From: Arnd Bergmann @ 2017-01-19  9:45 UTC (permalink / raw)
  To: David S. Miller
  Cc: Arnd Bergmann, Jamal Hadi Salim, Jiri Pirko, Hadar Hen Zion,
	Amir Vadai, Paul Blakey, Or Gerlitz, Simon Horman, Roi Dayan,
	netdev, linux-kernel

The new ARP support has pushed the stack size over the edge on ARM,
as there are two large objects on the stack in this function (mask
and tb) and both have now grown a bit more:

net/sched/cls_flower.c: In function 'fl_change':
net/sched/cls_flower.c:928:1: error: the frame size of 1072 bytes is larger than 1024 bytes [-Werror=frame-larger-than=]

We can solve this by dynamically allocating one or both of them.
I first tried to do it just for the mask, but that only saved
152 bytes on ARM, while this version just does it for the 'tb'
array, bringing the stack size back down to 664 bytes.

Fixes: 99d31326cbe6 ("net/sched: cls_flower: Support matching on ARP")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 net/sched/cls_flower.c | 23 +++++++++++++++++------
 1 file changed, 17 insertions(+), 6 deletions(-)

diff --git a/net/sched/cls_flower.c b/net/sched/cls_flower.c
index 27934456d984..9e74b0fa4b89 100644
--- a/net/sched/cls_flower.c
+++ b/net/sched/cls_flower.c
@@ -832,23 +832,31 @@ static int fl_change(struct net *net, struct sk_buff *in_skb,
 	struct cls_fl_head *head = rtnl_dereference(tp->root);
 	struct cls_fl_filter *fold = (struct cls_fl_filter *) *arg;
 	struct cls_fl_filter *fnew;
-	struct nlattr *tb[TCA_FLOWER_MAX + 1];
+	struct nlattr **tb;
 	struct fl_flow_mask mask = {};
 	int err;
 
 	if (!tca[TCA_OPTIONS])
 		return -EINVAL;
 
+	tb = kcalloc(TCA_FLOWER_MAX + 1, sizeof(struct nlattr *), GFP_KERNEL);
+	if (!tb)
+		return -ENOBUFS;
+
 	err = nla_parse_nested(tb, TCA_FLOWER_MAX, tca[TCA_OPTIONS], fl_policy);
 	if (err < 0)
-		return err;
+		goto errout_tb;
 
-	if (fold && handle && fold->handle != handle)
-		return -EINVAL;
+	if (fold && handle && fold->handle != handle) {
+		err = -EINVAL;
+		goto errout_tb;
+	}
 
 	fnew = kzalloc(sizeof(*fnew), GFP_KERNEL);
-	if (!fnew)
-		return -ENOBUFS;
+	if (!fnew) {
+		err = -ENOBUFS;
+		goto errout_tb;
+	}
 
 	err = tcf_exts_init(&fnew->exts, TCA_FLOWER_ACT, 0);
 	if (err < 0)
@@ -919,11 +927,14 @@ static int fl_change(struct net *net, struct sk_buff *in_skb,
 		list_add_tail_rcu(&fnew->list, &head->filters);
 	}
 
+	kfree(tb);
 	return 0;
 
 errout:
 	tcf_exts_destroy(&fnew->exts);
 	kfree(fnew);
+errout_tb:
+	kfree(tb);
 	return err;
 }
 
-- 
2.9.0

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH net-next] net/sched: cls_flower: reduce fl_change stack size
  2017-01-19  9:45 [PATCH net-next] net/sched: cls_flower: reduce fl_change stack size Arnd Bergmann
@ 2017-01-19  9:55 ` Jiri Pirko
  2017-01-19 16:23 ` David Miller
  1 sibling, 0 replies; 3+ messages in thread
From: Jiri Pirko @ 2017-01-19  9:55 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: David S. Miller, Jamal Hadi Salim, Jiri Pirko, Hadar Hen Zion,
	Amir Vadai, Paul Blakey, Or Gerlitz, Simon Horman, Roi Dayan,
	netdev, linux-kernel

Thu, Jan 19, 2017 at 10:45:31AM CET, arnd@arndb.de wrote:
>The new ARP support has pushed the stack size over the edge on ARM,
>as there are two large objects on the stack in this function (mask
>and tb) and both have now grown a bit more:
>
>net/sched/cls_flower.c: In function 'fl_change':
>net/sched/cls_flower.c:928:1: error: the frame size of 1072 bytes is larger than 1024 bytes [-Werror=frame-larger-than=]
>
>We can solve this by dynamically allocating one or both of them.
>I first tried to do it just for the mask, but that only saved
>152 bytes on ARM, while this version just does it for the 'tb'
>array, bringing the stack size back down to 664 bytes.
>
>Fixes: 99d31326cbe6 ("net/sched: cls_flower: Support matching on ARP")
>Signed-off-by: Arnd Bergmann <arnd@arndb.de>

Acked-by: Jiri Pirko <jiri@mellanox.com>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH net-next] net/sched: cls_flower: reduce fl_change stack size
  2017-01-19  9:45 [PATCH net-next] net/sched: cls_flower: reduce fl_change stack size Arnd Bergmann
  2017-01-19  9:55 ` Jiri Pirko
@ 2017-01-19 16:23 ` David Miller
  1 sibling, 0 replies; 3+ messages in thread
From: David Miller @ 2017-01-19 16:23 UTC (permalink / raw)
  To: arnd
  Cc: jhs, jiri, hadarh, amir, paulb, ogerlitz, simon.horman, roid,
	netdev, linux-kernel

From: Arnd Bergmann <arnd@arndb.de>
Date: Thu, 19 Jan 2017 10:45:31 +0100

> The new ARP support has pushed the stack size over the edge on ARM,
> as there are two large objects on the stack in this function (mask
> and tb) and both have now grown a bit more:
> 
> net/sched/cls_flower.c: In function 'fl_change':
> net/sched/cls_flower.c:928:1: error: the frame size of 1072 bytes is larger than 1024 bytes [-Werror=frame-larger-than=]
> 
> We can solve this by dynamically allocating one or both of them.
> I first tried to do it just for the mask, but that only saved
> 152 bytes on ARM, while this version just does it for the 'tb'
> array, bringing the stack size back down to 664 bytes.
> 
> Fixes: 99d31326cbe6 ("net/sched: cls_flower: Support matching on ARP")
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>

Applied.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2017-01-19 16:23 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-01-19  9:45 [PATCH net-next] net/sched: cls_flower: reduce fl_change stack size Arnd Bergmann
2017-01-19  9:55 ` Jiri Pirko
2017-01-19 16:23 ` David Miller

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