public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Borislav Petkov <bp@alien8.de>
To: Thomas Gleixner <tglx@linutronix.de>
Cc: X86 ML <x86@kernel.org>, LKML <linux-kernel@vger.kernel.org>
Subject: [PATCH] lib/earlycpio: Mark find_cpio_data() __no_stack_protector
Date: Wed, 16 Aug 2023 12:02:21 +0200	[thread overview]
Message-ID: <20230816100221.12209-1-bp@alien8.de> (raw)

From: "Borislav Petkov (AMD)" <bp@alien8.de>

find_cpio_data() is called by the 32-bit x86 microcode loader while
paging is not yet enabled and the CPU is running off physical addresses.
However, when stack protector is enabled, the compiler adds the stack
protection check for this function:

  c1846480 <find_cpio_data>:
  c1846480:       55                      push   %ebp
  c1846481:       89 e5                   mov    %esp,%ebp
  c1846483:       57                      push   %edi
  ...

  c1846676:       e9 85 fe ff ff          jmp    c1846500 <find_cpio_data+0x80>
  c184667b:       e8 20 9e 02 00          call   c18704a0 <__stack_chk_fail>

which cannot work yet.

Prevent that from happening.

Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de>
---
 lib/earlycpio.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lib/earlycpio.c b/lib/earlycpio.c
index d2c37d64fd0c..d3efe707c3f7 100644
--- a/lib/earlycpio.c
+++ b/lib/earlycpio.c
@@ -56,8 +56,8 @@ enum cpio_fields {
  *              the match returned an empty filename string.
  */
 
-struct cpio_data find_cpio_data(const char *path, void *data,
-				size_t len,  long *nextoff)
+struct cpio_data __no_stack_protector find_cpio_data(const char *path, void *data,
+						     size_t len,  long *nextoff)
 {
 	const size_t cpio_header_len = 8*C_NFIELDS - 2;
 	struct cpio_data cd = { NULL, 0, "" };
-- 
2.42.0.rc0.25.ga82fb66fed25


             reply	other threads:[~2023-08-16 10:03 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-16 10:02 Borislav Petkov [this message]
2023-08-18  8:18 ` [PATCH] lib/earlycpio: Mark find_cpio_data() __no_stack_protector Thomas Gleixner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230816100221.12209-1-bp@alien8.de \
    --to=bp@alien8.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=tglx@linutronix.de \
    --cc=x86@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox