Skip to contentSkip to conversation

mm/slab_common.c: fix possible spectre-v1 in kmalloc_slab()

PATCH Alexey Dobriyan 2 participants 2 messages May 29, 2019 – May 30, 2019

lore
Share & tools
lore
#0 lore raw

Review

Quoted 5 lines

I think it makes more sense to sanitize size in size_index_elem(), don't you?

(quoted diff) +1 -1
-	return (bytes - 1) / 8;
+	return array_index_nospec((bytes - 1) / 8, ARRAY_SIZE(size_index));

I think it should be fixed in poll.
Literally every small variable kmalloc call is going through this function.

#1 lore raw
Quoted 8 lines · Alexey Dobriyan

Review

Quoted 5 lines

I think it makes more sense to sanitize size in size_index_elem(), don't you?

(quoted diff) +1 -1
-	return (bytes - 1) / 8;
+	return array_index_nospec((bytes - 1) / 8, ARRAY_SIZE(size_index));

I think it should be fixed in poll.
Literally every small variable kmalloc call is going through this function.

We could do that too, but don't we then have to audit every ioctl and similar to see if there's a k(v)malloc based on a size passed from userspace?