From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.0 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 553D2C43387 for ; Tue, 18 Dec 2018 20:55:04 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 2D69B218A2 for ; Tue, 18 Dec 2018 20:55:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727210AbeLRUzD (ORCPT ); Tue, 18 Dec 2018 15:55:03 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:60010 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726422AbeLRUzC (ORCPT ); Tue, 18 Dec 2018 15:55:02 -0500 Received: from akpm3.svl.corp.google.com (unknown [104.133.8.65]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 3F132EB5; Tue, 18 Dec 2018 20:54:54 +0000 (UTC) Date: Tue, 18 Dec 2018 12:54:53 -0800 From: Andrew Morton To: Andrey Konovalov 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 , Vincenzo Frascino , 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, Kostya Serebryany , Evgeniy Stepanov , Lee Smith , Ramana Radhakrishnan , Jacob Bramley , Ruben Ayrapetyan , Jann Horn , Mark Brand , Chintan Pandya , Vishwath Mohan Subject: Re: [PATCH mm] kasan, arm64: use ARCH_SLAB_MINALIGN instead of manual aligning Message-Id: <20181218125453.4c5e6c056d31ccaa3a73d4a5@linux-foundation.org> In-Reply-To: <706da77adfceb0c324e824d03b52d58a752577ea.1545139710.git.andreyknvl@google.com> References: <706da77adfceb0c324e824d03b52d58a752577ea.1545139710.git.andreyknvl@google.com> X-Mailer: Sylpheed 3.6.0 (GTK+ 2.24.31; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 18 Dec 2018 14:30:33 +0100 Andrey Konovalov wrote: > Instead of changing cache->align to be aligned to KASAN_SHADOW_SCALE_SIZE > in kasan_cache_create() we can reuse the ARCH_SLAB_MINALIGN macro. > > ... > > --- a/arch/arm64/include/asm/kasan.h > +++ b/arch/arm64/include/asm/kasan.h > @@ -36,6 +36,10 @@ > #define KASAN_SHADOW_OFFSET (KASAN_SHADOW_END - (1ULL << \ > (64 - KASAN_SHADOW_SCALE_SHIFT))) > > +#ifdef CONFIG_KASAN_SW_TAGS > +#define ARCH_SLAB_MINALIGN (1ULL << KASAN_SHADOW_SCALE_SHIFT) > +#endif > + > void kasan_init(void); > void kasan_copy_shadow(pgd_t *pgdir); > asmlinkage void kasan_early_init(void); This looks unreliable. include/linux/slab.h has /* * Setting ARCH_SLAB_MINALIGN in arch headers allows a different alignment. * Intended for arches that get misalignment faults even for 64 bit integer * aligned buffers. */ #ifndef ARCH_SLAB_MINALIGN #define ARCH_SLAB_MINALIGN __alignof__(unsigned long long) #endif so if a .c file includes arch/arm64/include/asm/kasan.h after include/linux/slab.h, it can get a macro-redefined warning. If the .c file includes those headers in the other order, ARCH_SLAB_MINALIGN will get a different value compared to other .c files. Or something like that. Different architectures define ARCH_SLAB_MINALIGN in different place: ./arch/microblaze/include/asm/page.h:#define ARCH_SLAB_MINALIGN L1_CACHE_BYTES ./arch/arm/include/asm/cache.h:#define ARCH_SLAB_MINALIGN 8 ./arch/sh/include/asm/page.h:#define ARCH_SLAB_MINALIGN 8 ./arch/c6x/include/asm/cache.h:#define ARCH_SLAB_MINALIGN L1_CACHE_BYTES ./arch/sparc/include/asm/cache.h:#define ARCH_SLAB_MINALIGN __alignof__(unsigned long long) ./arch/xtensa/include/asm/processor.h:#define ARCH_SLAB_MINALIGN STACK_ALIGN which is rather bad of us. But still. I think your definition should occur in an arch header file which is reliably included from slab.h. And kasan code should get its definition of ARCH_SLAB_MINALIGN by including slab.h.