Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp3061189imm; Mon, 16 Jul 2018 20:57:46 -0700 (PDT) X-Google-Smtp-Source: AAOMgpduSZ4OiHRPx6mKNt0KLyFRMkH0FTqzCyqQTb5HVNcOfC64PM78VI+gWDYo59oLHmMqFi5q X-Received: by 2002:a62:ca0d:: with SMTP id n13-v6mr20499412pfg.69.1531799866476; Mon, 16 Jul 2018 20:57:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531799866; cv=none; d=google.com; s=arc-20160816; b=jrrRAmjFxnOfZoCGFVzMO8M+fs3/MjgiDM1yqjOsaPcAq9ce0UThBiPSPF4uTZr2y/ xlMAIHYXgnWZ7w2VukjJFvtxSm+MBt25KM16mRBWZgUgxo3jSux3LkzRtgcWpx1WLC5p jene9gK4RUjMmgb/K03bceG3eYUCTUetCaUvX2Eh60nPOUaKBFmiyNpkppO4QDDC1N7w ezDAd05N8PEQnBFd68wa5Lfsppq6dK3AdRyZRgN9AFZoDlUYKiFXd7dmVOu8qqgyhXNK zPgRjm+4Lw9QeLvxY/ThVE0oW9JcNsMBYLuQUpH/FlEAPvyouG0CXLoZILG0++k9n+Vd r05A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature:dkim-signature :arc-authentication-results; bh=gmh5bXsFrHKLy7iNW75AOlO+7QSQS0tyNvTCb+rsQfU=; b=I/PygKepzstdaqq4umegS7AYJb5XNP53fGpU5MTpgSE7OW0IclZ2GMr6UcgB3isS+R 7bljBryA3JWWX0SjCxF0R4ii7YhfEbZvDyVJkmKg3CCxF00+tH0W6fmKTPl5iMo+gElU WxcJW+PFxgHqkuWHQmL6EfXN/bP3sceM7mqZ5Yo/1m/ySY7bn4Bz20TQP9bGs8+NFACg v9K/HIJP7eAWk4brKSAkST0W++HDm4ZWnsqKBM6obYVLHD8ZHh3veRP7wO9rR+tONdUz stSidfeOq7f+IpnKqLnMUjxx9wIYV/gZ8nJi3c00sLMEZ9iobQ5Zzj8MqyoKfWb7m7DG AK4Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@google.com header.s=20161025 header.b=ok4Pi5nu; dkim=fail header.i=@chromium.org header.s=google header.b=AZ5H4xrX; 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=fail (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 x63-v6si30848715pfb.352.2018.07.16.20.57.30; Mon, 16 Jul 2018 20:57:46 -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=fail header.i=@google.com header.s=20161025 header.b=ok4Pi5nu; dkim=fail header.i=@chromium.org header.s=google header.b=AZ5H4xrX; 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=fail (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727096AbeGQE1Z (ORCPT + 99 others); Tue, 17 Jul 2018 00:27:25 -0400 Received: from mail-yb0-f195.google.com ([209.85.213.195]:40875 "EHLO mail-yb0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726753AbeGQE1Z (ORCPT ); Tue, 17 Jul 2018 00:27:25 -0400 Received: by mail-yb0-f195.google.com with SMTP id y11-v6so16295255ybm.7 for ; Mon, 16 Jul 2018 20:56:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc; bh=gmh5bXsFrHKLy7iNW75AOlO+7QSQS0tyNvTCb+rsQfU=; b=ok4Pi5nuOTC2DvQzOsEEzLo0oNZLOR1v4aSX1KBwNtlZZ/UlnBLJ6vcDL/R8rNJQdw g+LwDZGlpaGOFdiE4kgrf90Fp86NOkahFUfX5PYhl/VERatzj1bvmqco2/mFATDJ3Fjs /xP/GxGQE6BL7dkCInCY28tymmq6ze49owv5ESBc2I+RZSS1zB9NghHnBeRJFb9TJ94V bYI3Pw5DKv40fQLTcWK2hwHW2E0fZduZ+x5gA4OD+2ipOcmIqzt+ZAgI1yAVyIg5OOy1 yB0mGaH+FrSF6fvLexUWkirfcAFgtD9b3NVzSH5os9iD74gJHMRK/Nl99TI1rQ1S3BL3 w/fw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc; bh=gmh5bXsFrHKLy7iNW75AOlO+7QSQS0tyNvTCb+rsQfU=; b=AZ5H4xrXq4Bx04IxNGKc7TActproqqGO9hcP+BVwNTzox12VLoHAnzBQu7ddCUYbB4 aC6WmmcIo03oD21/hZlL9ajk2NV0J60NUbJIy4jbXpifDdq/7k1iucGlKdatlPSkXQ3S zAbWmcBLhc1l1W3QyxoH3hCUjr5fZWpGIfx5A= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to:cc; bh=gmh5bXsFrHKLy7iNW75AOlO+7QSQS0tyNvTCb+rsQfU=; b=lSm9g3T8MB4vxgpjJY8kq4mjCZPS+OCd8LpbWZx0lqg/zeccD7rO4KfD93Qx8b4v75 OYjq0QEPguQ0xeCVAxojXmaRL1sAINpD0cq8oQtiTMHtpBx3REYyXAp0athtP9BP3YQx nA7jK6sqq+TqbXwrOoqdnCkr+WeLTdOUx3CqFtytFpWRqE7SZtL9NJRSGm7hvQSBEWwZ pS1P0znoTeL1KwvlJk2wvBIFhmLwncBkqhoYmH9b2zozhT4+bSN5vWQjWoDCp6cMoFBr 0rY7tRMwtpLUUSs/q15qtnwDmjr0wpP8Qpkhbt/N9MP3ljX08GJTceU+7joU25Ok9y4Y /uzQ== X-Gm-Message-State: AOUpUlERGSDAYYUJcmkfzUdlik/kydXhtogBKjkC7LoE/dkju0c0VaV+ SOhlyOXDq0l1cA0f5bSgcQMlMiWyDI+s5IVjKWMQhA== X-Received: by 2002:a25:afce:: with SMTP id d14-v6mr9545199ybj.343.1531799815524; Mon, 16 Jul 2018 20:56:55 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a25:6602:0:0:0:0:0 with HTTP; Mon, 16 Jul 2018 20:56:54 -0700 (PDT) In-Reply-To: <20180629185254.GA37557@beast> References: <20180629185254.GA37557@beast> From: Kees Cook Date: Mon, 16 Jul 2018 20:56:54 -0700 X-Google-Sender-Auth: qVeGM6o_26irSimAOsZw12_W9BU Message-ID: Subject: Re: [PATCH] powerpc/msi: Remove VLA usage To: Michael Ellerman Cc: Benjamin Herrenschmidt , Paul Mackerras , Andrew Morton , Randy Dunlap , Tyrel Datwyler , Rob Herring , Ingo Molnar , PowerPC , LKML Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Jun 29, 2018 at 11:52 AM, Kees Cook wrote: > 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 > > Signed-off-by: Kees Cook Friendly ping! Michael, can you take this? -Kees > --- > 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 -- Kees Cook Pixel Security