Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp816526imm; Wed, 25 Jul 2018 06:45:25 -0700 (PDT) X-Google-Smtp-Source: AAOMgpeEPDwBR7pa/LvzP2R2of0f7KwdPMPQAKbK7I/WvY7lX09ykjSMFgnFFMyCErpPMzB9982B X-Received: by 2002:a62:fb05:: with SMTP id x5-v6mr22379219pfm.210.1532526325031; Wed, 25 Jul 2018 06:45:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532526325; cv=none; d=google.com; s=arc-20160816; b=UXCv0Sie32JNpZJyw0dt3QoOgX++wwbIQCB8P5LFpDQIqnoMuZaQzziCIhDleq3IPe 5k0lRcLfeZkPUf9LifVvkFbKf5AcgW8FMv6x/0amv8zKo6Y9ObyQJLVgf5Bqb67IKAb0 Hs+QhyhR2A788Hn7XX5BHB4nx4DyBKBMZRDNanP/+SkJs8+Wzb2ddc4t2TFX1iicpvTm zwG6AY8QRBKVnkPK46K+tqBf1YchuZ0UJNzF+8K59Uk1a3XxpGnVyFtCze5N0y/XEsZh qcxr+dXKpo7h9E46g+TSdTEx0LQ1qic0IaWpPCiS49nCpSrqams7Vhzmrsah9RKviBsa P05A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-language :content-transfer-encoding:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:arc-authentication-results; bh=BWCNTlzu+TQN+HWnSEWw9uJLXSqoinjNUopCzkzYYWQ=; b=DBBgBUGFG+NJIv3VRqbbV5CGYhcSKL0aOWyjednxhFF6nsruKR+lIFzlmH66tLL7g8 3dgH1SZ1zc5vY5uKC2GeLskzdPYCyRcHMb0kR1Sn+hwwUKexYQ5hOPlxh6UPO3e7J3/A XBQgOniiTZfxHQb1I0H8Sy1kw35feUagFeg53mpJSsrYBuhMlWBS3gPFUTnz6TzFyJH5 nP/NDY0WFJYPVc/81XqFfkTaaoQachbhAOXHtTbWgCdWdlIuOJSClhaooY+Y/E0+1g1M KNySOe4qWXYBe7NG84RYKcfCEMPpFgsrm/sFAZbeRcekvgKZ7YRic1k9yzeMVmwedwrX g3yQ== 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 p2-v6si13694477pgk.690.2018.07.25.06.45.09; Wed, 25 Jul 2018 06:45:24 -0700 (PDT) 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 S1729087AbeGYO4D (ORCPT + 99 others); Wed, 25 Jul 2018 10:56:03 -0400 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:38958 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728452AbeGYO4D (ORCPT ); Wed, 25 Jul 2018 10:56:03 -0400 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 2C0C915A2; Wed, 25 Jul 2018 06:44:18 -0700 (PDT) Received: from [10.4.12.117] (e107460-lin.Emea.Arm.com [10.4.12.117]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 514A23F6A8; Wed, 25 Jul 2018 06:44:12 -0700 (PDT) Subject: Re: [PATCH v4 13/17] khwasan: add hooks implementation 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: Chintan Pandya , Jacob Bramley , Jann Horn , Ruben Ayrapetyan , Lee Smith , Kostya Serebryany , Mark Brand , Ramana Radhakrishnan , Evgeniy Stepanov References: From: "Vincenzo Frascino@Foss" Message-ID: <09cb5553-d84a-0e62-5174-315c14b88833@arm.com> Date: Wed, 25 Jul 2018 14:44:10 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-US Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 06/26/2018 02:15 PM, Andrey Konovalov wrote: > @@ -325,18 +341,41 @@ void kasan_init_slab_obj(struct kmem_cache *cache, const void *object) > > void *kasan_slab_alloc(struct kmem_cache *cache, void *object, gfp_t flags) > { > - return kasan_kmalloc(cache, object, cache->object_size, flags); > + object = kasan_kmalloc(cache, object, cache->object_size, flags); > + if (IS_ENABLED(CONFIG_KASAN_HW) && unlikely(cache->ctor)) { > + /* > + * Cache constructor might use object's pointer value to > + * initialize some of its fields. > + */ > + cache->ctor(object); > This seams breaking the kmem_cache_create() contract: "The @ctor is run when new pages are allocated by the cache." (https://elixir.bootlin.com/linux/v3.7/source/mm/slab_common.c#L83) Since there might be preexisting code relying on it, this could lead to global side effects. Did you verify that this is not the case? Another concern is performance related if we consider this solution suitable for "near-production", since with the current implementation you call the ctor (where present) on an object multiple times and this ends up memsetting and repopulating the memory every time (i.e. inode.c: inode_init_once). Do you know what is the performance impact? -- Regards, Vincenzo