From patchwork Wed Apr 25 14:46:39 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kees Cook X-Patchwork-Id: 10363381 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 5317B6038F for ; Wed, 25 Apr 2018 14:46:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 43B3228518 for ; Wed, 25 Apr 2018 14:46:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3714C28AF1; Wed, 25 Apr 2018 14:46:57 +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 7593828518 for ; Wed, 25 Apr 2018 14:46:56 +0000 (UTC) Received: (qmail 25830 invoked by uid 550); 25 Apr 2018 14:46:54 -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 25803 invoked from network); 25 Apr 2018 14:46:54 -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=2tQsBi2Tvy9BONFoyp+Kg7ZktJ0b81Z5QNCojos7+ZM=; b=Iv0LWIpJ0oby74L/uohhFtfuoAqB4LIkO6/gbJ4h1yr/E9Vk7CL/oIVo3VIDFIJNxs EQGqNW/nHQh+x2yepCVZGQfS+2G95IH+XbHm3gNiBjz5nBirIftqqp0hCgF6jgk6S0g/ 6cYgG1DLAr9AdzeSS71fG12r3mKioliKCc+yc= 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=2tQsBi2Tvy9BONFoyp+Kg7ZktJ0b81Z5QNCojos7+ZM=; b=q3d6vGuRCVW3PaOuE4vd5AwZMzoXu6KzMHA9g8pREqAST97iv+W0FZwO51VOhx0qCu qD52+2IdGnBGjgM+t06ZYvRNVVwQ2bqI8yd04dpq6uwPCJWOG0c3EW8cl2XsK2j7WZNt OP/XZfMQlkgjFs5j/OEaKETgpzwBXXSINvktslqktpvbNp7dzDpxKseVsSU03dSmvBq7 sCPrfsDDJeiH5+igg2J1ghHKmxK+4Y1LN0Q6O1KYzRtHAFN7jar7JThSwY8o2gsVPAlq PdsmIgYd7IP8cI0PBhN4SJlp9EQRVbCU2X8i2ibo8cM26+fKuDB8TIZZCt6JV2raTGMh waOA== X-Gm-Message-State: ALQs6tBIjWr0w+F8jZLee9o4JsKZoIQb1vXcgaWez2blD71JaW8iefDt vsYP8oXL9ii/z2RqqlYQ+7Gpzg== X-Google-Smtp-Source: AIpwx4/tIBfZ7i/IgWIPu/WjaqHVpplQprfGRbFKZdPNdvse7AAGkN+AXZBi9kFmMmzfIGF6+hnYCw== X-Received: by 10.98.72.209 with SMTP id q78mr22822909pfi.70.1524667602141; Wed, 25 Apr 2018 07:46:42 -0700 (PDT) Date: Wed, 25 Apr 2018 07:46:39 -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 v4 ipsec-next] xfrm: remove VLA usage in __xfrm6_sort() Message-ID: <20180425144639.GA38350@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 Acked-by: Stefano Brivio --- v4: - actually remove memset(). :) v3: - adjust Subject and commit log (Steffen) - use "= { }" instead of memset() (Stefano) v2: - use XFRM_MAX_DEPTH for "count" array (Steffen and Mathias). --- net/ipv6/xfrm6_state.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/net/ipv6/xfrm6_state.c b/net/ipv6/xfrm6_state.c index 16f434791763..5bdca3d5d6b7 100644 --- a/net/ipv6/xfrm6_state.c +++ b/net/ipv6/xfrm6_state.c @@ -60,11 +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]; - - memset(count, 0, sizeof(count)); + int i; for (i = 0; i < n; i++) { int c;