Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1407674
| From | Thomas Garnier <thgarnie@google.com> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | Re: [RFC v2 1/2] mm: Reorganize SLAB freelist randomization |
| Date | 2016-05-26 21:00 +0200 |
| Message-ID | <rD8FI-1wa-45@gated-at.bofh.it> (permalink) |
| References | <rCrU6-cB-13@gated-at.bofh.it> <rCrU6-cB-21@gated-at.bofh.it> <rCRYd-87B-1@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
On Wed, May 25, 2016 at 6:09 PM, Joonsoo Kim <iamjoonsoo.kim@lge.com> wrote: > 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. > Sure. From my test (limited scenario), get_random_bytes_arch was much slower than get_random_int when the random instructions were not available. It also seems from looking at both implementation that get_random_int may provide a bit more entropy at this early stage. >> >> Signed-off-by: Thomas Garnier <thgarnie@google.com> >> --- >> 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 <linux/reciprocal_div.h> >> >> +#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. > Ok, will do. Thanks. > Thanks. >
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[RFC v2 0/2] mm: SLUB Freelist randomization Thomas Garnier <thgarnie@google.com> - 2016-05-24 23:20 +0200
[RFC v2 1/2] mm: Reorganize SLAB freelist randomization Thomas Garnier <thgarnie@google.com> - 2016-05-24 23:20 +0200
Re: [RFC v2 1/2] mm: Reorganize SLAB freelist randomization Joonsoo Kim <iamjoonsoo.kim@lge.com> - 2016-05-26 03:10 +0200
Re: [RFC v2 1/2] mm: Reorganize SLAB freelist randomization Thomas Garnier <thgarnie@google.com> - 2016-05-26 21:00 +0200
[RFC v2 2/2] mm: SLUB Freelist randomization Thomas Garnier <thgarnie@google.com> - 2016-05-24 23:20 +0200
Re: [RFC v2 2/2] mm: SLUB Freelist randomization Kees Cook <keescook@chromium.org> - 2016-05-26 00:30 +0200
Re: [RFC v2 2/2] mm: SLUB Freelist randomization Thomas Garnier <thgarnie@google.com> - 2016-05-26 20:40 +0200
Re: [RFC v2 2/2] mm: SLUB Freelist randomization Joonsoo Kim <js1304@gmail.com> - 2016-05-26 03:50 +0200
Re: [RFC v2 2/2] mm: SLUB Freelist randomization Thomas Garnier <thgarnie@google.com> - 2016-05-26 20:50 +0200
csiph-web