Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp1370669lqp; Fri, 22 Mar 2024 12:47:38 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCV7kyf86EIwcqIGUpjo35B+Gf6ZWw+P9njMltZgEky0WuM5e6KV0UofsVYHYhdgppPDoFQTBNd1b7DQ7KqGiKd/KlDaPZx72Xv4LmAngA== X-Google-Smtp-Source: AGHT+IG5dE+RIi0gidddf+XQS+Y8XxkFNzGhml5f7PQYD8gL7GZedNBy8NXcuJIeuvd2Au8rx5vv X-Received: by 2002:a17:906:195a:b0:a46:a8b8:f4cf with SMTP id b26-20020a170906195a00b00a46a8b8f4cfmr418337eje.35.1711136857946; Fri, 22 Mar 2024 12:47:37 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711136857; cv=pass; d=google.com; s=arc-20160816; b=T//IAvQP+ZyrEWGDrio59klURUW8rUGPlf/Iz3gf4q9l7+Ktk+tw/802gEsDMEXsLH qRbAtjQX8QOvowg5ROIE7GWUqDz6Zy1rzYQ8B0VsFEgpv5OFTr/ArEIO/FSzPetAtEhJ 4k1UZKyGUpg9C5kJ7F/h3pOTFoTAJ/XGqStCTZJaPl9qbkziBO/lhq0+RR8vmeunGMFH wUsFJx0vO8QnaT66cVN7oqwNwK5UWOTO+hppVbvxdpOhlB2ZN0IDKv3DKBzh9DIpbYEl VKs+66yPFkBJtT6gopxZgacBJEsSgV/QILg+YYfnetCbjS8DxNVuE/hM60q7dmPda0Y6 2yDQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=DmmHov9qZK91tSR+f8HXIJGfm9hhKvVNviRTerX3QXY=; fh=mv3/gaOXVtVsnRkar+/qqlrPc6IUp3b1kRAdDhVSZHA=; b=GUp8nMQ04qNh+EHJikBj2iKbJzs6R2bYYSwGbDjLz1gnXJ5uglCQTBuxBqKauxdAKX u0JPwi/YfJYtnLECqAz6SkH5L6cY1xVtMwFNPBa9gaAVAesGvaXrD6S4b9RCJCOnl0SZ nAN/SkAyleEJBfF2FQanTLDEtxz23XeePSKo1HQrMRrdpTd/RebIt7qXdks2Un1x9n4d k5qlaFyefiKma38JP9t9PSzf8Ip9C/Q0YU499ZOauqJnnsKwH0szso1uz/RdTgxyk2J3 oY/bh45+LpwZ0nlgYIPsf62zNNUaMy/AxKvncufDMqVUgguSJP4A1HIcoInwJCDe0ZSj t6qg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@alien8.de header.s=alien8 header.b=ckpGz2m1; arc=pass (i=1 spf=pass spfdomain=alien8.de dkim=pass dkdomain=alien8.de dmarc=pass fromdomain=alien8.de); spf=pass (google.com: domain of linux-kernel+bounces-112003-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-112003-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=alien8.de Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id w13-20020a170906480d00b00a46620a5593si137978ejq.153.2024.03.22.12.47.37 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Mar 2024 12:47:37 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-112003-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@alien8.de header.s=alien8 header.b=ckpGz2m1; arc=pass (i=1 spf=pass spfdomain=alien8.de dkim=pass dkdomain=alien8.de dmarc=pass fromdomain=alien8.de); spf=pass (google.com: domain of linux-kernel+bounces-112003-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-112003-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=alien8.de 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 am.mirrors.kernel.org (Postfix) with ESMTPS id AD5B81F23D84 for ; Fri, 22 Mar 2024 19:47:37 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 617537EF0F; Fri, 22 Mar 2024 19:47:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (4096-bit key) header.d=alien8.de header.i=@alien8.de header.b="ckpGz2m1" Received: from mail.alien8.de (mail.alien8.de [65.109.113.108]) (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 3805C745C0; Fri, 22 Mar 2024 19:47:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=65.109.113.108 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711136849; cv=none; b=DtwwojI1uD4v8f3DKgrr35s76zJC/Ao2HXP0Cs+dAw634ASWSEIan2EUpaserULDf8TabkWWjhGzdfqBo5hPelr4esiMfReMjdreumWdnVk9dBajeICEiA3AZs8pgUZyZU9tc5l8edKdfnO9ePMIwsDQmUDDHHwGvnTPxfr8feg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711136849; c=relaxed/simple; bh=nxEGXVhNhN4RVfE3d1n+2+C+HEvgFuhkK+1tNpRSEbI=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=KoBldVl8oLJHSJy8zzlgj89x/5P1TibY5V2be6nfn4P8RmTt2dcUTd8orsDAygizjO3ZB6rkikbbUSgjDIfnfbel8+R8PZnouSWamnu9veFcPrcvErjFmjLxqzlO5TxLR0dzXvnv5sjGlUQP1wCcrsY6NDqB4D1Bi4fW4lsdk+g= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=alien8.de; spf=pass smtp.mailfrom=alien8.de; dkim=pass (4096-bit key) header.d=alien8.de header.i=@alien8.de header.b=ckpGz2m1; arc=none smtp.client-ip=65.109.113.108 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=alien8.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=alien8.de Received: from localhost (localhost.localdomain [127.0.0.1]) by mail.alien8.de (SuperMail on ZX Spectrum 128k) with ESMTP id 9257640E01B5; Fri, 22 Mar 2024 19:47:23 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at mail.alien8.de Authentication-Results: mail.alien8.de (amavisd-new); dkim=pass (4096-bit key) header.d=alien8.de Received: from mail.alien8.de ([127.0.0.1]) by localhost (mail.alien8.de [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id kApiESXmhvFM; Fri, 22 Mar 2024 19:47:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alien8.de; s=alien8; t=1711136839; bh=DmmHov9qZK91tSR+f8HXIJGfm9hhKvVNviRTerX3QXY=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=ckpGz2m1aGeUUEDfnOnKk9xVdwdmhnREG+tzE5h8RE7AfMrFLNlH8UrsEgn3tJsWw fwHwEDhhLhMClv7vG/qKyFfIkAj9ywkLmCo9EtW74crm+v/Su7Q2aiVOdTLki0e13J rD37/jrKQKcQhccrjftN3UaozrDvndrCkf1MVmHmBtsuVtTcZjKSTopfG8m59coe/8 fviSpb614HLGADaxdL8UNAfMQGeZ4Us5XO30RnkrH5mRO4Fbpnhg3leKvlVQCynmBq PBWjsyv0yQ3U49VWA/KoD1Xm9nInT6eYoCLpeY3HhpgOniBH8thYfd537GpzefKz9P ritHXTamlK42Zj4g3JB5gnuGA0oyKwKSORrQ7ZR0jSjERcD1ABzTT3jTYlCB5tFn7v oz/Mm1eSu511R0eO3TA4qAQjevxtDXIQAA9S0lzt153p9Le8SEmua6MDsP/Jx0Xtc0 HBhEkxAuiYoywM446zI2Aimu6lYj2x92lrfm3Lyxn71emU55NuVvOaaEK08GltA1cN zNrHbN/oDiKz6PE8/KsWr0f34JXlgW2lRyVd19krBGdUDBrGGIY435NPP84Lv/pOmv wWa0MXIsFqi/ELXTRXAFXCDF2KL2umRKCi45DGWJlSmf1cZtYqsR64HI6DG22ULa/a wAxDiyGY+fVZpW/FlVazaCcs= Received: from zn.tnic (pd953021b.dip0.t-ipconnect.de [217.83.2.27]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature ECDSA (P-256) server-digest SHA256) (No client certificate requested) by mail.alien8.de (SuperMail on ZX Spectrum 128k) with ESMTPSA id 1637840E00B2; Fri, 22 Mar 2024 19:47:05 +0000 (UTC) Date: Fri, 22 Mar 2024 20:46:58 +0100 From: Borislav Petkov To: Kees Cook Cc: tglx@linutronix.de, Guixiong Wei , jgross@suse.com, mingo@redhat.com, dave.hansen@linux.intel.com, x86@kernel.org, hpa@zytor.com, peterz@infradead.org, gregkh@linuxfoundation.org, tony.luck@intel.com, adobriyan@gmail.com, linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org Subject: Re: [PATCH] x86, relocs: Ignore relocations in .notes section on walk_relocs Message-ID: <20240322194658.GCZf3gMphnWeR9upN6@fat_crate.local> References: <20240317150547.24910-1-weiguixiong@bytedance.com> <171079804927.224083.15609364452504732018.b4-ty@chromium.org> <20240318215612.GDZfi4fG52DTgra51p@fat_crate.local> <202403181644.690285D3@keescook> <20240319081640.GAZflJ6IBQ7TEKD2Ll@fat_crate.local> <202403190955.25E5E03E6@keescook> 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 In-Reply-To: <202403190955.25E5E03E6@keescook> On Tue, Mar 19, 2024 at 09:56:29AM -0700, Kees Cook wrote: > > Yes, please. Just send a Reviewed-by and it'll get picked up. > > Okay, thanks! Dammit, how did this commit land upstream and in stable?! Forgot to zap it from your tree and sent the branch to Linus anyway? Kees, please refrain from taking tip patches in the future. You know how this works - get_maintainers.pl. Thx. Date: Fri, 22 Mar 2024 14:47:05 -0400 From: Sasha Levin To: stable-commits@vger.kernel.org, keescook@chromium.org Cc: Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" Subject: Patch "x86, relocs: Ignore relocations in .notes section" has been added to the 5.4-stable tree X-Mailer: git-send-email 2.43.0 Message-ID: <20240322184705.144463-1-sashal@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=utf-8 This is a note to let you know that I've just added the patch titled x86, relocs: Ignore relocations in .notes section to the 5.4-stable tree which can be found at: http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary The filename of the patch is: x86-relocs-ignore-relocations-in-.notes-section.patch and it can be found in the queue-5.4 subdirectory. If you, or anyone else, feels it should not be added to the stable tree, please let know about it. commit 91aa857ccbd1212a23cd80bb45f71715f2db7144 Author: Kees Cook Date: Tue Feb 27 09:51:12 2024 -0800 x86, relocs: Ignore relocations in .notes section [ Upstream commit aaa8736370db1a78f0e8434344a484f9fd20be3b ] When building with CONFIG_XEN_PV=y, .text symbols are emitted into the .notes section so that Xen can find the "startup_xen" entry point. This information is used prior to booting the kernel, so relocations are not useful. In fact, performing relocations against the .notes section means that the KASLR base is exposed since /sys/kernel/notes is world-readable. To avoid leaking the KASLR base without breaking unprivileged tools that are expecting to read /sys/kernel/notes, skip performing relocations in the .notes section. The values readable in .notes are then identical to those found in System.map. Reported-by: Guixiong Wei Closes: https://lore.kernel.org/all/20240218073501.54555-1-guixiongwei@gmail.com/ Fixes: 5ead97c84fa7 ("xen: Core Xen implementation") Fixes: da1a679cde9b ("Add /sys/kernel/notes") Reviewed-by: Juergen Gross Signed-off-by: Kees Cook Signed-off-by: Sasha Levin diff --git a/arch/x86/tools/relocs.c b/arch/x86/tools/relocs.c index 1c3a1962cade6..0043fd374a62f 100644 --- a/arch/x86/tools/relocs.c +++ b/arch/x86/tools/relocs.c @@ -596,6 +596,14 @@ static void print_absolute_relocs(void) if (!(sec_applies->shdr.sh_flags & SHF_ALLOC)) { continue; } + /* + * Do not perform relocations in .notes section; any + * values there are meant for pre-boot consumption (e.g. + * startup_xen). + */ + if (sec_applies->shdr.sh_type == SHT_NOTE) { + continue; + } sh_symtab = sec_symtab->symtab; sym_strtab = sec_symtab->link->strtab; for (j = 0; j < sec->shdr.sh_size/sizeof(Elf_Rel); j++) { -- Regards/Gruss, Boris. https://people.kernel.org/tglx/notes-about-netiquette