Message ID | 20210804082230.10837-3-Kuan-Ying.Lee@mediatek.com (mailing list archive) |
---|---|
State | New |
Headers | show |
Series | kasan: reset tag when accessing invalid data | expand |
On Wed, 4 Aug 2021 at 10:23, Kuan-Ying Lee <Kuan-Ying.Lee@mediatek.com> wrote: > > The address still includes the tags when it is printed. > With hardware tag-based kasan enabled, we will get a > false positive KASAN issue when we access metadata. > > Reset the tag before we access the metadata. > > Fixes: aa1ef4d7b3f6 ("kasan, mm: reset tags when accessing metadata") > Signed-off-by: Kuan-Ying Lee <Kuan-Ying.Lee@mediatek.com> > Suggested-by: Marco Elver <elver@google.com> Note, in this case Suggested-by is inappropriate, because I did not suggest the change in any way (you already had it in v1). I just commented on the fact that it's missing a Fixes so stable can pick it up and some clarification. Reviewed-by: Marco Elver <elver@google.com> > --- > mm/slub.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/mm/slub.c b/mm/slub.c > index b6c5205252eb..f77d8cd79ef7 100644 > --- a/mm/slub.c > +++ b/mm/slub.c > @@ -576,8 +576,8 @@ static void print_section(char *level, char *text, u8 *addr, > unsigned int length) > { > metadata_access_enable(); > - print_hex_dump(level, kasan_reset_tag(text), DUMP_PREFIX_ADDRESS, > - 16, 1, addr, length, 1); > + print_hex_dump(level, text, DUMP_PREFIX_ADDRESS, > + 16, 1, kasan_reset_tag((void *)addr), length, 1); > metadata_access_disable(); > } > > -- > 2.18.0
On Wed, 2021-08-04 at 10:41 +0200, Marco Elver wrote: > On Wed, 4 Aug 2021 at 10:23, Kuan-Ying Lee < > Kuan-Ying.Lee@mediatek.com> wrote: > > > > The address still includes the tags when it is printed. > > With hardware tag-based kasan enabled, we will get a > > false positive KASAN issue when we access metadata. > > > > Reset the tag before we access the metadata. > > > > Fixes: aa1ef4d7b3f6 ("kasan, mm: reset tags when accessing > > metadata") > > Signed-off-by: Kuan-Ying Lee <Kuan-Ying.Lee@mediatek.com> > > Suggested-by: Marco Elver <elver@google.com> > > Note, in this case Suggested-by is inappropriate, because I did not > suggest the change in any way (you already had it in v1). I just > commented on the fact that it's missing a Fixes so stable can pick it > up and some clarification. > > Reviewed-by: Marco Elver <elver@google.com> Got it. I will remove it on v3. Thanks. > > > --- > > mm/slub.c | 4 ++-- > > 1 file changed, 2 insertions(+), 2 deletions(-) > > > > diff --git a/mm/slub.c b/mm/slub.c > > index b6c5205252eb..f77d8cd79ef7 100644 > > --- a/mm/slub.c > > +++ b/mm/slub.c > > @@ -576,8 +576,8 @@ static void print_section(char *level, char > > *text, u8 *addr, > > unsigned int length) > > { > > metadata_access_enable(); > > - print_hex_dump(level, kasan_reset_tag(text), > > DUMP_PREFIX_ADDRESS, > > - 16, 1, addr, length, 1); > > + print_hex_dump(level, text, DUMP_PREFIX_ADDRESS, > > + 16, 1, kasan_reset_tag((void *)addr), > > length, 1); > > metadata_access_disable(); > > } > > > > -- > > 2.18.0
diff --git a/mm/slub.c b/mm/slub.c index b6c5205252eb..f77d8cd79ef7 100644 --- a/mm/slub.c +++ b/mm/slub.c @@ -576,8 +576,8 @@ static void print_section(char *level, char *text, u8 *addr, unsigned int length) { metadata_access_enable(); - print_hex_dump(level, kasan_reset_tag(text), DUMP_PREFIX_ADDRESS, - 16, 1, addr, length, 1); + print_hex_dump(level, text, DUMP_PREFIX_ADDRESS, + 16, 1, kasan_reset_tag((void *)addr), length, 1); metadata_access_disable(); }
The address still includes the tags when it is printed. With hardware tag-based kasan enabled, we will get a false positive KASAN issue when we access metadata. Reset the tag before we access the metadata. Fixes: aa1ef4d7b3f6 ("kasan, mm: reset tags when accessing metadata") Signed-off-by: Kuan-Ying Lee <Kuan-Ying.Lee@mediatek.com> Suggested-by: Marco Elver <elver@google.com> --- mm/slub.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)