From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753029AbcEZBJA (ORCPT ); Wed, 25 May 2016 21:09:00 -0400 Received: from LGEAMRELO11.lge.com ([156.147.23.51]:49664 "EHLO lgeamrelo11.lge.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752761AbcEZBI7 (ORCPT ); Wed, 25 May 2016 21:08:59 -0400 X-Original-SENDERIP: 156.147.1.127 X-Original-MAILFROM: iamjoonsoo.kim@lge.com X-Original-SENDERIP: 10.177.222.138 X-Original-MAILFROM: iamjoonsoo.kim@lge.com Date: Thu, 26 May 2016 10:09:51 +0900 From: Joonsoo Kim To: Thomas Garnier Cc: Christoph Lameter , Pekka Enberg , David Rientjes , Andrew Morton , "Paul E . McKenney" , Pranith Kumar , David Howells , Tejun Heo , Johannes Weiner , David Woodhouse , Petr Mladek , Kees Cook , linux-mm@kvack.org, linux-kernel@vger.kernel.org, gthelen@google.com, kernel-hardening@lists.openwall.com Subject: Re: [RFC v2 1/2] mm: Reorganize SLAB freelist randomization Message-ID: <20160526010951.GC9302@js1304-P5Q-DELUXE> References: <1464124523-43051-1-git-send-email-thgarnie@google.com> <1464124523-43051-2-git-send-email-thgarnie@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1464124523-43051-2-git-send-email-thgarnie@google.com> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, May 24, 2016 at 02:15:22PM -0700, Thomas Garnier wrote: > This commit reorganizes the previous SLAB freelist randomization to > prepare for the SLUB implementation. It moves functions that will be > shared to slab_common. It also move the definition of freelist_idx_t in > the slab_def header so a similar type can be used for all common > functions. The entropy functions are changed to align with the SLUB > implementation, now using get_random_* functions. Could you explain more what's the difference between get_random_* and get_random_bytes_arch() and why this change is needed? And, I think that it should be another patch. > > Signed-off-by: Thomas Garnier > --- > Based on 0e01df100b6bf22a1de61b66657502a6454153c5 > --- > include/linux/slab_def.h | 11 +++++++- > mm/slab.c | 68 ++---------------------------------------------- > mm/slab.h | 16 ++++++++++++ > mm/slab_common.c | 48 ++++++++++++++++++++++++++++++++++ > 4 files changed, 76 insertions(+), 67 deletions(-) > > diff --git a/include/linux/slab_def.h b/include/linux/slab_def.h > index 8694f7a..e05a871 100644 > --- a/include/linux/slab_def.h > +++ b/include/linux/slab_def.h > @@ -3,6 +3,15 @@ > > #include > > +#define FREELIST_BYTE_INDEX (((PAGE_SIZE >> BITS_PER_BYTE) \ > + <= SLAB_OBJ_MIN_SIZE) ? 1 : 0) > + > +#if FREELIST_BYTE_INDEX > +typedef unsigned char freelist_idx_t; > +#else > +typedef unsigned short freelist_idx_t; > +#endif > + This is a SLAB specific index size definition and I don't want to export it to SLUB. Please use 'void *random_seq' and allocate sizeof(void *) memory for each entry. And, then do type casting when suffling in SLAB. There is some memory waste but not that much so we can tolerate it. Others look fine to me. Thanks.