Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751434AbeAPSH4 (ORCPT + 1 other); Tue, 16 Jan 2018 13:07:56 -0500 Received: from resqmta-po-06v.sys.comcast.net ([96.114.154.165]:56948 "EHLO resqmta-po-06v.sys.comcast.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751028AbeAPSHx (ORCPT ); Tue, 16 Jan 2018 13:07:53 -0500 Date: Tue, 16 Jan 2018 12:07:49 -0600 (CST) From: Christopher Lameter X-X-Sender: cl@nuc-kabylake To: Matthew Wilcox cc: Kees Cook , linux-kernel@vger.kernel.org, David Windsor , Pekka Enberg , David Rientjes , Joonsoo Kim , Andrew Morton , linux-mm@kvack.org, linux-xfs@vger.kernel.org, Linus Torvalds , Alexander Viro , Andy Lutomirski , Christoph Hellwig , "David S. Miller" , Laura Abbott , Mark Rutland , "Martin K. Petersen" , Paolo Bonzini , Christian Borntraeger , Christoffer Dall , Dave Kleikamp , Jan Kara , Luis de Bethencourt , Marc Zyngier , Rik van Riel , Matthew Garrett , linux-fsdevel@vger.kernel.org, linux-arch@vger.kernel.org, netdev@vger.kernel.org, kernel-hardening@lists.openwall.com Subject: Re: kmem_cache_attr (was Re: [PATCH 04/36] usercopy: Prepare for usercopy whitelisting) In-Reply-To: <20180116174315.GA10461@bombadil.infradead.org> Message-ID: References: <1515531365-37423-1-git-send-email-keescook@chromium.org> <1515531365-37423-5-git-send-email-keescook@chromium.org> <20180114230719.GB32027@bombadil.infradead.org> <20180116160525.GF30073@bombadil.infradead.org> <20180116174315.GA10461@bombadil.infradead.org> User-Agent: Alpine 2.20 (DEB 67 2015-01-07) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-CMAE-Envelope: MS4wfKNyNTaLcw7nt5KcCCzh2N4E84ea/a1wHMf8YOfqkb5KeFzhmcurf9ecjsi3yqveNtoUnKSE90IsfgMxnJjnE01CTbMUgO1CX10NRTGtdcOB+NqH3a8c Fm6wCBdAYJ+O0HS9k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List: linux-kernel@vger.kernel.org Return-Path: On Tue, 16 Jan 2018, Matthew Wilcox wrote: > > Sure this data is never changed. It can be const. > > It's changed at initialisation. Look: > > kmem_cache_create(const char *name, size_t size, size_t align, > slab_flags_t flags, void (*ctor)(void *)) > s = create_cache(cache_name, size, size, > calculate_alignment(flags, align, size), > flags, ctor, NULL, NULL); > > The 'align' that ends up in s->align, is not the user-specified align. > It's also dependent on runtime information (cache_line_size()), so it > can't be calculated at compile time. Then we would need another align field in struct kmem_cache that takes the changes value? > 'flags' also gets mangled: > flags &= CACHE_CREATE_MASK; Well ok then that also belongs into kmem_cache and the original value stays in kmem_cache_attr. > unsigned int would be my preference. Great.