From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (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 C527C420485 for ; Tue, 18 Aug 2026 08:54:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787043249; cv=none; b=rNEcbu6zjyiUoLiYIS2TS7nCk2A5GH2Ih8nNqWi3Fk5YY0kjj5IX/bmLl0Zb3dJI7rQ7kT7sKxki+vFwHycHT6jd73WV/1OXvrSy9Uw5cOY76JCJJStNLU6fJZB3z+XK19XT1V5Umo2Due9fXAgepdlkIdFSvcYgp/qFIGPGjn8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787043249; c=relaxed/simple; bh=BRBqclakuJSrqoUrzNR923rzUiJVaD/pyI7+lgPChmU=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=SDSRNPa3MdOGgKqnESRl986stMlkESpN1FLGplxaE2QOfS8UD3QttCazfQGh6NUqa1t9G2o7VwCVCBSME5rUTFWXaaxX6alAw25Rdge6WUG6e6DBjJpUAnL7+Gs1xCyo+7kxb4bgNwWMZ2rQBVUXiAAM1W6x1bppTs+s7IhxeLs= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=jNRx9QyV; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b=iicnHPxN; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="jNRx9QyV"; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b="iicnHPxN" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1787043246; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:autocrypt:autocrypt; bh=CMJnkJ88VUdXuXfoihnWNaJTjZl0nlhmsfAU8nGEPNI=; b=jNRx9QyVWaTRZKo6lJoj09sS64AxqQerMmUMpMrRUv0VisAm7/vhxsJrqK+YW7OF6v7SPG ZPCNoqWfCOLNUZ+gzkAqnG77ryiXMGDQQ/MC4DckekdoK6joK+xsH+TVD2CP43AOinXe0q UylbxQQGDkwXGR3Dg5ik4ydoQVIlkBI= Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-528-cKmBlQjxP620JLN7V3c9MQ-1; Tue, 18 Aug 2026 04:53:59 -0400 X-MC-Unique: cKmBlQjxP620JLN7V3c9MQ-1 X-Mimecast-MFC-AGG-ID: cKmBlQjxP620JLN7V3c9MQ_1787043238 Received: by mail-wm1-f69.google.com with SMTP id 5b1f17b1804b1-4955e865174so22977285e9.3 for ; Tue, 18 Aug 2026 01:53:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1787043238; x=1787648038; darn=vger.kernel.org; h=content-transfer-encoding:content-type:in-reply-to:autocrypt:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:from:to:cc:subject:date:message-id:reply-to :content-type; bh=CMJnkJ88VUdXuXfoihnWNaJTjZl0nlhmsfAU8nGEPNI=; b=iicnHPxNhdaGxlIR7Qa+Y7qCy1bCQeVb6qpYIYg5jo/YTRAAbqPINg+POMw+120v2O bVO1AekAKE6cuGBckRvHDDzePJ1LLlOztsqSWB15SNi6r2ErIw84o/WgjHEyxAXVhqwk X+HYndkx+2Bw3U63ISs6FQarTbYi22zAx9pFEbf6jgVz5uGYzVnyNOxK7mxtAIxXMbw4 BkXZfWebGzXx/rgivel0rPqv/G8y3e+T8F/xWTjHO/Pcsfs0YmlH2tePNXYQICkVjCqI idewi7kvTrJljmSU0cItHukWE2LPMhWjzNcsDok1gGPKMGpsdLiGZiF0Hdj9/n4AlldL ll1w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1787043238; x=1787648038; h=content-transfer-encoding:content-type:in-reply-to:autocrypt:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=CMJnkJ88VUdXuXfoihnWNaJTjZl0nlhmsfAU8nGEPNI=; b=ZNMBknirvEjnI+GG+pcPE46VXAdncO8c00SZGEKoAxT43tSlSHGrdND5L1GU5dzxi4 RekKweQhcF38X2P41tVIjcLQHD3i9LyiFT73GTkPFCgcCqGfT7i86q9Klt8PMfPu/oH4 bvFzga7sFZyyt+lsZqKcJX1Nn0Nwcid+6Rb/EAOZBGfJYpy2zb/NCrQqeq15bOFp/Ipt 8jdoq4zSiNikIVB4RKyTF9wxtb3GsGFG6fDaS1ETV5xVqONU4tnECmFP0AepqE7x0HMM xEfUtHVAGLNLNaAzbkG4G3c70iZ2vmevorM8p/NqtXFMPGJXDlah/JuGR7kpAezdVbY/ i5dg== X-Forwarded-Encrypted: i=1; AHgh+RpSpbx3FHMTU2iAuMGL81ycP/3O5PGm/CmMyCnmVxnFbL/izlrfbN5vdtRdYyO1ixzEx1xSOnePkBwLcSA=@vger.kernel.org X-Gm-Message-State: AOJu0Yy/bkHC53Af3FfVYaJ7F3rHK8CWQpg6XF7cRoODk1khZdtebx1K 8M74NjGT3xrFcBIfyWvzo/RMeDeC9zPxQrYsl5LKwvNQGrGq7WbFk4N3DmuUYLrYssCXuVI4EMO xi+nvIohiyLkdEFNU3dIZ8krmIhsh7OcHs+NONCV1oxQ4hrgjSywxFyb2HO90P3MG2Q== X-Gm-Gg: AR+sD11JEN/vyYJcipnPvqHQLdwXBR568qKEUnzQgjUDClyn5VlZrD69n70k5Qm0S82 nCckyzMa8oJy5yHu0gHKW3VorKdQnbQ+fPXUCe1VjtBUHs54Xzxr6LGCflSGDuhVbQFndMoKKQ2 YKLUu/UDIukMNkuFeuE23EzlH3wTC+w+v6MHVDmY7DswMgBZKsdUNOCCYbh6fJ1jnCz9OOognH1 pUzEoNN9mPnKrTIk7srPMoSksrqhAYJ/QZtccubs3XWksbJM0uhRujJt8YYwYhwiModd8Fl7aLw Fs7RSxOJFrWhFXOXeWuuD8SJ46n6xK4DZx4lZmri0gtZLfAvZ6dWToRHVrw4dO18b23w6Zk= X-Received: by 2002:a05:600c:4e56:b0:499:a69d:e14b with SMTP id 5b1f17b1804b1-499a69de2fbmr12309645e9.4.1787043237828; Tue, 18 Aug 2026 01:53:57 -0700 (PDT) X-Received: by 2002:a05:600c:4e56:b0:499:a69d:e14b with SMTP id 5b1f17b1804b1-499a69de2fbmr12309405e9.4.1787043237494; Tue, 18 Aug 2026 01:53:57 -0700 (PDT) Received: from [10.22.3.81] ([91.26.127.10]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4999d10be27sm141261325e9.14.2026.08.18.01.53.54 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 18 Aug 2026 01:53:55 -0700 (PDT) Message-ID: <7d373eca-c23c-4f79-9391-29d75bd5a53f@redhat.com> Date: Tue, 18 Aug 2026 10:53:53 +0200 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 10/11] x86/purgatory: Compile purgatory.c with -D__NO_FORTIFY To: Borislav Petkov Cc: Eric Biggers , "Jason A. Donenfeld" , Ard Biesheuvel , Thomas Gleixner , Ingo Molnar , Dave Hansen , x86@kernel.org, Herbert Xu , "David S. Miller" , linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org, "H. Peter Anvin" References: <20260813134953.979481-1-thuth@redhat.com> <20260813134953.979481-11-thuth@redhat.com> <20260814152457.GBan8zSeYlWd_1oWkz@fat_crate.local> Content-Language: en-US From: Thomas Huth Autocrypt: addr=thuth@redhat.com; keydata= xsFNBFH7eUwBEACzyOXKU+5Pcs6wNpKzrlJwzRl3VGZt95VCdb+FgoU9g11m7FWcOafrVRwU yYkTm9+7zBUc0sW5AuPGR/dp3pSLX/yFWsA/UB4nJsHqgDvDU7BImSeiTrnpMOTXb7Arw2a2 4CflIyFqjCpfDM4MuTmzTjXq4Uov1giGE9X6viNo1pxyEpd7PanlKNnf4PqEQp06X4IgUacW tSGj6Gcns1bCuHV8OPWLkf4hkRnu8hdL6i60Yxz4E6TqlrpxsfYwLXgEeswPHOA6Mn4Cso9O 0lewVYfFfsmokfAVMKWzOl1Sr0KGI5T9CpmRfAiSHpthhHWnECcJFwl72NTi6kUcUzG4se81 O6n9d/kTj7pzTmBdfwuOZ0YUSqcqs0W+l1NcASSYZQaDoD3/SLk+nqVeCBB4OnYOGhgmIHNW 0CwMRO/GK+20alxzk//V9GmIM2ACElbfF8+Uug3pqiHkVnKqM7W9/S1NH2qmxB6zMiJUHlTH gnVeZX0dgH27mzstcF786uPcdEqS0KJuxh2kk5IvUSL3Qn3ZgmgdxBMyCPciD/1cb7/Ahazr 3ThHQXSHXkH/aDXdfLsKVuwDzHLVSkdSnZdt5HHh75/NFHxwaTlydgfHmFFwodK8y/TjyiGZ zg2Kje38xnz8zKn9iesFBCcONXS7txENTzX0z80WKBhK+XSFJwARA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IC//DCOxzQNFNJAKldPe/bKZMCxEqtVoRkuJtNdp/5a yXFZ6TfE1hGKrDBYAm4vrnZ4CXFSBDllL59cFFOJCkn4Xboj/aVxxJxF30bn In-Reply-To: <20260814152457.GBan8zSeYlWd_1oWkz@fat_crate.local> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 14/08/2026 17.24, Borislav Petkov wrote: > On Thu, Aug 13, 2026 at 03:49:48PM +0200, Thomas Huth wrote: >> From: Thomas Huth >> >> purgatory.c includes both, the header and the >> arch/x86/boot/string.h header. The latter provides its own prototypes >> for a lot of string functions which clash with the fortified macros >> from . >> The next patch will add #include to sha2.h to be able > > This is exactly the problem - people are adding main include namespace headers > from linux/ to arch/x86/boot, or, as you do, to purgatory, which are special > - and then they have to do all kinds of hacks so that it builds. > > (btw, there's no "next patch" in git history). > >> to use memzero_explicit() there, so we have to compile the code in >> purgatory.c with -D__NO_FORTIFY to avoid compilation problems in this >> file. > > How about you extract memzero_explicit() to a separate header in > include/asm-generic/ or simply put it in include/asm-generic/string.h and then > use that header instead? > > Then you shouldn't have prototype clashes... > > It does sound cleaner to me but you'd have to try it to see whether it > actually works. Thanks for the suggestion, I gave it a try, but I only ended up with another huger ugliness this way: Since memzero_explicit() needs memset(), that memset() has to be declared somewhere. Since I cannot include from the file where I put memzero_explicit(), we would need to make sure that all files that want to use include either or arch/x86/boot/string.h or whatever before including sha2.h - i.e. this creates a likely unacceptable indirect dependency of sha2.h on including a string.h header first. Adding the -D__NO_FORTIFY to the purgatory Makefile sounds like the lesser of the two evils to me, especially since there is already another line in that Makefile that adds -D__NO_FORTIFY to one of the other files there: CFLAGS_sha256.o := -D__DISABLE_EXPORTS -D__NO_FORTIFY Maybe I should rather change the patch to add -D__NO_FORTIFY unconditionally to generic PURGATORY_CFLAGS there? Something like: diff --git a/arch/x86/purgatory/Makefile b/arch/x86/purgatory/Makefile --- a/arch/x86/purgatory/Makefile +++ b/arch/x86/purgatory/Makefile @@ -11,7 +11,7 @@ $(obj)/string.o: $(srctree)/arch/x86/boot/compressed/string.c FORCE $(obj)/sha256.o: $(srctree)/lib/crypto/sha256.c FORCE $(call if_changed_rule,cc_o_c) -CFLAGS_sha256.o := -D__DISABLE_EXPORTS -D__NO_FORTIFY +CFLAGS_sha256.o := -D__DISABLE_EXPORTS # When profile-guided optimization is enabled, llvm emits two different # overlapping text sections, which is not supported by kexec. Remove profile @@ -37,6 +37,7 @@ PURGATORY_CFLAGS := -mcmodel=small -ffreestanding -fno-zero-initialized-in-bss - PURGATORY_CFLAGS += -fpic -fvisibility=hidden PURGATORY_CFLAGS += $(DISABLE_KSTACK_ERASE) -DDISABLE_BRANCH_PROFILING PURGATORY_CFLAGS += -fno-stack-protector +PURGATORY_CFLAGS += -D__NO_FORTIFY # Default KBUILD_CFLAGS can have -pg option set when FTRACE is enabled. That # in turn leaves some undefined symbols like __fentry__ in purgatory and not WDYT? Thomas