[PATCH net-next] calipso: hash the cache key, not the option start, in calipso_cache_add()
Daniel Machon
daniel.machon at microchip.com
Fri Oct 9 11:42:03 UTC 2026
> calipso_cache_add() stores calipso_ptr + 2 as the cache key, but
> computes entry->hash over calipso_ptr, i.e. starting two bytes earlier
> at the option type and length. calipso_opt_getattr() looks entries up
> with calipso_cache_check(calipso + 2, calipso[1], ...), which hashes the
> key itself.
>
> The two hashes only match on a jhash collision, so the CALIPSO label
> cache never hits and every labelled packet takes the full DOI lookup and
> category conversion path. The memcmp() on the key keeps lookups
> correct, so this is a performance bug only.
>
> Hash the stored key, as cipso_v4_cache_add() does for CIPSO.
FWIW:
I tested this with a small throwaway KUnit test: put 16 labels into the cache,
then look each one up again the same way the kernel does when a packet arrives.
Without the patch none of them were found (0/16), with it all of them were
(16/16).
Reviewed-by: Daniel Machon <daniel.machon at microchip.com>
More information about the Linux-security-module-archive
mailing list