From patchwork Tue Apr 24 23:46:51 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kees Cook X-Patchwork-Id: 10361301 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 407846038F for ; Tue, 24 Apr 2018 23:48:29 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3110B28D62 for ; Tue, 24 Apr 2018 23:48:29 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 250CF28D89; Tue, 24 Apr 2018 23:48:29 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.3 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from mother.openwall.net (mother.openwall.net [195.42.179.200]) by mail.wl.linuxfoundation.org (Postfix) with SMTP id 58BEB28E8F for ; Tue, 24 Apr 2018 23:48:14 +0000 (UTC) Received: (qmail 22456 invoked by uid 550); 24 Apr 2018 23:47:06 -0000 Mailing-List: contact kernel-hardening-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Delivered-To: mailing list kernel-hardening@lists.openwall.com Received: (qmail 22361 invoked from network); 24 Apr 2018 23:47:05 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=date:from:to:cc:subject:message-id:mime-version:content-disposition; bh=rLqPTM14KUrVSYqU+/iO1vPmNuFVMIrEdGPtuePmyEw=; b=NQC9ygiutjnNDaWxNnA3aP5GXyaOaAHLe56fqWnIXoxTaRzqOQscn/AUN7IJ9wrNOf omdHG9Iz+oNZhiHtt+AS1A4la6c4IhrD5WGIWVLNXrewS54UpZr6PS+iS0MxEyrHpfQI Lixh4MCRz94isjMlCs+EcPtCVI1fppTlu1bgw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-disposition; bh=rLqPTM14KUrVSYqU+/iO1vPmNuFVMIrEdGPtuePmyEw=; b=oCj7hvfr/WebjUinYu/RYW0GBeoePhFxFE01wV5V4o0VZSLOrqd0F7zTaEURv3vHJi ZLrFwrYA641Vto9RvlsBq3dDviRU8I4f/szHNGRjkw+ju5BNAr2L5mFRJK34TomgZ0Rh amjJYEtAKAs/Wkr74Xg4xojMl/7SDTyONiuRBVu2rwKsYZuLg5v5O4Vf5XZpodESsapL glclcNorTuvdFBoDoxeiZ6Cmj6eYa0MCNVrWkvmjnCP9Jj8Dz/4oc32tBXLJ8iBpEVCd 5dJOnotkLiDvVSp0uV3i7Ewr59w8ggb/BhKqJZDdIp6hocJJJLkXfqKcKOkScZXzhNYv eHsA== X-Gm-Message-State: ALQs6tBqDU5UM8xAilV9bHD/0pPw6t7dNnGbP2HVNxy1iVP4muHaFoww UZ8Ff8vZ3nUkgo+iMiCONU49lg== X-Google-Smtp-Source: AIpwx49UjIOsh25Wz7t5FXHQT4kYVyLcWzUWgmt0ZedlAq+fkbPxGg/WsGIMy+/30rqRAf1Ib9A4vg== X-Received: by 2002:a17:902:2a43:: with SMTP id i61-v6mr27284651plb.54.1524613613799; Tue, 24 Apr 2018 16:46:53 -0700 (PDT) Date: Tue, 24 Apr 2018 16:46:51 -0700 From: Kees Cook To: Stefano Brivio Cc: Andreas Christoforou , kernel-hardening@lists.openwall.com, Steffen Klassert , Herbert Xu , "David S. Miller" , Alexey Kuznetsov , Hideaki YOSHIFUJI , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 ipsec-next] xfrm: remove VLA usage in __xfrm6_sort() Message-ID: <20180424234651.GA30225@beast> MIME-Version: 1.0 Content-Disposition: inline X-Virus-Scanned: ClamAV using ClamSMTP In the quest to remove all stack VLA usage removed from the kernel[1], just use XFRM_MAX_DEPTH as already done for the "class" array. In one case, it'll do this loop up to 5, the other caller up to 6. [1] https://lkml.org/lkml/2018/3/7/621 Co-developed-by: Andreas Christoforou Signed-off-by: Kees Cook --- v3: - adjust Subject and commit log (Steffen) - use "= { }" instead of memset() (Stefano) - reorder variables (Stefano) v2: - use XFRM_MAX_DEPTH for "count" array (Steffen and Mathias). --- net/ipv6/xfrm6_state.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/net/ipv6/xfrm6_state.c b/net/ipv6/xfrm6_state.c index 16f434791763..eeb44b64ae7f 100644 --- a/net/ipv6/xfrm6_state.c +++ b/net/ipv6/xfrm6_state.c @@ -60,9 +60,9 @@ xfrm6_init_temprop(struct xfrm_state *x, const struct xfrm_tmpl *tmpl, static int __xfrm6_sort(void **dst, void **src, int n, int (*cmp)(void *p), int maxclass) { - int i; + int count[XFRM_MAX_DEPTH] = { }; int class[XFRM_MAX_DEPTH]; - int count[maxclass]; + int i; memset(count, 0, sizeof(count));