Message ID | 20190215000441.14323-2-dja@axtens.net (mailing list archive) |
---|---|
State | RFC |
Headers | show |
Series | powerpc: KASAN for 64-bit Book3E | expand |
Context | Check | Description |
---|---|---|
snowpatch_ozlabs/apply_patch | success | next/apply_patch Successfully applied |
snowpatch_ozlabs/checkpatch | success | total: 0 errors, 0 warnings, 0 checks, 18 lines checked |
On 15/2/19 11:04 am, Daniel Axtens wrote: > We have a couple of places checking for the existence of a shadow > mapping for an address by open-coding the inverse of the check in > addr_has_shadow. > > Replace the open-coded versions with the helper. This will be > needed in future to allow architectures to override the layout > of the shadow mapping. > > Signed-off-by: Daniel Axtens <dja@axtens.net> Reviewed-by: Andrew Donnellan <andrew.donnellan@au1.ibm.com> > --- > mm/kasan/generic.c | 3 +-- > mm/kasan/tags.c | 3 +-- > 2 files changed, 2 insertions(+), 4 deletions(-) > > diff --git a/mm/kasan/generic.c b/mm/kasan/generic.c > index ccb6207276e3..ffc64a9a97a5 100644 > --- a/mm/kasan/generic.c > +++ b/mm/kasan/generic.c > @@ -173,8 +173,7 @@ static __always_inline void check_memory_region_inline(unsigned long addr, > if (unlikely(size == 0)) > return; > > - if (unlikely((void *)addr < > - kasan_shadow_to_mem((void *)KASAN_SHADOW_START))) { > + if (unlikely(!addr_has_shadow((void *)addr))) { > kasan_report(addr, size, write, ret_ip); > return; > } > diff --git a/mm/kasan/tags.c b/mm/kasan/tags.c > index 0777649e07c4..bc759f8f1c67 100644 > --- a/mm/kasan/tags.c > +++ b/mm/kasan/tags.c > @@ -109,8 +109,7 @@ void check_memory_region(unsigned long addr, size_t size, bool write, > return; > > untagged_addr = reset_tag((const void *)addr); > - if (unlikely(untagged_addr < > - kasan_shadow_to_mem((void *)KASAN_SHADOW_START))) { > + if (unlikely(!addr_has_shadow(untagged_addr))) { > kasan_report(addr, size, write, ret_ip); > return; > } >
On Fri, Feb 15, 2019 at 1:12 AM Andrew Donnellan <andrew.donnellan@au1.ibm.com> wrote: > > On 15/2/19 11:04 am, Daniel Axtens wrote: > > We have a couple of places checking for the existence of a shadow > > mapping for an address by open-coding the inverse of the check in > > addr_has_shadow. > > > > Replace the open-coded versions with the helper. This will be > > needed in future to allow architectures to override the layout > > of the shadow mapping. > > > > Signed-off-by: Daniel Axtens <dja@axtens.net> > > Reviewed-by: Andrew Donnellan <andrew.donnellan@au1.ibm.com> Reviewed-by: Dmitry Vyukov <dvyukov@google.com> > > --- > > mm/kasan/generic.c | 3 +-- > > mm/kasan/tags.c | 3 +-- > > 2 files changed, 2 insertions(+), 4 deletions(-) > > > > diff --git a/mm/kasan/generic.c b/mm/kasan/generic.c > > index ccb6207276e3..ffc64a9a97a5 100644 > > --- a/mm/kasan/generic.c > > +++ b/mm/kasan/generic.c > > @@ -173,8 +173,7 @@ static __always_inline void check_memory_region_inline(unsigned long addr, > > if (unlikely(size == 0)) > > return; > > > > - if (unlikely((void *)addr < > > - kasan_shadow_to_mem((void *)KASAN_SHADOW_START))) { > > + if (unlikely(!addr_has_shadow((void *)addr))) { > > kasan_report(addr, size, write, ret_ip); > > return; > > } > > diff --git a/mm/kasan/tags.c b/mm/kasan/tags.c > > index 0777649e07c4..bc759f8f1c67 100644 > > --- a/mm/kasan/tags.c > > +++ b/mm/kasan/tags.c > > @@ -109,8 +109,7 @@ void check_memory_region(unsigned long addr, size_t size, bool write, > > return; > > > > untagged_addr = reset_tag((const void *)addr); > > - if (unlikely(untagged_addr < > > - kasan_shadow_to_mem((void *)KASAN_SHADOW_START))) { > > + if (unlikely(!addr_has_shadow(untagged_addr))) { > > kasan_report(addr, size, write, ret_ip); > > return; > > } > > > > -- > Andrew Donnellan OzLabs, ADL Canberra > andrew.donnellan@au1.ibm.com IBM Australia Limited > > -- > You received this message because you are subscribed to the Google Groups "kasan-dev" group. > To unsubscribe from this group and stop receiving emails from it, send an email to kasan-dev+unsubscribe@googlegroups.com. > To post to this group, send email to kasan-dev@googlegroups.com. > To view this discussion on the web visit https://groups.google.com/d/msgid/kasan-dev/f155a38b-c6ab-7825-71e2-15709f9410f6%40au1.ibm.com. > For more options, visit https://groups.google.com/d/optout.
diff --git a/mm/kasan/generic.c b/mm/kasan/generic.c index ccb6207276e3..ffc64a9a97a5 100644 --- a/mm/kasan/generic.c +++ b/mm/kasan/generic.c @@ -173,8 +173,7 @@ static __always_inline void check_memory_region_inline(unsigned long addr, if (unlikely(size == 0)) return; - if (unlikely((void *)addr < - kasan_shadow_to_mem((void *)KASAN_SHADOW_START))) { + if (unlikely(!addr_has_shadow((void *)addr))) { kasan_report(addr, size, write, ret_ip); return; } diff --git a/mm/kasan/tags.c b/mm/kasan/tags.c index 0777649e07c4..bc759f8f1c67 100644 --- a/mm/kasan/tags.c +++ b/mm/kasan/tags.c @@ -109,8 +109,7 @@ void check_memory_region(unsigned long addr, size_t size, bool write, return; untagged_addr = reset_tag((const void *)addr); - if (unlikely(untagged_addr < - kasan_shadow_to_mem((void *)KASAN_SHADOW_START))) { + if (unlikely(!addr_has_shadow(untagged_addr))) { kasan_report(addr, size, write, ret_ip); return; }
We have a couple of places checking for the existence of a shadow mapping for an address by open-coding the inverse of the check in addr_has_shadow. Replace the open-coded versions with the helper. This will be needed in future to allow architectures to override the layout of the shadow mapping. Signed-off-by: Daniel Axtens <dja@axtens.net> --- mm/kasan/generic.c | 3 +-- mm/kasan/tags.c | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-)