* [PATCH] powerpc/msi: Remove VLA usage
@ 2018-06-29 18:52 Kees Cook
2018-07-17 3:56 ` Kees Cook
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: Kees Cook @ 2018-06-29 18:52 UTC (permalink / raw)
To: Benjamin Herrenschmidt
Cc: Paul Mackerras, Michael Ellerman, Andrew Morton, Randy Dunlap,
Tyrel Datwyler, Rob Herring, Ingo Molnar, linuxppc-dev,
linux-kernel
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 <benh@kernel.crashing.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Randy Dunlap <rdunlap@infradead.org>
Cc: Tyrel Datwyler <tyreld@linux.vnet.ibm.com>
Cc: Rob Herring <robh@kernel.org>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: linuxppc-dev@lists.ozlabs.org
Signed-off-by: Kees Cook <keescook@chromium.org>
---
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
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] powerpc/msi: Remove VLA usage
2018-06-29 18:52 [PATCH] powerpc/msi: Remove VLA usage Kees Cook
@ 2018-07-17 3:56 ` Kees Cook
2018-07-19 12:17 ` Michael Ellerman
2018-07-17 21:12 ` Tyrel Datwyler
2018-07-19 6:07 ` Michael Ellerman
2 siblings, 1 reply; 6+ messages in thread
From: Kees Cook @ 2018-07-17 3:56 UTC (permalink / raw)
To: Michael Ellerman
Cc: Benjamin Herrenschmidt, Paul Mackerras, Andrew Morton,
Randy Dunlap, Tyrel Datwyler, Rob Herring, Ingo Molnar, PowerPC,
LKML
On Fri, Jun 29, 2018 at 11:52 AM, Kees Cook <keescook@chromium.org> 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 <keescook@chromium.org>
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
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] powerpc/msi: Remove VLA usage
2018-06-29 18:52 [PATCH] powerpc/msi: Remove VLA usage Kees Cook
2018-07-17 3:56 ` Kees Cook
@ 2018-07-17 21:12 ` Tyrel Datwyler
2018-07-19 6:07 ` Michael Ellerman
2 siblings, 0 replies; 6+ messages in thread
From: Tyrel Datwyler @ 2018-07-17 21:12 UTC (permalink / raw)
To: Kees Cook, Benjamin Herrenschmidt
Cc: Rob Herring, Randy Dunlap, linux-kernel, Paul Mackerras,
Tyrel Datwyler, Andrew Morton, linuxppc-dev, Ingo Molnar
On 06/29/2018 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
>
> Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
> Cc: Paul Mackerras <paulus@samba.org>
> Cc: Michael Ellerman <mpe@ellerman.id.au>
> Cc: Andrew Morton <akpm@linux-foundation.org>
> Cc: Randy Dunlap <rdunlap@infradead.org>
> Cc: Tyrel Datwyler <tyreld@linux.vnet.ibm.com>
> Cc: Rob Herring <robh@kernel.org>
> Cc: Ingo Molnar <mingo@kernel.org>
> Cc: linuxppc-dev@lists.ozlabs.org
> Signed-off-by: Kees Cook <keescook@chromium.org>
> ---
Reviewed-by: Tyrel Datwyler <tyreld@linux.vnet.ibm.com>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: powerpc/msi: Remove VLA usage
2018-06-29 18:52 [PATCH] powerpc/msi: Remove VLA usage Kees Cook
2018-07-17 3:56 ` Kees Cook
2018-07-17 21:12 ` Tyrel Datwyler
@ 2018-07-19 6:07 ` Michael Ellerman
2 siblings, 0 replies; 6+ messages in thread
From: Michael Ellerman @ 2018-07-19 6:07 UTC (permalink / raw)
To: Kees Cook, Benjamin Herrenschmidt
Cc: Rob Herring, Randy Dunlap, linux-kernel, Paul Mackerras,
Tyrel Datwyler, Andrew Morton, linuxppc-dev, Ingo Molnar
On Fri, 2018-06-29 at 18:52:54 UTC, 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
>
> Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
> Cc: Paul Mackerras <paulus@samba.org>
> Cc: Michael Ellerman <mpe@ellerman.id.au>
> Cc: Andrew Morton <akpm@linux-foundation.org>
> Cc: Randy Dunlap <rdunlap@infradead.org>
> Cc: Tyrel Datwyler <tyreld@linux.vnet.ibm.com>
> Cc: Rob Herring <robh@kernel.org>
> Cc: Ingo Molnar <mingo@kernel.org>
> Cc: linuxppc-dev@lists.ozlabs.org
> Signed-off-by: Kees Cook <keescook@chromium.org>
Applied to powerpc next, thanks.
https://git.kernel.org/powerpc/c/1b80ac648483189e45f60d4ddbb54b
cheers
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] powerpc/msi: Remove VLA usage
2018-07-17 3:56 ` Kees Cook
@ 2018-07-19 12:17 ` Michael Ellerman
2018-07-19 18:33 ` Kees Cook
0 siblings, 1 reply; 6+ messages in thread
From: Michael Ellerman @ 2018-07-19 12:17 UTC (permalink / raw)
To: Kees Cook
Cc: Benjamin Herrenschmidt, Paul Mackerras, Andrew Morton,
Randy Dunlap, Tyrel Datwyler, Rob Herring, Ingo Molnar, PowerPC,
LKML
Kees Cook <keescook@chromium.org> writes:
> On Fri, Jun 29, 2018 at 11:52 AM, Kees Cook <keescook@chromium.org> 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 <keescook@chromium.org>
>
> Friendly ping! Michael, can you take this?
Yep, sorry. I actually applied it weeks ago but hadn't pushed.
cheers
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] powerpc/msi: Remove VLA usage
2018-07-19 12:17 ` Michael Ellerman
@ 2018-07-19 18:33 ` Kees Cook
0 siblings, 0 replies; 6+ messages in thread
From: Kees Cook @ 2018-07-19 18:33 UTC (permalink / raw)
To: Michael Ellerman
Cc: Benjamin Herrenschmidt, Paul Mackerras, Andrew Morton,
Randy Dunlap, Tyrel Datwyler, Rob Herring, Ingo Molnar, PowerPC,
LKML
On Thu, Jul 19, 2018 at 5:17 AM, Michael Ellerman <mpe@ellerman.id.au> wrote:
> Kees Cook <keescook@chromium.org> writes:
>
>> On Fri, Jun 29, 2018 at 11:52 AM, Kees Cook <keescook@chromium.org> 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 <keescook@chromium.org>
>>
>> Friendly ping! Michael, can you take this?
>
> Yep, sorry. I actually applied it weeks ago but hadn't pushed.
No worries! Thanks! :)
-Kees
--
Kees Cook
Pixel Security
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2018-07-19 18:34 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-06-29 18:52 [PATCH] powerpc/msi: Remove VLA usage Kees Cook
2018-07-17 3:56 ` Kees Cook
2018-07-19 12:17 ` Michael Ellerman
2018-07-19 18:33 ` Kees Cook
2018-07-17 21:12 ` Tyrel Datwyler
2018-07-19 6:07 ` Michael Ellerman
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).