Re: [PATCH 7/8] x86/fpu: Pre-fault only required size of xstate buffer

From: Chang S. Bae

Date: Wed Sep 02 2026 - 17:23:16 EST


On 8/16/2026 9:20 PM, Andrei Vagin wrote:
The kernel previously used the default task FPU state size (user_size)
to fault in the user buffer when restoring FPU registers from a signal
frame. This can lead to attempting to fault in memory past the end of
the actual frame if the frame was smaller than the default size.

Introduce consistency checks to calculate the actual required size for
the features enabled in the xfeatures mask, ensure that the provided
xstate_size is sufficient, and shrink it to the actual required size.
Use this validated size to fault in the user buffer.

Keep the strict check that the provided xstate_size does not exceed the
default user_size for now.
I think this consistency check should have been there already. Thanks!

Reviewed-by: Chang S. Bae <chang.seok.bae@xxxxxxxxx>

Thanks,
Chang