From nobody Sun Nov 24 11:34:59 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 6BE4A18EFD4; Wed, 6 Nov 2024 02:07:34 +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=1730858854; cv=none; b=F+K4fpDaaisdKiCLT1F0kj7ja9+e5yJArebKPPr9bb4lvWJ1cGpQX6tDWIyKfZ3AKN/HEPAm6/1bOJ2OWp3HFPnbCI1ywwpJeKHMlhjR8kmp+loH1lQytxy25hxgtlPm3S5nE2YIZt0io9zVSMHZF5IoFnLQIa+5X9g9Xj7rtQc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730858854; c=relaxed/simple; bh=16WZozry3IWIsN9qHKE/zH8myu5XP6InRSKDu/UUqTg=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=D2xFZ2Z+D7+SwUq8ns0ZOq0J871WLAiW+r0FNtYhsy0gq+Hy/P26BJSH6NimAmLdQ2Jek5nGfovkMDFGeSpBSMbtdIoqTqo9eefz84xFT3FM5wlyPFI4ngoT2STS2Xvwhx4lXBR91rNy8tVSH/oV7fXi/9U8/VuXT9cTVVwCMzE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=VAJFT7ry; 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="VAJFT7ry" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2B7D5C4CECF; Wed, 6 Nov 2024 02:07:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1730858854; bh=16WZozry3IWIsN9qHKE/zH8myu5XP6InRSKDu/UUqTg=; h=From:To:Cc:Subject:Date:From; b=VAJFT7ryTJ0n5D9qhGRyyBLWHEbEXACNi2zKXDXhR5fIoPhn9uP/1hy4p/6Yo1oGh p6Q0vaUCbmFSBq31OwCuXdFhmr2HDHPzu7iUtahW9iygYPLNWQksBCpvNB0LxYtDbD fwXYa6rglLaMegYa1fPhZtbHqqmR4L3/gr77UWvwvKilmq3Gnhvhoyuw8w/v2YeP+e MLqf8zRKnm6glEjPK77rVudRaxsLHZbx+TWp56Rh+JBPnT7jO10Ms8RD0VeCUneugf 1SLjhkpKa+PvNyB0ENJPAMqK4D345jXlnB16K5jddukLWtf0adx7wduY9eitFxw/jh W1KK+FYS6dDeg== 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:07:30 -0500 Message-ID: <20241106020731.164192-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