Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp844378imu; Tue, 11 Dec 2018 08:24:45 -0800 (PST) X-Google-Smtp-Source: AFSGD/VImbESD9g8ruaiicCqk7nrSqXJkx7NZHRScjG7iByaBiMUrywDCZMrtNN3ILE8C/CX+N8r X-Received: by 2002:a65:4646:: with SMTP id k6mr14814830pgr.153.1544545485548; Tue, 11 Dec 2018 08:24:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544545485; cv=none; d=google.com; s=arc-20160816; b=wEzm125eftyqyET218QFs1/kzXCE7jETMX7R0mML+4JBRTxygnpN0kmbLXu2p3kAiy BW02DdiHJ1IFqY/JhXY4riSx7txR6XXvmOS0eXIfUK83rXr0BSpsdVhX8gGrzvoWIw96 Vbpp60on59uqtuU5fXghbV69mq/CtqY0/sIdJv+AalR3vjOtJMNBLPLmgAuTu7sl8tKb 6rQnnpydNa2buD7vIpBT3YtyDXyXnmSo2k+uUa9bYFVniuw4adrnDaxycsvhAj/OZEJ1 GAbsqdQGhYGeRuxap3F1bhpLR/lq5CwxLLXScaoJOXWbL77tMtYDEvt0sam+Izzf8fOJ Pksg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=nHRymrmsRQ9mmaouipaaFIgxUd9XJyVwAWyG6F7aw8U=; b=HpTknRX9kxwWCNyyuVB8iPoX0qcYnMZrBquRua669tk0Mcj2HeZwhPrV/JGZcsHnYM ex8EWKvGLw1vis7sJUOsYym/5dG2+izrW0NA+sRL9HZhJhVNL0UKkb5duFeHhriQgB3q QaCkjRvRlUJv2HcwpiRQIi+geB1+lEbXlBKOLupp07GqFDYN5ZkdsiQNTjxLCfct8Nqw mNeYCrUJVWhryJucHG7Ed2hGm4TJhWouivsMIclPqKEaHggXbQroSpNwnHf6hbTVWEga PAlW6jca2WQibN5/101/mX9xNIJhil8UJqpaJZICI1jC8Z0hxtrgB2/BeEgTDU/VqvhX I5cg== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a1si13693100pld.249.2018.12.11.08.24.30; Tue, 11 Dec 2018 08:24:45 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728138AbeLKQWy (ORCPT + 99 others); Tue, 11 Dec 2018 11:22:54 -0500 Received: from foss.arm.com ([217.140.101.70]:52176 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727686AbeLKQWw (ORCPT ); Tue, 11 Dec 2018 11:22:52 -0500 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 3D88D1596; Tue, 11 Dec 2018 08:22:51 -0800 (PST) Received: from [10.1.196.72] (e119884-lin.cambridge.arm.com [10.1.196.72]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 5F89F3F575; Tue, 11 Dec 2018 08:22:45 -0800 (PST) Subject: Re: [PATCH v13 19/25] kasan: add hooks implementation for tag-based mode To: Andrey Konovalov , 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@googlegroups.com, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-sparse@vger.kernel.org, linux-mm@kvack.org, linux-kbuild@vger.kernel.org Cc: Vishwath Mohan , Chintan Pandya , Jacob Bramley , Jann Horn , Ruben Ayrapetyan , Lee Smith , Kostya Serebryany , Mark Brand , Ramana Radhakrishnan , Evgeniy Stepanov References: From: Vincenzo Frascino Message-ID: <2bf7415e-2724-b3c3-9571-20c8b6d43b92@arm.com> Date: Tue, 11 Dec 2018 16:22:43 +0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.2.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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? -- Regards, Vincenzo