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 C60BB2E36F1 for ; Sat, 7 Feb 2026 21:07:10 +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=1770498430; cv=none; b=r8uhc5v54uALkxZ5OQ5ULwXmNWx849ZejrlFvkZolHxefRqVOtweVFs82i2Yq2PU8x01BQWb3JwNuddbJIgAMtCcC5gAvjE1mhlTeXi/7WOHEtDyGbN9srDkmcogVwxuTVNoYC2wgGfOxmT1hekh9F8mfGzdeAgNZhjpeieterM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770498430; c=relaxed/simple; bh=0bSHiqgsXcPMGO7h9HRetz2eaZotSlzI4oWZ7iypKh8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ZBENHoSMeZ6kVa/A4D7LE6dxtGDUa2F3aF7HMzSr5EV4Xm0cxq00OB5EFg28mCP7oZILf0xcY7P2dEdjU3c6kg0h4vSKinVy4o5Iswtc+wJD4lgPfmOXHPLKWAFkwC57vkf/Wk9eN1cZ2Q8wEcbKr+0hzdXKNa3TrrraTQvt5T4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=OJHzjzys; 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="OJHzjzys" Received: by smtp.kernel.org (Postfix) with ESMTPSA id C1241C116D0; Sat, 7 Feb 2026 21:07:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1770498430; bh=0bSHiqgsXcPMGO7h9HRetz2eaZotSlzI4oWZ7iypKh8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OJHzjzysExkYSM4Zv/OOoo9hEioX7rC8govT+jBXkvGPr+DzHy2NYZJu3klK+DOcM RERRLKSefnZnu4LI0jis+jqiSWUU5DDsFU0FaBfk2gb3ZnWM42eChGn9qEGzc/hkKJ lyCkvbNF+A6N3Ts/pb48syVS5Tvf7eaUJea+aM3zzC2RWhHcPZOOHPNA9I0OIterEj c7g2vR/mivW1Yas8j92WAXAVa7z8wAR0l8TfNnCEeWuPdm/AywRWqtkTOayEBCsmNm lNcaxI37E9kofV8QkMxXYZn8FfeDuCM4rqKd9yjvDE/G81emw6MPTbw912I1/V/rF8 j525fLXv/OoIA== From: Sasha Levin To: stable@vger.kernel.org Cc: Zhiquan Li , Sean Christopherson , Sasha Levin Subject: [PATCH 6.6.y] KVM: selftests: Add -U_FORTIFY_SOURCE to avoid some unpredictable test failures Date: Sat, 7 Feb 2026 16:07:08 -0500 Message-ID: <20260207210708.557817-1-sashal@kernel.org> X-Mailer: git-send-email 2.51.0 In-Reply-To: <2026020755-gratitude-opulently-9cf8@gregkh> References: <2026020755-gratitude-opulently-9cf8@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 a3bb36fb3cfc5..d819994874df1 100644 --- a/tools/testing/selftests/kvm/Makefile +++ b/tools/testing/selftests/kvm/Makefile @@ -212,6 +212,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\ + -U_FORTIFY_SOURCE \ -fno-builtin-memcmp -fno-builtin-memcpy -fno-builtin-memset \ -fno-builtin-strnlen \ -fno-stack-protector -fno-PIE -I$(LINUX_TOOL_INCLUDE) \ -- 2.51.0