From nobody Sun Nov 24 12:01:05 2024 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 74D4418C903; Wed, 6 Nov 2024 02:08:39 +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=1730858919; cv=none; b=V4UPcfD1wSIf8Lzu+h/zUVdO1xiK6advLwoYtC6vXYQT002E4Hn7s6lueu1Cpw+0AqIP8LXC5ZTihVEWOchJVztOlIqq35n3PIXvqSkznkuh0lhshq4NdEzsqx7oi5nGnwt1mN+I5lvEWMtUC/fpQLPXsZFPOlZIjrM1BaEwXAg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730858919; c=relaxed/simple; bh=16WZozry3IWIsN9qHKE/zH8myu5XP6InRSKDu/UUqTg=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=pDAcNjElW/+c3yCKNX5fzKHp+vezQAVZVi1cLmV3+8vy9hhdqnBbP86dWNAv2U6i2a+kIpjeZ0UUl6axU6X+6rb0FyFWbTO6EGO5czdQvO1jkaOre0eghEmoyJBgsAluwhWNlneEW2Kg0wjTi5EWW/9S9sMLCSBSp7e9FCFX+zA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=shU7kjBv; 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="shU7kjBv" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4E546C4CECF; Wed, 6 Nov 2024 02:08:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1730858919; bh=16WZozry3IWIsN9qHKE/zH8myu5XP6InRSKDu/UUqTg=; h=From:To:Cc:Subject:Date:From; b=shU7kjBvYA2U/QCdhlxDzXSurrYcAj00kcqUk8tUAYRZX1FY34mE7xS6lTQcyVST1 YLhxwCSrCDxkS1b8KKPOhHqTfk4Y8yIkzVPj1CNnqtW7Yz4D0L/8QGTCMD25U7xBuZ aVjwk6oVrIpp/a/AubR4vbFDSduelfz+c/r8X/buUXrR4Fhq7AgbSkUKCcpQKGZBxF Fb/ZaeUre0qFvqQgjzFpvleo97Um0tTthMxPlN6Tr9qClzHZigmJQ+E53TAykvwCuR /x1vRSgGfCgYG6v2MHKPDDBlzygCS5vFyOxBjICB2sePBLyswUZZH61+0GtzNLMOp8 tV81XoI7ab9IQ== From: Sasha Levin To: stable@vger.kernel.org, alexghiti@rivosinc.com Cc: Jason Montleon , Palmer Dabbelt , linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org Subject: FAILED: Patch "riscv: Do not use fortify in early code" failed to apply to v6.11-stable tree Date: Tue, 5 Nov 2024 21:08:35 -0500 Message-ID: <20241106020836.164319-1-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Hint: ignore X-stable: review Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The patch below does not apply to the v6.11-stable tree. If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to . Thanks, Sasha Reported-by: Jason Montleon ------------------ original commit in Linus's tree ------------------ From afedc3126e11ff1404b32e538657b68022e933ca Mon Sep 17 00:00:00 2001 From: Alexandre Ghiti Date: Wed, 9 Oct 2024 09:27:49 +0200 Subject: [PATCH] riscv: Do not use fortify in early code Early code designates the code executed when the MMU is not yet enabled, and this comes with some limitations (see Documentation/arch/riscv/boot.rst, section "Pre-MMU execution"). FORTIFY_SOURCE must be disabled then since it can trigger kernel panics as reported in [1]. Reported-by: Jason Montleon Closes: https://lore.kernel.org/linux-riscv/CAJD_bPJes4QhmXY5f63GHV9B9HFkSC= oaZjk-qCT2NGS7Q9HODg@mail.gmail.com/ [1] Fixes: a35707c3d850 ("riscv: add memory-type errata for T-Head") Fixes: 26e7aacb83df ("riscv: Allow to downgrade paging mode from the comman= d line") Cc: stable@vger.kernel.org Signed-off-by: Alexandre Ghiti Link: https://lore.kernel.org/r/20241009072749.45006-1-alexghiti@rivosinc.c= om Signed-off-by: Palmer Dabbelt --- arch/riscv/errata/Makefile | 6 ++++++ arch/riscv/kernel/Makefile | 5 +++++ arch/riscv/kernel/pi/Makefile | 6 +++++- 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/arch/riscv/errata/Makefile b/arch/riscv/errata/Makefile index 8a27394851233..f0da9d7b39c37 100644 --- a/arch/riscv/errata/Makefile +++ b/arch/riscv/errata/Makefile @@ -2,6 +2,12 @@ ifdef CONFIG_RELOCATABLE KBUILD_CFLAGS +=3D -fno-pie endif =20 +ifdef CONFIG_RISCV_ALTERNATIVE_EARLY +ifdef CONFIG_FORTIFY_SOURCE +KBUILD_CFLAGS +=3D -D__NO_FORTIFY +endif +endif + obj-$(CONFIG_ERRATA_ANDES) +=3D andes/ obj-$(CONFIG_ERRATA_SIFIVE) +=3D sifive/ obj-$(CONFIG_ERRATA_THEAD) +=3D thead/ diff --git a/arch/riscv/kernel/Makefile b/arch/riscv/kernel/Makefile index 7f88cc4931f5c..69dc8aaab3fb3 100644 --- a/arch/riscv/kernel/Makefile +++ b/arch/riscv/kernel/Makefile @@ -36,6 +36,11 @@ KASAN_SANITIZE_alternative.o :=3D n KASAN_SANITIZE_cpufeature.o :=3D n KASAN_SANITIZE_sbi_ecall.o :=3D n endif +ifdef CONFIG_FORTIFY_SOURCE +CFLAGS_alternative.o +=3D -D__NO_FORTIFY +CFLAGS_cpufeature.o +=3D -D__NO_FORTIFY +CFLAGS_sbi_ecall.o +=3D -D__NO_FORTIFY +endif endif =20 extra-y +=3D vmlinux.lds diff --git a/arch/riscv/kernel/pi/Makefile b/arch/riscv/kernel/pi/Makefile index d5bf1bc7de62e..81d69d45c06c3 100644 --- a/arch/riscv/kernel/pi/Makefile +++ b/arch/riscv/kernel/pi/Makefile @@ -16,8 +16,12 @@ KBUILD_CFLAGS :=3D $(filter-out $(CC_FLAGS_LTO), $(KBUIL= D_CFLAGS)) KBUILD_CFLAGS +=3D -mcmodel=3Dmedany =20 CFLAGS_cmdline_early.o +=3D -D__NO_FORTIFY -CFLAGS_lib-fdt_ro.o +=3D -D__NO_FORTIFY CFLAGS_fdt_early.o +=3D -D__NO_FORTIFY +# lib/string.c already defines __NO_FORTIFY +CFLAGS_ctype.o +=3D -D__NO_FORTIFY +CFLAGS_lib-fdt.o +=3D -D__NO_FORTIFY +CFLAGS_lib-fdt_ro.o +=3D -D__NO_FORTIFY +CFLAGS_archrandom_early.o +=3D -D__NO_FORTIFY =20 $(obj)/%.pi.o: OBJCOPYFLAGS :=3D --prefix-symbols=3D__pi_ \ --remove-section=3D.note.gnu.property \ --=20 2.43.0