Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp1949662imu; Wed, 12 Dec 2018 07:07:07 -0800 (PST) X-Google-Smtp-Source: AFSGD/V7fVJI/vqzU838/hhZLpM938uQ/BAc6BvjG/ZiERNOl4hbPiHZg7tLZOitA7zxTwld9e8J X-Received: by 2002:a17:902:a5ca:: with SMTP id t10mr20059312plq.139.1544627227044; Wed, 12 Dec 2018 07:07:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544627227; cv=none; d=google.com; s=arc-20160816; b=JbULLiH2Z5L6rU5PY9pEEUwvwHy4Xxtuwftw8zsQ3r5JZIulv3Yz2ESQA+a1OEdYlq btl007rhSHHtc7Px9HY3eI3HuCwmQlNsYZMKRYNjpewLsNYD3I9bWIzbZdSn1JqO1qRh 1+zV7z3VkMNqIe8uz065HLd1BxESmbo18uvmwno4ANaxBeoUuZUZoBgBm1visiHssult aXtbRhiVMMBjABbfNGkm857KOHvzWfNHDI0yBOvp3/JY2U8NxQBY2sV9y4z9OwdIhnNN 3X0f/NXsRF04n4BUzQWIedLq1YGimrKywos+AZkYtMIKgwoL0s8CGw8fkZEeuXEP9mQs wseA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=PpoxLeEWdCe6ZUeKoHp9WMUaj9WSDS7J7D+6g3Uf7k4=; b=XQbPmsrwHjamA2D0jYzDlcdjnzICDF3hQGDaailpjzY1LasvueUjB5/wfFBqpr/Hut pcplyNwZVpH1m+G+ga2I9OxA8w4oEoQQrTOSdHgpHvd3Qh1YUUpbQ7IRWAAU54+U69ET jJPRCFvjIq4+Va503IyOgHwOrPdgIkpnYgmPiW2TmSei+z08fNDoztR6kA4nhZ28+LPb IAPtGPDkuX5VvTelFDKf9Y6HcYlDPM4DDtJWWungnTyIHZBs0tNA+b6Ekcg/sF4HWv22 o0GYved3Eo86BsDpRJQdnazLcG2OTc/vp5QhcPJ5cMIYJ4kBHyfakl2EHczlMH2rFZdS b6tw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=nBiB1TTF; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k22si15261270pgl.29.2018.12.12.07.06.46; Wed, 12 Dec 2018 07:07:07 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=nBiB1TTF; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727765AbeLLPEd (ORCPT + 99 others); Wed, 12 Dec 2018 10:04:33 -0500 Received: from mail-it1-f171.google.com ([209.85.166.171]:51123 "EHLO mail-it1-f171.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727738AbeLLPEc (ORCPT ); Wed, 12 Dec 2018 10:04:32 -0500 Received: by mail-it1-f171.google.com with SMTP id z7so9475453iti.0 for ; Wed, 12 Dec 2018 07:04:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=PpoxLeEWdCe6ZUeKoHp9WMUaj9WSDS7J7D+6g3Uf7k4=; b=nBiB1TTFievXIyFZJ1GjOf7BR/ieJpcwr36DtE6EMtni+BLGACt3LH3GWi+q1azY5H 6ztQpGuF4Z1Ers5PB54/G1UVBEQOxjPYdD+Xl+0yrtTzxJ9X9qH9yFzuyQZExbq22Jj0 zyp6z+cPo5Td2P3g9Ie2aItdJm+qdepJejDvr1kM3CA26NsXWCZb2F8nVHV8LrKLDlKx 18+QNZKNBv95T/cjciFi8SHnxO9lereVW+tRg45xAEC5yC4RuYmybEGf4uRNJ+/ma360 nNHfTc8eQwM6p/MUReWygmFhEYH5Zvl0u85p3Gtr334RfpAyOPk5u1YJjehrpZC4O5EI CvLA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=PpoxLeEWdCe6ZUeKoHp9WMUaj9WSDS7J7D+6g3Uf7k4=; b=LA7yDQALTumUWwCIM6OemBv+Skuez7M6K//WgAasrACyNn8kkRLYEcCwQgyv6I4WuO olJM6kvuCeF565sYHnHQ1AgPVg/nJKYNhTrTfR7KuZjYls60fvRJwDaUII1PodEWFJ8A 8ve5Zbmk6T3BZF1I1jj3XXjck63t3CrsgXa29wmg8999vTySzHJejcg7RFsJyrvbDiat meVXcqLFJIwHoA04EorjjrxmbsPSXfFqJwMt49sK/73snR4H2GLh80ASF1Q1Q2GPVw/+ p5H21szEEgRI8LEoPGkp33n/3O9alTSq0yJnxBg8C/LXaNZefhG/0bHTeabFBCpf/2M5 rXiw== X-Gm-Message-State: AA+aEWZ+istPrUBEQtYXItctR7Y69QES5E4XG7q2NF9wK8OGR4neuB5I ffkyTWtdmbOldHs6X+j5k2WgvvdCQ5h1/zolsiAX8A== X-Received: by 2002:a02:88cf:: with SMTP id b15mr19921762jak.10.1544627071413; Wed, 12 Dec 2018 07:04:31 -0800 (PST) MIME-Version: 1.0 References: <2bf7415e-2724-b3c3-9571-20c8b6d43b92@arm.com> In-Reply-To: <2bf7415e-2724-b3c3-9571-20c8b6d43b92@arm.com> From: Andrey Konovalov Date: Wed, 12 Dec 2018 16:04:20 +0100 Message-ID: Subject: Re: [PATCH v13 19/25] kasan: add hooks implementation for tag-based mode To: Vincenzo Frascino Cc: Andrey Ryabinin , Alexander Potapenko , Dmitry Vyukov , Catalin Marinas , Will Deacon , Christoph Lameter , Andrew Morton , Mark Rutland , Nick Desaulniers , Marc Zyngier , Dave Martin , Ard Biesheuvel , "Eric W . Biederman" , Ingo Molnar , Paul Lawrence , Geert Uytterhoeven , Arnd Bergmann , "Kirill A. Shutemov" , Greg Kroah-Hartman , Kate Stewart , Mike Rapoport , kasan-dev , "open list:DOCUMENTATION" , LKML , Linux ARM , linux-sparse@vger.kernel.org, Linux Memory Management List , Linux Kbuild mailing list , Vishwath Mohan , Chintan Pandya , Jacob Bramley , Jann Horn , Ruben Ayrapetyan , Lee Smith , Kostya Serebryany , Mark Brand , Ramana Radhakrishnan , Evgenii Stepanov Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Dec 11, 2018 at 5:22 PM Vincenzo Frascino wrote: > > Hi Andrey, > > On 06/12/2018 12:24, Andrey Konovalov wrote: > > This commit adds tag-based KASAN specific hooks implementation and > > adjusts common generic and tag-based KASAN ones. > > > > 1. When a new slab cache is created, tag-based KASAN rounds up the size of > > the objects in this cache to KASAN_SHADOW_SCALE_SIZE (== 16). > > > > 2. On each kmalloc tag-based KASAN generates a random tag, sets the shadow > > memory, that corresponds to this object to this tag, and embeds this > > tag value into the top byte of the returned pointer. > > > > 3. On each kfree tag-based KASAN poisons the shadow memory with a random > > tag to allow detection of use-after-free bugs. > > > > The rest of the logic of the hook implementation is very much similar to > > the one provided by generic KASAN. Tag-based KASAN saves allocation and > > free stack metadata to the slab object the same way generic KASAN does. > > > > Reviewed-by: Andrey Ryabinin > > Reviewed-by: Dmitry Vyukov > > Signed-off-by: Andrey Konovalov > > --- > > mm/kasan/common.c | 116 ++++++++++++++++++++++++++++++++++++++-------- > > mm/kasan/kasan.h | 8 ++++ > > mm/kasan/tags.c | 48 +++++++++++++++++++ > > 3 files changed, 153 insertions(+), 19 deletions(-) > > > > > [...] > > > @@ -265,6 +290,8 @@ void kasan_cache_create(struct kmem_cache *cache, unsigned int *size, > > return; > > } > > > > + cache->align = round_up(cache->align, KASAN_SHADOW_SCALE_SIZE); > > + > > Did you consider to set ARCH_SLAB_MINALIGN instead of this round up? I didn't know about this macro. Looks like we can use it to do the same thing. Do you think it's a better solution to redefine ARCH_SLAB_MINALIGN to KASAN_SHADOW_SCALE_SIZE for arm64 when tag-based KASAN is enabled instead of adjusting cache->align in kasan_cache_create? > > -- > Regards, > Vincenzo > > -- > 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/2bf7415e-2724-b3c3-9571-20c8b6d43b92%40arm.com. > For more options, visit https://groups.google.com/d/optout.