Message ID | 20240619154530.163232-1-iii@linux.ibm.com (mailing list archive) |
---|---|
Headers | show |
Series | kmsan: Enable on s390 | expand |
On Wed, Jun 19, 2024 at 5:45 PM Ilya Leoshkevich <iii@linux.ibm.com> wrote: > > Add a wrapper for memset() that prevents unpoisoning. This is useful > for filling memory allocator redzones. > > Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com> Reviewed-by: Alexander Potapenko <glider@google.com> > --- > include/linux/kmsan.h | 13 +++++++++++++ > 1 file changed, 13 insertions(+) > > diff --git a/include/linux/kmsan.h b/include/linux/kmsan.h > index 23de1b3d6aee..5f50885f2023 100644 > --- a/include/linux/kmsan.h > +++ b/include/linux/kmsan.h > @@ -255,6 +255,14 @@ void kmsan_enable_current(void); > */ > void kmsan_disable_current(void); > > +/* > + * memset_no_sanitize_memory(): memset() without KMSAN instrumentation. > + */ Please make this a doc comment, like in the rest of the file. (Please also fix kmsan_enable_current/kmsan_disable_current in the respective patch)
On Wed, Jun 19, 2024 at 5:45 PM Ilya Leoshkevich <iii@linux.ibm.com> wrote: > > Avoid false KMSAN negatives with SLUB_DEBUG by allowing > kmsan_slab_free() to poison the freed memory, and by preventing > init_object() from unpoisoning new allocations by using __memset(). > > There are two alternatives to this approach. First, init_object() > can be marked with __no_sanitize_memory. This annotation should be used > with great care, because it drops all instrumentation from the > function, and any shadow writes will be lost. Even though this is not a > concern with the current init_object() implementation, this may change > in the future. > > Second, kmsan_poison_memory() calls may be added after memset() calls. > The downside is that init_object() is called from > free_debug_processing(), in which case poisoning will erase the > distinction between simply uninitialized memory and UAF. > > Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com> Reviewed-by: Alexander Potapenko <glider@google.com>