All of lore.kernel.org
 help / color / mirror / Atom feed
From: Rasmus Villemoes <linux@rasmusvillemoes.dk>
To: Nick Desaulniers <ndesaulniers@google.com>,
	Kees Cook <keescook@chromium.org>
Cc: "Gustavo A. R. Silva" <gustavoars@kernel.org>,
	Nathan Chancellor <nathan@kernel.org>,
	Jason Gunthorpe <jgg@ziepe.ca>, Leon Romanovsky <leon@kernel.org>,
	Keith Busch <kbusch@kernel.org>, Len Baker <len.baker@gmx.com>,
	linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org
Subject: Re: [PATCH 2/2] test_overflow: Regularize test reporting output
Date: Tue, 21 Sep 2021 08:56:20 +0200	[thread overview]
Message-ID: <eb6d02ae-e2ed-e7bd-c700-8a6d004d84ce@rasmusvillemoes.dk> (raw)
In-Reply-To: <CAKwvOdnYYa+72VhtJ4ug=SJVFn7w+n7Th+hKYE87BRDt4hvqOg@mail.gmail.com>

On 21/09/2021 00.10, Nick Desaulniers wrote:
> On Mon, Sep 20, 2021 at 11:09 AM Kees Cook <keescook@chromium.org> wrote:
>>

>> @@ -544,10 +544,7 @@ DEFINE_TEST_ALLOC(kmalloc,  kfree,      0, 1, 0);
>>  DEFINE_TEST_ALLOC(kmalloc_node,         kfree,      0, 1, 1);
>>  DEFINE_TEST_ALLOC(kzalloc,      kfree,      0, 1, 0);
>>  DEFINE_TEST_ALLOC(kzalloc_node,  kfree,             0, 1, 1);
>> -DEFINE_TEST_ALLOC(vmalloc,      vfree,      0, 0, 0);
>> -DEFINE_TEST_ALLOC(vmalloc_node,  vfree,             0, 0, 1);
>> -DEFINE_TEST_ALLOC(vzalloc,      vfree,      0, 0, 0);
>> -DEFINE_TEST_ALLOC(vzalloc_node,  vfree,             0, 0, 1);
>> +DEFINE_TEST_ALLOC(__vmalloc,    vfree,      0, 1, 0);
>>  DEFINE_TEST_ALLOC(kvmalloc,     kvfree,     0, 1, 0);
>>  DEFINE_TEST_ALLOC(kvmalloc_node, kvfree,     0, 1, 1);
>>  DEFINE_TEST_ALLOC(kvzalloc,     kvfree,     0, 1, 0);
>> @@ -559,8 +556,14 @@ static int __init test_overflow_allocation(void)
>>  {
>>         const char device_name[] = "overflow-test";
>>         struct device *dev;
>> +       int count = 0;
>>         int err = 0;
>>
>> +#define check_allocation_overflow(alloc)       ({      \
>> +       count++;                                        \
>> +       test_ ## alloc(dev);                            \
>> +})
>> +
>>         /* Create dummy device for devm_kmalloc()-family tests. */
>>         dev = root_device_register(device_name);
>>         if (IS_ERR(dev)) {
>> @@ -568,23 +571,22 @@ static int __init test_overflow_allocation(void)
>>                 return 1;
>>         }
>>
>> -       err |= test_kmalloc(NULL);
>> -       err |= test_kmalloc_node(NULL);
>> -       err |= test_kzalloc(NULL);
>> -       err |= test_kzalloc_node(NULL);
>> -       err |= test_kvmalloc(NULL);
>> -       err |= test_kvmalloc_node(NULL);
>> -       err |= test_kvzalloc(NULL);
>> -       err |= test_kvzalloc_node(NULL);
>> -       err |= test_vmalloc(NULL);
>> -       err |= test_vmalloc_node(NULL);
>> -       err |= test_vzalloc(NULL);
>> -       err |= test_vzalloc_node(NULL);
>> -       err |= test_devm_kmalloc(dev);
>> -       err |= test_devm_kzalloc(dev);
>> +       err |= check_allocation_overflow(kmalloc);
>> +       err |= check_allocation_overflow(kmalloc_node);
>> +       err |= check_allocation_overflow(kzalloc);
>> +       err |= check_allocation_overflow(kzalloc_node);
>> +       err |= check_allocation_overflow(__vmalloc);
>> +       err |= check_allocation_overflow(kvmalloc);
>> +       err |= check_allocation_overflow(kvmalloc_node);
>> +       err |= check_allocation_overflow(kvzalloc);
>> +       err |= check_allocation_overflow(kvzalloc_node);
>> +       err |= check_allocation_overflow(devm_kmalloc);
>> +       err |= check_allocation_overflow(devm_kzalloc);
>>
>>         device_unregister(dev);

I'd prefer if such a local helper macro was defined immediately prior to
the sequence of uses, and then #undef'ed at the end.

Other than that:

Acked-by: Rasmus Villemoes <linux@rasmusvillemoes.dk>

      reply	other threads:[~2021-09-21  6:56 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-20 18:08 [PATCH 0/2] overflow: Implement size_t saturating arithmetic helpers Kees Cook
2021-09-20 18:08 ` [PATCH 1/2] " Kees Cook
2021-09-20 22:06   ` Nick Desaulniers
2021-09-21  1:38     ` Kees Cook
2021-09-21  6:51   ` Rasmus Villemoes
2021-09-21 19:07     ` Kees Cook
2022-01-24 21:13     ` Kees Cook
2022-01-24 21:16       ` Nick Desaulniers
2022-01-25 12:58       ` Jason Gunthorpe
2021-09-20 18:08 ` [PATCH 2/2] test_overflow: Regularize test reporting output Kees Cook
2021-09-20 22:10   ` Nick Desaulniers
2021-09-21  6:56     ` Rasmus Villemoes [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=eb6d02ae-e2ed-e7bd-c700-8a6d004d84ce@rasmusvillemoes.dk \
    --to=linux@rasmusvillemoes.dk \
    --cc=gustavoars@kernel.org \
    --cc=jgg@ziepe.ca \
    --cc=kbusch@kernel.org \
    --cc=keescook@chromium.org \
    --cc=len.baker@gmx.com \
    --cc=leon@kernel.org \
    --cc=linux-hardening@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nathan@kernel.org \
    --cc=ndesaulniers@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.