Re: [PATCH] kasan: fix more unit tests with CONFIG_UBSAN_LOCAL_BOUNDS enabled

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Feb 21, 2022 at 3:20 AM Marco Elver <elver@xxxxxxxxxx> wrote:
>
> On Sat, 19 Feb 2022 at 02:26, Peter Collingbourne <pcc@xxxxxxxxxx> wrote:
> >
> > This is a followup to commit f649dc0e0d7b ("kasan: fix unit tests
> > with CONFIG_UBSAN_LOCAL_BOUNDS enabled") that fixes tests that fail
> > as a result of __alloc_size annotations being added to the kernel
> > allocator functions.
> >
> > Link: https://linux-review.googlesource.com/id/I4334cafc5db600fda5cebb851b2ee9fd09fb46cc
> > Signed-off-by: Peter Collingbourne <pcc@xxxxxxxxxx>
> > Cc: <stable@xxxxxxxxxxxxxxx> # 5.16.x
> > Fixes: c37495d6254c ("slab: add __alloc_size attributes for better bounds checking")
> > ---
> >  lib/test_kasan.c | 9 ++++++---
> >  1 file changed, 6 insertions(+), 3 deletions(-)
> >
> > diff --git a/lib/test_kasan.c b/lib/test_kasan.c
> > index 26a5c9007653..3bf8801d0e66 100644
> > --- a/lib/test_kasan.c
> > +++ b/lib/test_kasan.c
> > @@ -177,7 +177,8 @@ static void kmalloc_node_oob_right(struct kunit *test)
> >   */
> >  static void kmalloc_pagealloc_oob_right(struct kunit *test)
> >  {
> > -       char *ptr;
> > +       /* See comment in kasan_global_oob_right. */
> > +       char *volatile ptr;
> >         size_t size = KMALLOC_MAX_CACHE_SIZE + 10;
>
> I think more recently we've been using OPTIMIZER_HIDE_VAR() to hide
> things from the compiler. Does OPTIMIZER_HIDE_VAR(ptr) right before
> the access also work in this case?
>
> I leave it to you which you think is cleaner - I'm guessing that we
> might want to avoid volatile if we can.

Okay, sent v2 which uses OPTIMIZER_HIDE_VAR.

Peter



[Index of Archives]     [Linux Kernel]     [Kernel Development Newbies]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite Hiking]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux