[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CA+fCnZfg2E7Hk2Sc-=Z4XnENm9KUtmAZ6378YgeJg6xriMQXpA@mail.gmail.com>
Date: Wed, 18 Sep 2024 17:15:18 +0200
From: Andrey Konovalov <andreyknvl@...il.com>
To: Sabyrzhan Tasbolatov <snovitoll@...il.com>
Cc: akpm@...ux-foundation.org, bp@...en8.de, brauner@...nel.org,
dave.hansen@...ux.intel.com, dhowells@...hat.com, dvyukov@...gle.com,
glider@...gle.com, hpa@...or.com, kasan-dev@...glegroups.com,
linux-kernel@...r.kernel.org, linux-mm@...ck.org, mingo@...hat.com,
ryabinin.a.a@...il.com, tglx@...utronix.de, vincenzo.frascino@....com,
x86@...nel.org
Subject: Re: [PATCH v2] mm: x86: instrument __get/__put_kernel_nofault
On Wed, Sep 18, 2024 at 12:57 PM Sabyrzhan Tasbolatov
<snovitoll@...il.com> wrote:
>
> diff --git a/mm/kasan/kasan_test.c b/mm/kasan/kasan_test.c
> index 7b32be2a3cf0..9a3c4ad91d59 100644
> --- a/mm/kasan/kasan_test.c
> +++ b/mm/kasan/kasan_test.c
> @@ -1899,6 +1899,26 @@ static void match_all_mem_tag(struct kunit *test)
> kfree(ptr);
> }
>
> +static void copy_from_to_kernel_nofault(struct kunit *test)
> +{
> + char *ptr;
> + char buf[KASAN_GRANULE_SIZE];
> + size_t size = sizeof(buf);
> +
> + ptr = kmalloc(size, GFP_KERNEL);
> + KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ptr);
> + kfree(ptr);
> +
> + KUNIT_EXPECT_KASAN_FAIL(test,
> + copy_from_kernel_nofault(&buf[0], ptr, size));
> + KUNIT_EXPECT_KASAN_FAIL(test,
> + copy_from_kernel_nofault(ptr, &buf[0], size));
> + KUNIT_EXPECT_KASAN_FAIL(test,
> + copy_to_kernel_nofault(&buf[0], ptr, size));
> + KUNIT_EXPECT_KASAN_FAIL(test,
> + copy_to_kernel_nofault(ptr, &buf[0], size));
> +}
You still have the same problem here.
What I meant is:
char *ptr;
char buf[128 - KASAN_GRANULE_SIZE];
size_t size = sizeof(buf);
ptr = kmalloc(size, GFP_KERNEL);
KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ptr);
KUNIT_EXPECT_KASAN_FAIL(...);
...
kfree(ptr);
Thanks!
Powered by blists - more mailing lists