Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753493AbeAQOqu (ORCPT + 1 other); Wed, 17 Jan 2018 09:46:50 -0500 Received: from resqmta-ch2-02v.sys.comcast.net ([69.252.207.34]:52114 "EHLO resqmta-ch2-02v.sys.comcast.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753361AbeAQOqq (ORCPT ); Wed, 17 Jan 2018 09:46:46 -0500 Date: Wed, 17 Jan 2018 08:46:41 -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: <20180116210313.GA7791@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> <20180116210313.GA7791@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: MS4wfNj6iYSahyxLtVi+zQbhovBqYTPb5uUbgUDVXYS5vy+FAGX+5aMhf4VNXoy0xFY2eJN9sxz9Gd0s9/KVU/SXsz6gNmLe1f5gVRrAH9vK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ner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Return-Path: On Tue, 16 Jan 2018, Matthew Wilcox wrote: > On Tue, Jan 16, 2018 at 12:17:01PM -0600, Christopher Lameter wrote: > > Draft patch of how the data structs could change. kmem_cache_attr is read > > only. > > Looks good. Although I would add Kees' user feature: Sure I tried to do this quickly so that the basic struct changes are visible. > And I'd start with > +struct kmem_cache *kmem_cache_create_attr(const kmem_cache_attr *); > > leaving the old kmem_cache_create to kmalloc a kmem_cache_attr and > initialise it. Well at some point we should convert the callers by putting the definitions into const kmem_cache_attr initializations. That way the callbacks function pointers are safe. > Can we also do something like this? > > -#define KMEM_CACHE(__struct, __flags) kmem_cache_create(#__struct,\ > - sizeof(struct __struct), __alignof__(struct __struct),\ > - (__flags), NULL) > +#define KMEM_CACHE(__struct, __flags) ({ \ > + const struct kmem_cache_attr kca ## __stringify(__struct) = { \ > + .name = #__struct, \ > + .size = sizeof(struct __struct), \ > + .align = __alignof__(struct __struct), \ > + .flags = (__flags), \ > + }; \ > + kmem_cache_create_attr(&kca ## __stringify(__struct)); \ > +}) > > That way we won't need to convert any of those users. Yep thats what I was planning.