mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Chang S. Bae" <chang.seok.bae@intel.com>
To: linux-kernel@vger.kernel.org
Cc: x86@kernel.org, tglx@kernel.org, mingo@redhat.com, bp@alien8.de,
	dave.hansen@linux.intel.com, weiguixiong@bytedance.com,
	omermetekaya0@gmail.com, chang.seok.bae@intel.com
Subject: [PATCH 0/6] x86/fpu: Fix issues around resetting fpstate
Date: Mon, 30 Nov 2026 20:51:36 +0000	[thread overview]
Message-ID: <20261130205143.1258369-1-chang.seok.bae@intel.com> (raw)

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


             reply	other threads:[~2026-11-30 21:19 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-30 20:51 Chang S. Bae [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261130205143.1258369-1-chang.seok.bae@intel.com \
    --to=chang.seok.bae@intel.com \
    --cc=bp@alien8.de \
    --cc=dave.hansen@linux.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=omermetekaya0@gmail.com \
    --cc=tglx@kernel.org \
    --cc=weiguixiong@bytedance.com \
    --cc=x86@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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®