Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751304AbeAPVDX (ORCPT + 1 other); Tue, 16 Jan 2018 16:03:23 -0500 Received: from bombadil.infradead.org ([65.50.211.133]:46901 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750796AbeAPVDU (ORCPT ); Tue, 16 Jan 2018 16:03:20 -0500 Date: Tue, 16 Jan 2018 13:03:13 -0800 From: Matthew Wilcox To: Christopher Lameter 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) Message-ID: <20180116210313.GA7791@bombadil.infradead.org> 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> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.9.1 (2017-09-22) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Return-Path: 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: struct kmem_cache_attr { char name[16]; unsigned int size; unsigned int align; + unsigned int useroffset; + unsigned int usersize; slab_flags_t flags; kmem_cache_ctor ctor; } 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. 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.