From: "Kirill A. Shutemov" <kirill@shutemov.name>
To: Dave Hansen <dave.hansen@linux.intel.com>
Cc: linux-kernel@vger.kernel.org, x86@kernel.org, shuah@kernel.org,
linux-kselftest@vger.kernel.org
Subject: Re: [PATCH 2/2] selftests, x86, pkeys: test with random, unallocated protection keys
Date: Fri, 24 Feb 2017 03:10:09 +0300 [thread overview]
Message-ID: <20170224001009.GB26920@node.shutemov.name> (raw)
In-Reply-To: <20170223222604.D3AE8473@viggo.jf.intel.com>
On Thu, Feb 23, 2017 at 02:26:04PM -0800, Dave Hansen wrote:
>
>
> Shuah, I assume you'll take this patch in through the selftests tree.
>
> --
> From: Dave Hansen <dave.hansen@linux.intel.com>
>
> The kernel pkeys code had a minor bug where it did some large shifts
> to an integer which is undefined behavior in C. It didn't cause any
> real harm, but it is screwy behavior that the kernel should have
> rejected.
>
> Add a test case for this.
>
> Signed-off-by: Dave Hansen <dave.hansen@linux.intel.com>
> ec: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
> Cc: Shuah Khan <shuah@kernel.org>
> Cc: linux-kselftest@vger.kernel.org
> Cc: linux-kernel@vger.kernel.org
> Cc: x86@kernel.org
> ---
>
> b/tools/testing/selftests/x86/protection_keys.c | 25 ++++++++++++++++++++++++
> 1 file changed, 25 insertions(+)
>
> diff -puN tools/testing/selftests/x86/protection_keys.c~pkeys-better-selftests-of-random-pkey tools/testing/selftests/x86/protection_keys.c
> --- a/tools/testing/selftests/x86/protection_keys.c~pkeys-better-selftests-of-random-pkey 2017-02-23 14:21:05.168391529 -0800
> +++ b/tools/testing/selftests/x86/protection_keys.c 2017-02-23 14:23:03.244671815 -0800
> @@ -1123,6 +1123,30 @@ void test_pkey_syscalls_on_non_allocated
> }
>
> /* Assumes that all pkeys other than 'pkey' are unallocated */
> +void test_pkey_syscalls_on_non_allocated_random_pkey(int *ptr, u16 pkey)
> +{
> + int err;
> + int nr_tests = 0;
> +
> + while (nr_tests < 1000) {
> + int test_pkey = rand();
rand(3) doesn't generate negative numbers. Would be good to cover this
case too.
int test_pkey = rand() - RAND_MAX/2;
?
Otherwise looks good to me.
--
Kirill A. Shutemov
next prev parent reply other threads:[~2017-02-24 0:10 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-02-23 22:26 [PATCH 1/2] x86, pkeys: check against max pkey to avoid overflows Dave Hansen
2017-02-23 22:26 ` [PATCH 2/2] selftests, x86, pkeys: test with random, unallocated protection keys Dave Hansen
2017-02-23 22:36 ` Shuah Khan
2017-02-24 7:45 ` Ingo Molnar
2017-02-24 14:41 ` Shuah Khan
2017-02-25 9:10 ` Ingo Molnar
2017-02-24 0:10 ` Kirill A. Shutemov [this message]
2017-02-24 0:07 ` [PATCH 1/2] x86, pkeys: check against max pkey to avoid overflows Kirill A. Shutemov
2017-03-01 9:57 ` [tip:x86/urgent] x86/pkeys: Check " tip-bot for Dave Hansen
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=20170224001009.GB26920@node.shutemov.name \
--to=kirill@shutemov.name \
--cc=dave.hansen@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=shuah@kernel.org \
--cc=x86@kernel.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox