mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 0/6] x86/fpu: Fix issues around resetting fpstate
@ 2026-11-30 20:51 Chang S. Bae
  2026-11-30 20:51 ` [PATCH 1/6] x86/fpu: Remove remaining fpstate reset for init_task Chang S. Bae
                   ` (5 more replies)
  0 siblings, 6 replies; 8+ messages in thread
From: Chang S. Bae @ 2026-11-30 20:51 UTC (permalink / raw)
  To: linux-kernel
  Cc: x86, tglx, mingo, bp, dave.hansen, weiguixiong, omermetekaya0,
	chang.seok.bae

Hi all,

This series addresses a couple of issues in fpu_flush_thread():

  Guixiong first reported and posted a patch [1] to address the memory
  leak on the exec() path. When TILE_DATA is active, the fpstate storage
  is expanded to record the large state. Then an exec() will reset the
  current fpstate entirely. But the issue there is not free up the
  reallocated fpstate memory - addressed in patch5 and test case in patch6.

  While working on this, syzbot reported another issue [2,3] on this path
  for resetting fpstate without fpregs_lock(). There is a race condition.
  Patch3 has the fix.

Then a couple of follow-up on that:

  Right now fpu_reset_fpstate_regs() is called on the exec() path only
  but it holds the lock just for the register storage. Including the
  metadata reset, as per Dave's suggestion, makes the same code sequence
  as in fpu_clone(). Similarily fpstate free code could be restructured.
  So, the series ends up including some refactoring (patch2/4).

  Finally, while looking at the fpstate_reset() sites, a removable one
  was also found, so include the minor fix as well (patch1).

Cc'ed stable@ since those refactoring if bought will change the base
where the fixes are applied.

[1]: https://lore.kernel.org/20260929151013.81562-2-weiguixiong@bytedance.com
[2]: https://syzkaller.appspot.com/bug?extid=58cbd7974a103b8b8916
[3]: https://syzkaller.appspot.com/bug?extid=b07ec23d35be305855be

Thanks,
Chang

Chang S. Bae (6):
  x86/fpu: Remove remaining fpstate reset for init_task
  x86/fpu: Refactor fpstate storage reset sequence
  x86/fpu: Reset the fpstate on exec() under fpregs_lock()
  x86/fpu: Refactor fpstate memory free helpers
  x86/fpu: Fix memory leak with dynamic fpstate and exec()
  selftests/x86/amx: Test fpstate memory cleanup on exec()

 arch/x86/include/asm/fpu/api.h          |   6 +-
 arch/x86/kernel/fpu/core.c              | 111 +++++++++++++++---------
 arch/x86/kernel/fpu/xstate.c            |  19 ++--
 arch/x86/kernel/process.c               |   2 +-
 tools/testing/selftests/x86/Makefile    |   1 +
 tools/testing/selftests/x86/amx.c       |  51 ++++++++++-
 tools/testing/selftests/x86/amx_exec.sh |  87 +++++++++++++++++++
 7 files changed, 223 insertions(+), 54 deletions(-)
 create mode 100755 tools/testing/selftests/x86/amx_exec.sh


base-commit: 75b8262a97abcb972ef897dad5f94d425157b635
-- 
2.53.0


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2026-11-30 21:33 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-30 20:51 [PATCH 0/6] x86/fpu: Fix issues around resetting fpstate Chang S. Bae
2026-11-30 20:51 ` [PATCH 1/6] x86/fpu: Remove remaining fpstate reset for init_task Chang S. Bae
2026-11-30 20:51 ` [PATCH 2/6] x86/fpu: Refactor fpstate storage reset sequence Chang S. Bae
2026-11-30 20:51 ` [PATCH 3/6] x86/fpu: Reset the fpstate on exec() under fpregs_lock() Chang S. Bae
2026-11-30 20:51 ` [PATCH 4/6] x86/fpu: Refactor fpstate memory free helpers Chang S. Bae
2026-11-30 20:51 ` [PATCH 5/6] x86/fpu: Fix memory leak with dynamic fpstate and exec() Chang S. Bae
2026-11-30 20:51 ` [PATCH 6/6] selftests/x86/amx: Test fpstate memory cleanup on exec() Chang S. Bae
2026-11-30 21:33   ` Chang S. Bae

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®