Messages in this thread Patch in this message | | | From | Dianzhang Chen <> | Date | Thu, 30 May 2019 00:39:53 +0800 | Subject | Re: [PATCH] mm/slab_common.c: fix possible spectre-v1 in kmalloc_slab() |
| |
It's come from `192+1`.
The more code fragment is:
if (size <= 192) {
if (!size)
return ZERO_SIZE_PTR;
size = array_index_nospec(size, 193);
index = size_index[size_index_elem(size)];
}
Sine array_index_nospec(index, size) can clamp the index within the range of [0, size), so in order to make the `size<=192`, need to clamp the index in the range of [0, 192+1) .
On Thu, May 30, 2019 at 12:25 AM Michal Hocko <mhocko@kernel.org> wrote: > > On Wed 29-05-19 20:37:28, Dianzhang Chen wrote: > [...] > > @@ -1056,6 +1057,7 @@ struct kmem_cache *kmalloc_slab(size_t size, gfp_t flags) > > if (!size) > > return ZERO_SIZE_PTR; > > > > + size = array_index_nospec(size, 193); > > index = size_index[size_index_elem(size)]; > > What is this 193 magic number? > -- > Michal Hocko > SUSE Labs
| |