![]() |
|
Message-Id: <1520802724-17509-1-git-send-email-s.mesoraca16@gmail.com> Date: Sun, 11 Mar 2018 22:12:04 +0100 From: Salvatore Mesoraca <s.mesoraca16@...il.com> To: linux-kernel@...r.kernel.org Cc: kernel-hardening@...ts.openwall.com, netdev@...r.kernel.org, "David S. Miller" <davem@...emloft.net>, "Paul E. McKenney" <paulmck@...ux.vnet.ibm.com>, David Rientjes <rientjes@...gle.com>, Elena Reshetova <elena.reshetova@...el.com>, Hans Liljestrand <ishkamiel@...il.com>, Kees Cook <keescook@...omium.org>, Salvatore Mesoraca <s.mesoraca16@...il.com> Subject: [PATCH] net: llc: drop VLA in llc_sap_mcast() Avoid a VLA[1] by using a real constant expression instead of a variable. The compiler should be able to optimize the original code and avoid using an actual VLA. Anyway this change is useful because it will avoid a false positive with -Wvla, it might also help the compiler generating better code. [1] https://lkml.org/lkml/2018/3/7/621 Signed-off-by: Salvatore Mesoraca <s.mesoraca16@...il.com> --- net/llc/llc_sap.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/net/llc/llc_sap.c b/net/llc/llc_sap.c index d90928f..a7f7b8f 100644 --- a/net/llc/llc_sap.c +++ b/net/llc/llc_sap.c @@ -394,8 +394,9 @@ static void llc_sap_mcast(struct llc_sap *sap, const struct llc_addr *laddr, struct sk_buff *skb) { - int i = 0, count = 256 / sizeof(struct sock *); - struct sock *sk, *stack[count]; + int i = 0; + struct sock *sk; + struct sock *stack[256 / sizeof(struct sock *)]; struct llc_sock *llc; struct hlist_head *dev_hb = llc_sk_dev_hash(sap, skb->dev->ifindex); @@ -408,7 +409,7 @@ static void llc_sap_mcast(struct llc_sap *sap, continue; sock_hold(sk); - if (i < count) + if (i < ARRAY_SIZE(stack)) stack[i++] = sk; else { llc_do_mcast(sap, skb, stack, i); -- 1.9.1
Powered by blists - more mailing lists
Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.