public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] net: ipv6: xfrm6_state: remove VLA usage
@ 2018-03-09 12:21 Andreas Christoforou
  2018-03-09 12:35 ` Steffen Klassert
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Andreas Christoforou @ 2018-03-09 12:21 UTC (permalink / raw)
  To: keescook
  Cc: kernel-hardening, Andreas Christoforou, Steffen Klassert,
	Herbert Xu, David S. Miller, Alexey Kuznetsov, Hideaki YOSHIFUJI,
	netdev, linux-kernel

The kernel would like to have all stack VLA usage removed[1].

Signed-off-by: Andreas Christoforou <andreaschristofo@gmail.com>
---
 net/ipv6/xfrm6_state.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/net/ipv6/xfrm6_state.c b/net/ipv6/xfrm6_state.c
index b15075a..45c0d98 100644
--- a/net/ipv6/xfrm6_state.c
+++ b/net/ipv6/xfrm6_state.c
@@ -62,7 +62,12 @@ __xfrm6_sort(void **dst, void **src, int n, int (*cmp)(void *p), int maxclass)
 {
 	int i;
 	int class[XFRM_MAX_DEPTH];
-	int count[maxclass];
+	int *count;
+
+	count = kcalloc(maxclass + 1, sizeof(*count), GFP_KERNEL);
+
+	if (!count)
+		return -ENOMEM;
 
 	memset(count, 0, sizeof(count));
 
@@ -80,6 +85,7 @@ __xfrm6_sort(void **dst, void **src, int n, int (*cmp)(void *p), int maxclass)
 		src[i] = NULL;
 	}
 
+	kfree(count);
 	return 0;
 }
 
-- 
2.7.4

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

end of thread, other threads:[~2018-03-09 18:35 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-03-09 12:21 [PATCH] net: ipv6: xfrm6_state: remove VLA usage Andreas Christoforou
2018-03-09 12:35 ` Steffen Klassert
2018-03-09 12:49 ` Mathias Krause
2018-03-09 13:02   ` Steffen Klassert
2018-03-09 13:49     ` Andreas Christoforou
2018-03-09 18:35 ` Sergei Shtylyov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox