From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EAD172F49F4 for ; Sat, 7 Feb 2026 20:28:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770496082; cv=none; b=G6lxcck9YCSh6foYHwUayLQHfrl2gmO6cF2tzYec7zX7ebV3MehHqyAAScep7jerRu/1z63aSNWUxCpNzWQWmF6SGXov6hKhaOFKQtzgdQMOkbqDMTUiSGTOGbxNsqqbI3MwRfy/Vp0tT4ng1N/75t5X58dd5ymf8hZfV4IhGp4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770496082; c=relaxed/simple; bh=VnPXfTNbx6UJqt3AIpBm5SQFeSXUhTpD3GZPbguSv/k=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=sKXE23PdoYuQy3rUB+5i5a/r3+MIp5hy+s1MzgZwxJPfyB458/L5zYOZIM3vQphQDEApPDrccmbCyLZOHSzUlwWoDJv0yLsFndAL3qHaR3D93pdlA0/+TbLyAjaE3kGPhgdKdHroU382bX2jWKpIW086fvi97yArHs1EkEVd2Wg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=XLKGuSbb; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="XLKGuSbb" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 057D2C116D0; Sat, 7 Feb 2026 20:28:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1770496081; bh=VnPXfTNbx6UJqt3AIpBm5SQFeSXUhTpD3GZPbguSv/k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XLKGuSbbEc2NpVQG+Axh26nDqEgXTUZs/yqkltQu6e8FavpUVvLqJjREB/ZIAuc9b uSRCg2QATx5wDipbK0v89GY86BACyLcfVNet2c/BAn/g6mzO7vgHl4FD91JQKQineM sYE0sDOZTYpQ0BB+CeZlFqyPfKA+QLiIWDLcEABU126QxIxKksBYm/k86iWbyVo2t5 q69gwCHFlV5IFXjnWET3zdr0aQZkYvCxri4nnL7SmW4e2NkbiGeYNHJuRCTj7Vv8h9 kSlVgNv5VXIxY76kKLt9w+li/rOyHJos4hZOrJEnSTXipV+xBgMzhWWv0bfxdLFd0v XmdUWfVy2Y4ZQ== From: Sasha Levin To: stable@vger.kernel.org Cc: Zhiquan Li , Sean Christopherson , Sasha Levin Subject: [PATCH 6.12.y] KVM: selftests: Add -U_FORTIFY_SOURCE to avoid some unpredictable test failures Date: Sat, 7 Feb 2026 15:27:59 -0500 Message-ID: <20260207202759.545635-1-sashal@kernel.org> X-Mailer: git-send-email 2.51.0 In-Reply-To: <2026020754-payback-platonic-6ee5@gregkh> References: <2026020754-payback-platonic-6ee5@gregkh> Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Zhiquan Li [ Upstream commit e396a74222654486d6ab45dca5d0c54c408b8b91 ] Some distributions (such as Ubuntu) configure GCC so that _FORTIFY_SOURCE is automatically enabled at -O1 or above. This results in some fortified version of definitions of standard library functions are included. While linker resolves the symbols, the fortified versions might override the definitions in lib/string_override.c and reference to those PLT entries in GLIBC. This is not a problem for the code in host, but it is a disaster for the guest code. E.g., if build and run x86/nested_emulation_test on Ubuntu 24.04 will encounter a L1 #PF due to memset() reference to __memset_chk@plt. The option -fno-builtin-memset is not helpful here, because those fortified versions are not built-in but some definitions which are included by header, they are for different intentions. In order to eliminate the unpredictable behaviors may vary depending on the linker and platform, add the "-U_FORTIFY_SOURCE" into CFLAGS to prevent from introducing the fortified definitions. Signed-off-by: Zhiquan Li Link: https://patch.msgid.link/20260122053551.548229-1-zhiquan_li@163.com Fixes: 6b6f71484bf4 ("KVM: selftests: Implement memcmp(), memcpy(), and memset() for guest use") Cc: stable@vger.kernel.org [sean: tag for stable] Signed-off-by: Sean Christopherson [ Makefile.kvm -> Makefile ] Signed-off-by: Sasha Levin --- tools/testing/selftests/kvm/Makefile | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/testing/selftests/kvm/Makefile b/tools/testing/selftests/kvm/Makefile index 48645a2e29da9..9d6fab359ae3c 100644 --- a/tools/testing/selftests/kvm/Makefile +++ b/tools/testing/selftests/kvm/Makefile @@ -239,6 +239,7 @@ LINUX_TOOL_ARCH_INCLUDE = $(top_srcdir)/tools/arch/$(ARCH)/include endif CFLAGS += -Wall -Wstrict-prototypes -Wuninitialized -O2 -g -std=gnu99 \ -Wno-gnu-variable-sized-type-not-at-end -MD -MP -DCONFIG_64BIT \ + -U_FORTIFY_SOURCE \ -fno-builtin-memcmp -fno-builtin-memcpy \ -fno-builtin-memset -fno-builtin-strnlen \ -fno-stack-protector -fno-PIE -fno-strict-aliasing \ -- 2.51.0