Received: by 2002:a05:6500:2018:b0:1fb:9675:f89d with SMTP id t24csp569409lqh; Fri, 31 May 2024 09:32:19 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCU+zvy81uXhHouV5fitYOIS+8/ovb/n+VLMuiGkiWUR/xotQ0YsQWL1HU4FHKw9mp8On07Jj+uzIb4UVU0Lk8AX4zzHQ96ygwj+4gne/Q== X-Google-Smtp-Source: AGHT+IH9Xy3ih3OZDaeZ3mo5bSKh8MbNKxWZvB7JntF5p94Zq6e6wFHw3pKsO8PKtkM/vwL5UzSJ X-Received: by 2002:a17:903:238c:b0:1f4:8a14:f4cd with SMTP id d9443c01a7336-1f63708dd12mr17980435ad.39.1717173138969; Fri, 31 May 2024 09:32:18 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717173138; cv=pass; d=google.com; s=arc-20160816; b=ndHCwdAfk4BBssaLOwcPEJoTy7ehKI+Z7PayH1jh4JC0ip04F8UWjw3Q7LxyB9Wtva sutXnTDyxT2hGuA4RHfViQ866bBqowZjz5SqMEZMGxgQN9qMVPby1vTN0js8xUtPjJ4V jyHhNcJYGGvrMkQ2OfQeqNtYAoQpY11H98QDaDCx/jQstZj71+pJEWzIRVQ3/T+Wc1+K zWIhnhAT+1OSViK5bOZOsdAUbeJVnh+Nw80eYRBIKj87N6mMr0kZIMdFKdUEyTjMmAzx zA2P072CeRXxdkz6QcfAacag3cqYSBw4W4gVnkfNTDRHsDVK25vVH8YD/cg0f9BJ7C0l DepA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :references:message-id:subject:cc:to:from:date:dkim-signature; bh=QfseHkemFK1ySLM9bQ1sq4nZl+cWEy4aeqy8nyYUwuc=; fh=Zu1B4f3lrF/Ju8VxaHzL58IKgATm2Cg3a57eBZyo+ok=; b=L6CKV4d2g4bXJr3s74iStK8Ww3jrir5sIuFvP25LFaLg1gq6C2l2ULOPMxImzN71Sb BkKcE2fe5zGOYTPEWnADlTxALtpTc3XghNt9JVQ4LDCMLpRf4IgdAD7Z/8E9byuRAEVt iJNyOdohFkoAs1IxFtMzJdyhMOruhBFz/9+iwiaGcECHaaoQpamQibJH7EvHCVcsrVxs zZd/MVUI/Cb5LWg77bET7POuYX2fm6PjftlWxEm0RBo2s4cYWcGbCUWtzoq59QDVzJ+9 CLDhonW3PFFEoNDsWcCThNFbErOMPLNIP4cWdaDjBFjuuafvawEDPM8hgSQK695l1Djs u+oQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=tA6mqYpF; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-197148-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-197148-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id d9443c01a7336-1f6323eb5c1si18495635ad.407.2024.05.31.09.32.18 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 31 May 2024 09:32:18 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-197148-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=tA6mqYpF; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-197148-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-197148-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org 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 sv.mirrors.kernel.org (Postfix) with ESMTPS id A00A928C6A4 for ; Fri, 31 May 2024 16:28:36 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 42D9515D5A6; Fri, 31 May 2024 16:28:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="tA6mqYpF" 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 6530F158DD7; Fri, 31 May 2024 16:28:27 +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=1717172907; cv=none; b=ZnvkIYzUkY+YZzuvrL6FuawAeP0Yjbbe9vqI9rQO7k+o5Q71REvFv3xfGk9y7bhxN+r/vYbM6zxbL4AaoMs5HZr82y7W8OL1k80e/hkr7XhuBX3sP2PfEOEatTz3ZEmTjuhBnrtUjcIdO1UaVirc5d+Tx8LX0MU+0nXVtDrb+Xs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717172907; c=relaxed/simple; bh=G9YBmBIaLtAXZPjNyAagf7B6fv+FKzsPzY489k3bd2w=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=SYYlLZggJJ2qPZorQOkHFgD+Vm9hqSuKW/aYoVU6B1Fmt/Z2iXLbMQJej0FPiP8KgzyN3yBVCjgwL7AepVgoZN4cG27nEPqrhk0bVJ284gNUfXqRQTl4+hf6bYinU7EMIS7Pxr+10hURT8zQCsJbW7Y4qHI/4fTlC3qC2PDFSx0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=tA6mqYpF; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id E5BD9C116B1; Fri, 31 May 2024 16:28:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1717172907; bh=G9YBmBIaLtAXZPjNyAagf7B6fv+FKzsPzY489k3bd2w=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=tA6mqYpF5paicZvv4vbBxYXrwWg4Vc0trMhm7CIfgnWMnRm9BhL+yS6yqLy3y/otu JSossMlgG5yHYJlcHphb5UiFnccarJ0LeWYyswSJ4JebhPYg2e61p06n4+upaf+Ae5 5NnbxbrDZuW6o/FRuQjhCBblw0XCe6zcdJ7m1EO+UmzT5chmuiX4Fag00a0tvvqzrB FvY2L5Q+z00Wy3llSN+DALsqpOY2QvLmvgCUTnAMLeMQOOV5EBMp7KVACEkAI00v7z En3ZmWds/j+hCt1HQ1YTDpyBwEY6eVCclba2DD0rbYg74ZQyWRqp/eXyboixaXNQv5 3I6F5qaGhOtsw== Date: Fri, 31 May 2024 09:28:26 -0700 From: Kees Cook To: Jeff Johnson Cc: Nikolay Borisov , 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 Subject: Re: [PATCH] x86/boot: add prototype for __fortify_panic() Message-ID: <202405310923.78257B2B3@keescook> References: <20240529-fortify_panic-v1-1-9923d5c77657@quicinc.com> <0d3f7c58-7fc0-4e8b-b6fb-c4d0d9969ce7@suse.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: 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: 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.) -- Kees Cook