From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=198.175.65.19 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796073556; b=rO2Rzxhprv4F0pUUo6McaGbTi8hu1ObUYRlJa55lR9B3w0YLeaZ1X/F/Ox+sC6f2eTtR n5jC0dn58dELqTjViCZ5EKT2FHJEg8U56NHRmV6SNNfyl7T8jLzZr7ZhNaP/EAfs/KuqQ WwoSTRXeRJAlwH8pwG6vtS8QoqiOkpQz+lGmFiHt60FIJhCL62vnu6pmFA6W+yLammQN1 LWp9/hjbaWHA9Q8ZYHpgXY9G8LwZMkP4bfFDu3NS/KuGuApGjO6xBS/ojv4LVFpqc+XeB cm0FxX9W/YSYHNxcn05S5+RzG5WTEx0OgFQKDyEFWcU+W8hH2C6O8lhSMdqVAqbAzWw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796073556; h=DMARC-Filter:DKIM-Signature:X-CSE-ConnectionGUID:X-CSE-MsgGUID: X-IronPort-AV:X-IronPort-AV:Received:X-CSE-ConnectionGUID: X-CSE-MsgGUID:X-ExtLoop1:X-IronPort-AV:Received:From:To:Cc:Subject: Date:Message-ID:X-Mailer:MIME-Version:Content-Type: Content-Transfer-Encoding; bh=GZrHqfmcUYkNVhs7gHUNcQjjhCeS6rxZd7+hxyTy3BI=; b=qtNchQ2SpRw4T5P3ZEnmcbIEcY6qB3N3w6YAS75yAJsVX7MFtuNOPHezkClwjeXKaoVv B7+sc7TFTAK9BZH3W5pCQMtHlcYKDtUgqUYPiEfctSOGTiB5jWtThPsrHCEbks7FeziLN Qqdztps8/BmjD+g+pv88qjah2SGireNEYQ94WFh60UA/CG8UOK+45T51t4iLnU3RwqPTA pwn9X9/Pp4UKCDqLc5ynsBhoZrzWBtXY9L5sPEkGzqBRig9e5ZqC7XdDCmhyUUiW0CvXZ H6Txvmg/ASW90SEOTMadfH7F8y0evJVIcVssiuVXRJw6JlDybtyELIjHlIWYV+HpSig== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=US6zdHKU; arc=none smtp.remote-ip=198.175.65.19 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.19]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F2ADF606A31A for ; Mon, 30 Nov 2026 21:19:14 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org F2ADF606A31A Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=US6zdHKU DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1796073555; x=1827609555; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=GZrHqfmcUYkNVhs7gHUNcQjjhCeS6rxZd7+hxyTy3BI=; b=US6zdHKUGsOOMASetllMKWlcC3u8T7bcnQufrC0kcH0qmzv+bSKUC2Zi JN8d+z2boBuJxn9EvTKSbiUoxvtp06i4Depd8F5SN6XokrhKdD6tLtmyY zQg0smElo+Tj9m4ntnxCCw3pro+F2x7m0XuCFMZDItJuWEGrsktQiBCzB sxQD803JjsBc6tXAfMJZs79/zyg6xGM/g3w2BX7VwbR1pCuaVZjKIuSLC dLfCuTTse2Caqy5Fz/wB8UdlB7zm6bbKo6pGUOzVoATw0REFqNBLLUcwz B3qRlZpD/iYu3JSog8INhYGs5GVvQayEXDsgRFZRVvCT0ZncyESG6J90Y Q==; X-CSE-ConnectionGUID: nJbHZre4Tc+jRubs5MwfpA== X-CSE-MsgGUID: t4FbW62qSu+hZNHeBbIkXA== X-IronPort-AV: E=McAfee;i="6800,10657,11982"; a="4989739" X-IronPort-AV: E=Sophos;i="6.27,243,1787036400"; d="scan'208";a="4989739" Received: from fmviesa005.fm.intel.com ([10.60.135.145]) by orvoesa111.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Nov 2026 13:19:12 -0800 X-CSE-ConnectionGUID: 3WK6dwxPTOWFCvL14nUuaw== X-CSE-MsgGUID: UTtc2DOsTFyfZ3YKfJg+mw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.27,243,1787036400"; d="scan'208";a="13166738" Received: from chang-linux-3.sc.intel.com (HELO chang-linux-3) ([172.25.66.174]) by fmviesa005.fm.intel.com with ESMTP; 30 Nov 2026 13:19:11 -0800 From: "Chang S. Bae" 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 Message-ID: <20261130205143.1258369-1-chang.seok.bae@intel.com> X-Mailer: git-send-email 2.53.0 X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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