On Wed, Dec 03, 2025 at 12:04:41PM +0000, Miod Vallat wrote: > > > The definition of PAGE_SHIFT should not be limited to defined(_KERNEL); > > > this > > > prevents userland from getting a valid PAGE_SIZE definition by including > > > <machine/param.h>. > > > > Except ugh, noone should be pulling from sys/param.h for this. > > > > That's not a portable interface at all, it should find the page size at > > runtime by asking one of the layers on top of system calls. > > Agreed, but at the moment none of the other platforms prevented this to > work, so it's good from a consistency point of view.
More on that: the code includes sys/param.h only if available, and uses PAGE_SIZE only if defined, as a default value ; when _sodium_alloc_init() is called, the value from "sysconf(_SC_PAGESIZE)" is used. While a non-portable interface, its use looks careful in libsodium seems careful and should Do The Right Thing. -- jca
