Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3065041imu; Mon, 17 Dec 2018 12:39:12 -0800 (PST) X-Google-Smtp-Source: AFSGD/XnbiA5lTjLK615Uh6mxzL5KiD/ug4UAS5pI2vdy8UGLMFzRJN7aYu0NicluymefGCkYTJq X-Received: by 2002:a62:7796:: with SMTP id s144mr14041880pfc.26.1545079152788; Mon, 17 Dec 2018 12:39:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1545079152; cv=none; d=google.com; s=arc-20160816; b=Dm7EBQMBvm5Ngjm1WexXYlF9WtMNCCOVqPyxVXY9e1IU0rNv06PI/YrpNLUMxnVTBd 4SEkLlfTt6HbivpZeXFdayZ9L+47aZwqonyx93zpRjBBog3otHZ+FZ/6WdjsV9WOSTXS IKYduaUYXxGAfZLhAj9gG3Sq0/1hcgNIUhudBX+md8hvuocJgsH+gl6XkGAvrJ/Nt7xv L57FBbbPm78VudJmhKBM+KK2pQACOxl/KE0CqirC8k47Yet4lk874clayv3B6nyAfu1Z rRcfGOBvC17iTqMuDazGOxg7GOeJFfTtJqeS5JWP7A6Ysj8wR38M4VK31GcZNz1Fy8+0 YyLw== 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=zqAJ7CpVrClj01fc/bQYKz6q7wMWGbGap3pF5MFiebg=; b=G+PrPJ8PNEeAgTMAZSWH77bPDvStuSjx2KoD6+FpM2Ay3vrF06vciFUYwMaXdqvnuy BxDyH2Q+nxWAPlBg0T95grsr61a7k5y6h63V7UiPJz76K8O88KUhelSB/VrhuR6PDmYX eob1zJcD+IKL0TxeTwokkd/2U3pC4mPfJYLfduiyg2fQnUSG0gNY8CyszOUbAOwvkpzP R9nPEmynqfRs2l4VlNDf6ybL+WiTnRfYQP9emYaJ20W2OS3FifptHzKCXzuem+UyWRue 2I3bFjnf71NoIv04MRxx+ds+/JUQbAZXMnF7V1J2+SR5Af/HVgJyCa/Ralr5wieVvLSq y68g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=Vb6I7xDD; 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 g184si12011000pfb.288.2018.12.17.12.38.57; Mon, 17 Dec 2018 12:39:12 -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=Vb6I7xDD; 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 S2389273AbeLQTd4 (ORCPT + 99 others); Mon, 17 Dec 2018 14:33:56 -0500 Received: from mail-pg1-f196.google.com ([209.85.215.196]:34324 "EHLO mail-pg1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732980AbeLQTdz (ORCPT ); Mon, 17 Dec 2018 14:33:55 -0500 Received: by mail-pg1-f196.google.com with SMTP id j10so5383284pga.1 for ; Mon, 17 Dec 2018 11:33:54 -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=zqAJ7CpVrClj01fc/bQYKz6q7wMWGbGap3pF5MFiebg=; b=Vb6I7xDD+N84CKMrD7JqBKLThyRzVJstMpfI88sWi3C/amzPJqd++0eAjzjxfSGZ5p owoD9N9R8WxLP4KxFs670QbqMIUxys3LisKdvQQvPxDlpMliFOTnEFQQcf47kHzDZuIQ rERc8yBDh5MrMar07ymNZJvCxhAEKbYgH3GJqYmnBMcWQEg4r3NdJeEHc49AlzPM+U9F ln2jrtI/nxmIoBuaTB64cLW7lttBtPNESWQjnywIyeiO1IC0YaJcInXINJK4YTyrUT5k SKpUoB+RmGiwHonpgoXMWhSOjdhX8l4A0KPTOygwYVbEbsfq2kXKcJEDj4Ee9iYxXmeP x2ww== 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=zqAJ7CpVrClj01fc/bQYKz6q7wMWGbGap3pF5MFiebg=; b=UpsHvhJjpbV8B7ff6vuEURQjkfARGGRXr9j4e1fFoNILbmbBgieSMlsyQ/Gds+j+3e sRwjeWYqRaA2FweaS8/OG6mzPqpLNfUyuSz5YDCy0egeqQPlKxF03QxojSaDMND9RnuU Z2rcFfoGxxDB+U6nA9F8F0cWHQ8CLuZntrEe7Kumh3y3abrCykJH9uyiyZ9GKbQAMMgF EgzhvehuNbUZ7KkdykMbnecstadBQQj//UA1cGa7QbAIzLIh7WsklvBH8t10HRJpfugg Ox3ZCaJJYjyOG3qRDiSw7cwNEy1nX6/UAZLXcx55VW8aZ5A0kKcrsnk256a46hOzHhHB c+fQ== X-Gm-Message-State: AA+aEWaDtv7ptxcDa8snaCMwWIxUEmuicDvVQ7wxOlzoW1qcyIjNzb8h 3KwOa3jnj7BdMgrk1jwEx1fnshq+ue1uQ83/T1XtQQ== X-Received: by 2002:a63:7044:: with SMTP id a4mr12916378pgn.359.1545075233957; Mon, 17 Dec 2018 11:33:53 -0800 (PST) MIME-Version: 1.0 References: <2bf7415e-2724-b3c3-9571-20c8b6d43b92@arm.com> In-Reply-To: From: Andrey Konovalov Date: Mon, 17 Dec 2018 20:33:42 +0100 Message-ID: Subject: Re: [PATCH v13 19/25] kasan: add hooks implementation for tag-based mode To: Vincenzo Frascino , Andrew Morton Cc: Andrey Ryabinin , Alexander Potapenko , Dmitry Vyukov , Catalin Marinas , Will Deacon , Christoph Lameter , 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 Fri, Dec 14, 2018 at 1:34 PM Vincenzo Frascino wrote: > > On 12/12/18 3:04 PM, Andrey Konovalov wrote: > > 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? > > > > Yes, I think it is better because in this way we do not need to add extra code > to do the rounding. > > Curiosity, did you try your patches with SLUB red zoning enabled? > Since the area used for the Redzone is just after the payload, aligning the > object_size independently from the allocator could have side effects, at least > if I understand well how the mechanism works. > > Setting ARCH_SLAB_MINALIGN should avoid this as well. > > What do you think? Sounds good to me. Andrew, how should proceed with this? Send another fixup patch or resend the whole series? > > >> > >> -- > >> 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. > > -- > 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/b99b331d-22ca-b9db-8677-4896c427ef10%40arm.com. > For more options, visit https://groups.google.com/d/optout.