CVSROOT:        /cvs
Module name:    src
Changes by:     bl...@cvs.openbsd.org   2025/05/09 08:53:22

Modified files:
        sys/kern       : kern_sysctl.c 

Log message:
Clear and fill memory within same mutex block.

When sysctl(2) copies a struct to userland, memset() the storage
to zero before filling the fields to avoid kernel stack information
leakage.  Both memset() and field assignment should be covered by
the same mutex.  Although clearing stack does not need mutex
protection, the compiler or processor may optimize away unnecessary
store operations.  A mtx_enter() between them would act as a barrier
and prevent this optimization.

OK tedu@ deraadt@

Reply via email to