Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp1141028imm; Fri, 29 Jun 2018 12:07:04 -0700 (PDT) X-Google-Smtp-Source: AAOMgpeU7HmztkM4rGkcLw/+9M60wDmTMx8ELSTx3iUBmo9NUjExk4vEzu7SDE4z+bS49eTwVpL+ X-Received: by 2002:a63:7c18:: with SMTP id x24-v6mr1163691pgc.311.1530299224410; Fri, 29 Jun 2018 12:07:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530299224; cv=none; d=google.com; s=arc-20160816; b=DLuyZQ6LoHc0wTecPNCJcl9/3YfM5D5b3QW03AihfnI3cvtIOr+En0Hy+YuVFdxdMM 7Hg74qRyh4X3zXsqQGUOZmu7O9jATIMlcHVT/uYA3PwRqsATeTIVuTmFJsxzPCMR2J10 WlEFZCi9u5XGtARXWZj1SalPacG1Wf3iU60IPIFyRZRc6TeY0EtL367MCAe5L6Ab39J9 S9GfnKbqaZmSBvYsde9SDe9R5VL2rDJQhbU/ZeRXlXKhFXUg7ueYK3AyRvxVRSvV2DVH fvhOGKMQP0+PIU1SwyPD4Wl5CmyfjwSkuobHRUfQA91x0Kp3dpx6PI0HSsLQo7Oj+amU evvw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-disposition:mime-version :message-id:subject:cc:to:from:date:dkim-signature :arc-authentication-results; bh=HYF+SyGoIuhrWleA6Wu31rpb31Ax1tSkr+IFmINSfT8=; b=xu6Jy+VP3x3mOzQiKuZG9xT27ogqdzeH091SMYAsxLcp3E7BP04E1wO3xF7azGbZtm 1iOy99tr7vF8nFpNfUEyJ8fKQwZcPosBibvDExBM+NZmdRnPPaVmY4d86mBcZIh2Mm+G 29jE8xkJPJCqsLWar13yCcJqkd99rHFNIL2hpknnfjqpSPlBqBEp5pWE1XvS4BMAb3EG T7wGUx+MFRamfiLu/+kBd+oGO2xfVTw3D6tm8BW/On0zGOQVgpDCYiVVrwJmx9PcaoeT wvswwQ2Nw4oHFM8gsiJ7Y9nZGSY0mDnsrndhfXoj+kysOAI0ZF65UMx8lclsxJ94cyT2 UMQA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=Jd7r2+BP; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i6-v6si8392829pgv.328.2018.06.29.12.06.49; Fri, 29 Jun 2018 12:07:04 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=Jd7r2+BP; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965402AbeF2SxF (ORCPT + 99 others); Fri, 29 Jun 2018 14:53:05 -0400 Received: from mail-pf0-f195.google.com ([209.85.192.195]:33641 "EHLO mail-pf0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S935265AbeF2Sw5 (ORCPT ); Fri, 29 Jun 2018 14:52:57 -0400 Received: by mail-pf0-f195.google.com with SMTP id b17-v6so4617613pfi.0 for ; Fri, 29 Jun 2018 11:52:57 -0700 (PDT) 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=HYF+SyGoIuhrWleA6Wu31rpb31Ax1tSkr+IFmINSfT8=; b=Jd7r2+BPJbJunloyRpdsP2Csep72xfcFfLJcC6Sy0XdPm6SyThLQFlUCVjJ+SWNe79 PPD+vVR3kfSLz5RYE+lph7EKCoR944bkWBbT6w0vJScYI5S8ACfl52cHhtTChBovb09I SL8DbS9kXXRu7Mq3UbzdGiB7UkbQLWPk2oxcg= 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=HYF+SyGoIuhrWleA6Wu31rpb31Ax1tSkr+IFmINSfT8=; b=bXL3lckVl6Nww4gpH/xPgA70Tb+yUY9S3MM5TiubMq5+6kttQ3Gs2Bhbt5urqKMWr2 hx6a628/1OHCCRl39XwvUefaUU4nVU9Str3A3Q4pwHd6dGRDiWtl6qoYmT7ne4meU6ip Ebxa9+8pVu+sYKD6u5k7mXxl0jkaQWp7FgHawqGYzeEjZYNe4nHRIGp46MsJQiQmZCdf FS6PFIMN/XIrJ/Wglgeqe2vR6R/goUp/TcM+qQ651Xi597qwVNQ49odGHeY4WdPC404R vFSNGp+EnLq2YIK2l2r8dQ5m8PUIy/3B4MwTcq4C2NeqgJHNlMNmxsaPwqZEACeNzLBK gmxQ== X-Gm-Message-State: APt69E3E7PdkGn+55jR2GrM7FriCmrV2vKFIt1e5WFnzWKzLL1imB2dy 1qlhDCbx8ybE1KLUUlRHaOlwOQ== X-Received: by 2002:a65:61af:: with SMTP id i15-v6mr13770689pgv.349.1530298376720; Fri, 29 Jun 2018 11:52:56 -0700 (PDT) Received: from www.outflux.net (173-164-112-133-Oregon.hfc.comcastbusiness.net. [173.164.112.133]) by smtp.gmail.com with ESMTPSA id d15-v6sm22611861pfh.92.2018.06.29.11.52.55 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 29 Jun 2018 11:52:55 -0700 (PDT) Date: Fri, 29 Jun 2018 11:52:54 -0700 From: Kees Cook To: Benjamin Herrenschmidt Cc: Paul Mackerras , Michael Ellerman , Andrew Morton , Randy Dunlap , Tyrel Datwyler , Rob Herring , Ingo Molnar , linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org Subject: [PATCH] powerpc/msi: Remove VLA usage Message-ID: <20180629185254.GA37557@beast> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In the quest to remove all stack VLA usage from the kernel[1], this switches from an unchanging variable to a constant expression to eliminate the VLA generation. [1] https://lkml.kernel.org/r/CA+55aFzCG-zNmZwX4A2FQpadafLfEzK6CC=qPXydAacU1RqZWA@mail.gmail.com Cc: Benjamin Herrenschmidt Cc: Paul Mackerras Cc: Michael Ellerman Cc: Andrew Morton Cc: Randy Dunlap Cc: Tyrel Datwyler Cc: Rob Herring Cc: Ingo Molnar Cc: linuxppc-dev@lists.ozlabs.org Signed-off-by: Kees Cook --- arch/powerpc/sysdev/msi_bitmap.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/arch/powerpc/sysdev/msi_bitmap.c b/arch/powerpc/sysdev/msi_bitmap.c index 6243a7e537d0..e64a411d1a00 100644 --- a/arch/powerpc/sysdev/msi_bitmap.c +++ b/arch/powerpc/sysdev/msi_bitmap.c @@ -225,22 +225,23 @@ static void __init test_of_node(void) struct device_node of_node; struct property prop; struct msi_bitmap bmp; - int size = 256; - DECLARE_BITMAP(expected, size); +#define SIZE_EXPECTED 256 + DECLARE_BITMAP(expected, SIZE_EXPECTED); /* There should really be a struct device_node allocator */ memset(&of_node, 0, sizeof(of_node)); of_node_init(&of_node); of_node.full_name = node_name; - WARN_ON(msi_bitmap_alloc(&bmp, size, &of_node)); + WARN_ON(msi_bitmap_alloc(&bmp, SIZE_EXPECTED, &of_node)); /* No msi-available-ranges, so expect > 0 */ WARN_ON(msi_bitmap_reserve_dt_hwirqs(&bmp) <= 0); /* Should all still be free */ - WARN_ON(bitmap_find_free_region(bmp.bitmap, size, get_count_order(size))); - bitmap_release_region(bmp.bitmap, 0, get_count_order(size)); + WARN_ON(bitmap_find_free_region(bmp.bitmap, SIZE_EXPECTED, + get_count_order(SIZE_EXPECTED))); + bitmap_release_region(bmp.bitmap, 0, get_count_order(SIZE_EXPECTED)); /* Now create a fake msi-available-ranges property */ @@ -256,8 +257,8 @@ static void __init test_of_node(void) WARN_ON(msi_bitmap_reserve_dt_hwirqs(&bmp)); /* Check we got the expected result */ - WARN_ON(bitmap_parselist(expected_str, expected, size)); - WARN_ON(!bitmap_equal(expected, bmp.bitmap, size)); + WARN_ON(bitmap_parselist(expected_str, expected, SIZE_EXPECTED)); + WARN_ON(!bitmap_equal(expected, bmp.bitmap, SIZE_EXPECTED)); msi_bitmap_free(&bmp); kfree(bmp.bitmap); -- 2.17.1 -- Kees Cook Pixel Security