Received: by 2002:a05:6500:2018:b0:1fb:9675:f89d with SMTP id t24csp897466lqh; Sat, 1 Jun 2024 00:29:48 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUD2jfkQA4Uq1b5xgngeZ5mz68lgY6dcesx8vnlHkj/O4XV0Fxko/DUOWg085FIJxdTqMqjQzDTEUq6wZNC9dEJb489g5A4S5167PEROA== X-Google-Smtp-Source: AGHT+IF2jllwH1wXMzJmeUPEBnCw+X3j2uyfu1L1WcxSc4/RJ2KmTx/Q+QxHNj9T+t4uc/YjvVli X-Received: by 2002:a17:90a:e28d:b0:2b9:e009:e47a with SMTP id 98e67ed59e1d1-2c1acc3d22cmr9897555a91.10.1717226988076; Sat, 01 Jun 2024 00:29:48 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717226988; cv=pass; d=google.com; s=arc-20160816; b=tBHTSK6n4aQCCibjcobkFJxb/0YVRMhSL91FLkalQ6W7xCGgv0Mckwv4n9IXGPtuQB /Lqu6zXDMt9AeUFuAgvm+Ae+0cTtawSKyX8nbNvfdPVXA30Lvor88I5bMhf6W6yRYXgx UkVFZPmaFhJ7+dOFypQ3Ei3T0Mcyx7ZBjcD45ED2c94cABWyfuvUiC9M3G/a3WB8cL9Y F9RSim2pyGmP4MtoQVQpB6+9BH5yWMPY+YwtTtO4C9x2EanypSPvXr+Uli649o9zS5Xw MQJQyeAs/GgEblDMD5n6DvqtXNA8bWZD4FaDySttYaEPaCEVLhKXf2FhAqGN1UPOAWj2 D39w== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id:dkim-signature; bh=Hge4VyxWituyIOOJfd321VcyqziYhhPj3o4Ih55xN00=; fh=r/NweF+33iIiu3X1k59krzxWjzn+a07/AkuiGYckQYU=; b=z66y3oc11LNEj0hdBJQVXlHbBHriy5YFOv47zOM+XdE+lcSQQTEbUnwvtO8ra3fY9Q 7W9XIE1RuV/+Uw5xdMGn41mmHXmXt6aVmapdEvaha/wUBxK/2W0Drt5nYvjcqRD9dRLO vZMmOioXKoLYeEBM0G9DmrwHa8i9XsKHMqesOR/gBPMzOssZp3sW+xJ6gXWCWHdLatVS ejHkJBsqn1Bi0YHwpc1GfK3H/U1LhWV9i4xVxGNCrrYWrYTmd/BzzO3cbtfhZOt9v/vv eqi4qPbhJ6O3k9dopvMmSHe5jTx72glMcV7dZm/UCwCTthXLdSFAQLc8XQZXG2IwqrLv RY7w==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@suse.com header.s=google header.b="bG+5p/3v"; arc=pass (i=1 spf=pass spfdomain=suse.com dkim=pass dkdomain=suse.com dmarc=pass fromdomain=suse.com); spf=pass (google.com: domain of linux-kernel+bounces-197752-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-197752-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=suse.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id 98e67ed59e1d1-2c1a7764d9esi4677674a91.20.2024.06.01.00.29.47 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 01 Jun 2024 00:29:48 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-197752-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.com header.s=google header.b="bG+5p/3v"; arc=pass (i=1 spf=pass spfdomain=suse.com dkim=pass dkdomain=suse.com dmarc=pass fromdomain=suse.com); spf=pass (google.com: domain of linux-kernel+bounces-197752-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-197752-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=suse.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 04D7DB22552 for ; Sat, 1 Jun 2024 07:27:46 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 700D618AEA; Sat, 1 Jun 2024 07:27:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b="bG+5p/3v" Received: from mail-lj1-f172.google.com (mail-lj1-f172.google.com [209.85.208.172]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 339DD175A5 for ; Sat, 1 Jun 2024 07:27:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717226855; cv=none; b=dqtPLRWRxmfsw3xXuwZgiiwAmAdYH9Je5jRGLED0ce5PMeeQd7M8XCnChbcLeDFs1p501C5zoRKfsyLX8CNAYrd0Sjro6+C85yiIDBJXoMjAvPgjZTN+/NWKFhXj6Ha+02FkB8q7zjQ6ahxirP8Dtl4QyAwYrgoDw8Tavawl/zU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717226855; c=relaxed/simple; bh=PCJyMuyEUt6FOSKpRSAJIF1DJ6gHGxPxtSzQDAWBqFA=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=ga/gDD05MIx2QNEIHto2npx0qstSz4RsShdgs3Pfsl1C5M4GTD3Eo20V3LhJwKG5RTSMhSyJN0lIIbbw8o2VljkWy53ZpxiASAozdZ2M2acGSYm9NJxU+xPmeMcE+xbiIrwuM+z4Nax9DHf+WoMwac7qI5g1EmVFq82jeqLjX0c= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com; spf=pass smtp.mailfrom=suse.com; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b=bG+5p/3v; arc=none smtp.client-ip=209.85.208.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.com Received: by mail-lj1-f172.google.com with SMTP id 38308e7fff4ca-2e95a883101so35488721fa.3 for ; Sat, 01 Jun 2024 00:27:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1717226850; x=1717831650; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=Hge4VyxWituyIOOJfd321VcyqziYhhPj3o4Ih55xN00=; b=bG+5p/3vyb4go8ANYQmZhD5TOLvBKYOZtyna3vgPdFAicvteo9XLLhyqvcVEfExBcD B2Hphqk7brJzIaUXkIJkymckLcBMIzxZWmeo7Q3LFFnkrZ5EGNzEczwBkrnWWxpRAOv7 nIF3kci1SwqPE0lruSFN6mmekFJ1SDeEvoO77rNAyV5aa/d8bzLVOT2av2RqHAXuzH+T tAlMETqBrMLWoqwYofytlpbcK8Dt2NAPIaNMrsWsUYlIGJbi3rcCsDXWnqGTSDAeQOFz 2KiZXj0wTSiQQwoQtQy+PB/BM/QDDxQUwbMwBkxGOBZ/r1N1P2dKpdAI0+fVDy7Mts1n 20Vw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717226850; x=1717831650; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=Hge4VyxWituyIOOJfd321VcyqziYhhPj3o4Ih55xN00=; b=AEKYScKNZhckrXns7+F5HkErGmiB9TiXzblsMYKQ9rsN+y58bCvNXYtWdwQwPCFApQ b5VE6DGwax+3rQlVA9XxsEo43YmdgQZetN6nwRHyB1nODg+6pUEsQZ4Vfvt5OC+VjpMV /vYw81TwHPboX/mmb3Qa1PPuYP/k2puUuJMbzkk9YY/uZxJyLRaxOtWDEvR//pmme2GK q/mDZ8S+iPO+KCjdgn8+wntpzTZBxtK6u3x9kwuuZouytBBPBJCf9vDD6u7aQGdcQxgg CNKDpNJngc8vKjg59CGsdpGx4pIQijOAFJTe0QI2ykf/5XOBIEcL8z+6MamRwNr6pha+ 7QYw== X-Forwarded-Encrypted: i=1; AJvYcCVBm+HW2WkquHRQdE9UPogBcnSVpe/S8KTD1efDo4K2KJrYuC5shA1LpEvEp2tFQkCt9waeJ0p9PFIBVcUu7y9bVj/EBERlh3ROHzn9 X-Gm-Message-State: AOJu0YyemAb/mFpY9LA9TdzWU7koZ0/OawkDVXjtYw6cUPqdqAP0AfRj uwfUjL+OgmYavVtFD0TSOocDUoPM42uTUunJsq0q0NwfHDiApxEn4hujpWGw79k= X-Received: by 2002:a2e:6a19:0:b0:2df:b7cf:9607 with SMTP id 38308e7fff4ca-2ea95114215mr28008081fa.22.1717226850126; Sat, 01 Jun 2024 00:27:30 -0700 (PDT) Received: from ?IPV6:2a10:bac0:b000:5de0:5af9:fc8:27d7:ba3d? ([2a10:bac0:b000:5de0:5af9:fc8:27d7:ba3d]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4212b838b4asm46873915e9.6.2024.06.01.00.27.29 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 01 Jun 2024 00:27:29 -0700 (PDT) Message-ID: Date: Sat, 1 Jun 2024 10:27:28 +0300 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] x86/boot: add prototype for __fortify_panic() To: Kees Cook , Jeff Johnson Cc: Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org, kernel-janitors@vger.kernel.org References: <20240529-fortify_panic-v1-1-9923d5c77657@quicinc.com> <0d3f7c58-7fc0-4e8b-b6fb-c4d0d9969ce7@suse.com> <202405310923.78257B2B3@keescook> Content-Language: en-US From: Nikolay Borisov In-Reply-To: <202405310923.78257B2B3@keescook> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit On 31.05.24 г. 19:28 ч., Kees Cook wrote: > On Thu, May 30, 2024 at 09:23:36AM -0700, Jeff Johnson wrote: >> On 5/30/2024 8:42 AM, Nikolay Borisov wrote: >>> >>> >>> On 29.05.24 г. 21:09 ч., Jeff Johnson wrote: >>>> As discussed in [1] add a prototype for __fortify_panic() to fix the >>>> 'make W=1 C=1' warning: >>>> >>>> arch/x86/boot/compressed/misc.c:535:6: warning: symbol '__fortify_panic' was not declared. Should it be static? >>> >>> Actually doesn't it make sense to have this defined under ../string.h ? >>> Actually given that we don't have any string fortification under the >>> boot/ why have the fortify _* functions at all ? >> >> I'll let Kees answer these questions since I just took guidance from him :) > > Ah-ha, I see what's happening. When not built with > CONFIG_FORTIFY_SOURCE, fortify-string.h isn't included. But since misc.c > has the function definition, we get a warning that the function > declaration was never seen. This is likely the better solution: fortify-strings.h is used in include/linux/string.h. However all the files in the decompressor are using a local copy of string.h and not the kernel-wide. When pre-processing misc.c with FORTIFY_SOURCE enabled here's the status: $ grep -i fortify arch/x86/boot/compressed/misc.i void __fortify_panic(const u8 reason, size_t avail, size_t size) It seems the decompressor is not using fortify-string at all because it's not using the global string.h ? > > > diff --git a/arch/x86/boot/compressed/misc.c b/arch/x86/boot/compressed/misc.c > index b70e4a21c15f..3f21a5e218f8 100644 > --- a/arch/x86/boot/compressed/misc.c > +++ b/arch/x86/boot/compressed/misc.c > @@ -532,7 +532,9 @@ asmlinkage __visible void *extract_kernel(void *rmode, unsigned char *output) > return output + entry_offset; > } > > +#ifdef CONFIG_FORTIFY_SOURCE > void __fortify_panic(const u8 reason, size_t avail, size_t size) > { > error("detected buffer overflow"); > } > +#endif > > > Jeff, can you test this? (I still haven't been able to reproduce the > warning.) >