Re: [PATCH v2 14/16] kasan: Remove ksize()-related tests

Kees Cook
2022-09-26T00:39:08Z

On Sat, Sep 24, 2022 at 10:15:18AM +0200, Dmitry Vyukov wrote:
> On Fri, 23 Sept 2022 at 22:28, Kees Cook <keescook@chromium.org> wrote:
> >
> > In preparation for no longer unpoisoning in ksize(), remove the behavioral
> > self-tests for ksize().
> >
> > [...]
> > -/* Check that ksize() makes the whole object accessible. */
> > -static void ksize_unpoisons_memory(struct kunit *test)
> > -{
> > - char *ptr;
> > - size_t size = 123, real_size;
> > -
> > - ptr = kmalloc(size, GFP_KERNEL);
> > - KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ptr);
> > - real_size = ksize(ptr);
> > -
> > - OPTIMIZER_HIDE_VAR(ptr);
> > -
> > - /* This access shouldn't trigger a KASAN report. */
> > - ptr[size] = 'x';
>
> I would rather keep the tests and update to the new behavior. We had
> bugs in ksize, we need test coverage.
> I assume ptr[size] access must now produce an error even after ksize.

Good point on all these! I'll respin.

--
Kees Cook