Re: [PATCH 21/32] kasan: simplify invalid-free reporting

From: Andrey Konovalov
Date: Tue Jul 12 2022 - 16:38:27 EST


On Tue, Jun 21, 2022 at 9:17 AM Kuan-Ying Lee
<Kuan-Ying.Lee@xxxxxxxxxxxx> wrote:
>
> On Tue, 2022-06-14 at 04:14 +0800, andrey.konovalov@xxxxxxxxx wrote:
> > From: Andrey Konovalov <andreyknvl@xxxxxxxxxx>
> >
> > Right now, KASAN uses the kasan_report_type enum to describe report
> > types.
> >
> > As this enum only has two options, replace it with a bool variable.
> >
> > Also, unify printing report header for invalid-free and other bug
> > types
> > in print_error_description().
> >
> > Signed-off-by: Andrey Konovalov <andreyknvl@xxxxxxxxxx>
> > ---
> > mm/kasan/kasan.h | 7 +------
> > mm/kasan/report.c | 16 +++++++---------
> > 2 files changed, 8 insertions(+), 15 deletions(-)
> >
> > diff --git a/mm/kasan/kasan.h b/mm/kasan/kasan.h
> > index e8329935fbfb..f696d50b09fb 100644
> > --- a/mm/kasan/kasan.h
> > +++ b/mm/kasan/kasan.h
> > @@ -146,16 +146,11 @@ static inline bool kasan_requires_meta(void)
> > #define META_MEM_BYTES_PER_ROW (META_BYTES_PER_ROW *
> > KASAN_GRANULE_SIZE)
> > #define META_ROWS_AROUND_ADDR 2
> >
> > -enum kasan_report_type {
> > - KASAN_REPORT_ACCESS,
> > - KASAN_REPORT_INVALID_FREE,
> > -};
> > -
> > struct kasan_report_info {
> > - enum kasan_report_type type;
> > void *access_addr;
> > void *first_bad_addr;
> > size_t access_size;
> > + bool is_free;
> > bool is_write;
> > unsigned long ip;
> > };
> > diff --git a/mm/kasan/report.c b/mm/kasan/report.c
> > index f951fd39db74..7269b6249488 100644
> > --- a/mm/kasan/report.c
> > +++ b/mm/kasan/report.c
> > @@ -175,14 +175,12 @@ static void end_report(unsigned long *flags,
> > void *addr)
> >
>
> Hi Andrey,
>
> Do we need to distinguish "double free" case from "invalid free" or
> we just print "double-free or invalid-free"?
>
> I sent a patch[1] to separate double free case from invalid
> free last week and I saw it has been merged into akpm tree.
>
> [1]
> https://lore.kernel.org/linux-mm/20220615062219.22618-1-Kuan-Ying.Lee@xxxxxxxxxxxx/

Hi Kuan-Ying,

Yes, thank you for the patch! I will rebase my series onto it.

Thanks!