public inbox for stable@vger.kernel.org
 help / color / mirror / Atom feed
* FAILED: patch "[PATCH] x86/retbleed: Fix return thunk alignment" failed to apply to 5.15-stable tree
@ 2023-05-13  8:17 gregkh
  2023-05-13 10:21 ` Borislav Petkov
  0 siblings, 1 reply; 4+ messages in thread
From: gregkh @ 2023-05-13  8:17 UTC (permalink / raw)
  To: bp, stable, tglx, torvalds; +Cc: stable


The patch below does not apply to the 5.15-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 <stable@vger.kernel.org>.

To reproduce the conflict and resubmit, you may use the following commands:

git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-5.15.y
git checkout FETCH_HEAD
git cherry-pick -x 9a48d604672220545d209e9996c2a1edbb5637f6
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<stable@vger.kernel.org>' --in-reply-to '2023051313-wrangle-brick-b43d@gregkh' --subject-prefix 'PATCH 5.15.y' HEAD^..

Possible dependencies:

9a48d6046722 ("x86/retbleed: Fix return thunk alignment")
a149180fbcf3 ("x86: Add magic AMD return-thunk")
d9e9d2300681 ("x86,objtool: Create .return_sites")
15e67227c49a ("x86: Undo return-thunk damage")
0b53c374b9ef ("x86/retpoline: Use -mfunction-return")
369ae6ffc41a ("x86/retpoline: Cleanup some #ifdefery")
a883d624aed4 ("x86/cpufeatures: Move RETPOLINE flags to word 11")
22922deae13f ("Merge tag 'objtool-core-2022-05-23' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip")

thanks,

greg k-h

------------------ original commit in Linus's tree ------------------

From 9a48d604672220545d209e9996c2a1edbb5637f6 Mon Sep 17 00:00:00 2001
From: "Borislav Petkov (AMD)" <bp@alien8.de>
Date: Fri, 12 May 2023 23:12:26 +0200
Subject: [PATCH] x86/retbleed: Fix return thunk alignment

SYM_FUNC_START_LOCAL_NOALIGN() adds an endbr leading to this layout
(leaving only the last 2 bytes of the address):

  3bff <zen_untrain_ret>:
  3bff:       f3 0f 1e fa             endbr64
  3c03:       f6                      test   $0xcc,%bl

  3c04 <__x86_return_thunk>:
  3c04:       c3                      ret
  3c05:       cc                      int3
  3c06:       0f ae e8                lfence

However, "the RET at __x86_return_thunk must be on a 64 byte boundary,
for alignment within the BTB."

Use SYM_START instead.

Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de>
Reviewed-by: Thomas Gleixner <tglx@linutronix.de>
Cc: <stable@kernel.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

diff --git a/arch/x86/lib/retpoline.S b/arch/x86/lib/retpoline.S
index 27ef53fab6bd..b3b1e376dce8 100644
--- a/arch/x86/lib/retpoline.S
+++ b/arch/x86/lib/retpoline.S
@@ -144,8 +144,8 @@ SYM_CODE_END(__x86_indirect_jump_thunk_array)
  */
 	.align 64
 	.skip 63, 0xcc
-SYM_FUNC_START_NOALIGN(zen_untrain_ret);
-
+SYM_START(zen_untrain_ret, SYM_L_GLOBAL, SYM_A_NONE)
+	ANNOTATE_NOENDBR
 	/*
 	 * As executed from zen_untrain_ret, this is:
 	 *


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: FAILED: patch "[PATCH] x86/retbleed: Fix return thunk alignment" failed to apply to 5.15-stable tree
  2023-05-13  8:17 FAILED: patch "[PATCH] x86/retbleed: Fix return thunk alignment" failed to apply to 5.15-stable tree gregkh
@ 2023-05-13 10:21 ` Borislav Petkov
  2023-05-13 10:35   ` Greg KH
  0 siblings, 1 reply; 4+ messages in thread
From: Borislav Petkov @ 2023-05-13 10:21 UTC (permalink / raw)
  To: gregkh; +Cc: stable, tglx, torvalds, stable

On Sat, May 13, 2023 at 05:17:13PM +0900, gregkh@linuxfoundation.org wrote:
> 
> The patch below does not apply to the 5.15-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 <stable@vger.kernel.org>.
> 
> To reproduce the conflict and resubmit, you may use the following commands:
> 
> git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-5.15.y
> git checkout FETCH_HEAD
> git cherry-pick -x 9a48d604672220545d209e9996c2a1edbb5637f6
> # <resolve conflicts, build, test, etc.>
> git commit -s
> git send-email --to '<stable@vger.kernel.org>' --in-reply-to '2023051313-wrangle-brick-b43d@gregkh' --subject-prefix 'PATCH 5.15.y' HEAD^..
> 
> Possible dependencies:
> 
> 9a48d6046722 ("x86/retbleed: Fix return thunk alignment")
> a149180fbcf3 ("x86: Add magic AMD return-thunk")
> d9e9d2300681 ("x86,objtool: Create .return_sites")
> 15e67227c49a ("x86: Undo return-thunk damage")
> 0b53c374b9ef ("x86/retpoline: Use -mfunction-return")
> 369ae6ffc41a ("x86/retpoline: Cleanup some #ifdefery")
> a883d624aed4 ("x86/cpufeatures: Move RETPOLINE flags to word 11")
> 22922deae13f ("Merge tag 'objtool-core-2022-05-23' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip")

Right, so that looks like this:

The patch which causes the misalignment is

c4691712b546 ("x86/linkage: Add ENDBR to SYM_FUNC_START*()")

which came in 5.18 (v5.17-rc8-21-gc4691712b546) and the one which adds
the actual untraining sequence:

a149180fbcf3 ("x86: Add magic AMD return-thunk")

came in 5.19.

So adding a Fixes: tag pointing to a patch which goes before the actual
patch didn't make any sense to me last night.

HOWEVER, Thadeu did backport it here as

a9c0926fc754 ("x86: Add magic AMD return-thunk")

but the other patch wasn't backported.

So the 5.15 build looks good:

ffffffff81c01f7f <zen_untrain_ret>:
ffffffff81c01f7f:       f6                      .byte 0xf6

ffffffff81c01f80 <__x86_return_thunk>:
ffffffff81c01f80:       c3                      ret
ffffffff81c01f81:       cc                      int3
ffffffff81c01f82:       0f ae e8                lfence
ffffffff81c01f85:       eb f9                   jmp    ffffffff81c01f80 <__x86_return_thunk>
ffffffff81c01f87:       cc                      int3

So 5.15 doesn't need it.

Now lemme look at 5.10.

Thx.

-- 
Regards/Gruss,
    Boris.

https://people.kernel.org/tglx/notes-about-netiquette

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: FAILED: patch "[PATCH] x86/retbleed: Fix return thunk alignment" failed to apply to 5.15-stable tree
  2023-05-13 10:21 ` Borislav Petkov
@ 2023-05-13 10:35   ` Greg KH
  2023-05-13 10:38     ` Borislav Petkov
  0 siblings, 1 reply; 4+ messages in thread
From: Greg KH @ 2023-05-13 10:35 UTC (permalink / raw)
  To: Borislav Petkov; +Cc: stable, tglx, torvalds, stable

On Sat, May 13, 2023 at 12:21:07PM +0200, Borislav Petkov wrote:
> On Sat, May 13, 2023 at 05:17:13PM +0900, gregkh@linuxfoundation.org wrote:
> > 
> > The patch below does not apply to the 5.15-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 <stable@vger.kernel.org>.
> > 
> > To reproduce the conflict and resubmit, you may use the following commands:
> > 
> > git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-5.15.y
> > git checkout FETCH_HEAD
> > git cherry-pick -x 9a48d604672220545d209e9996c2a1edbb5637f6
> > # <resolve conflicts, build, test, etc.>
> > git commit -s
> > git send-email --to '<stable@vger.kernel.org>' --in-reply-to '2023051313-wrangle-brick-b43d@gregkh' --subject-prefix 'PATCH 5.15.y' HEAD^..
> > 
> > Possible dependencies:
> > 
> > 9a48d6046722 ("x86/retbleed: Fix return thunk alignment")
> > a149180fbcf3 ("x86: Add magic AMD return-thunk")
> > d9e9d2300681 ("x86,objtool: Create .return_sites")
> > 15e67227c49a ("x86: Undo return-thunk damage")
> > 0b53c374b9ef ("x86/retpoline: Use -mfunction-return")
> > 369ae6ffc41a ("x86/retpoline: Cleanup some #ifdefery")
> > a883d624aed4 ("x86/cpufeatures: Move RETPOLINE flags to word 11")
> > 22922deae13f ("Merge tag 'objtool-core-2022-05-23' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip")
> 
> Right, so that looks like this:
> 
> The patch which causes the misalignment is
> 
> c4691712b546 ("x86/linkage: Add ENDBR to SYM_FUNC_START*()")
> 
> which came in 5.18 (v5.17-rc8-21-gc4691712b546) and the one which adds
> the actual untraining sequence:
> 
> a149180fbcf3 ("x86: Add magic AMD return-thunk")
> 
> came in 5.19.
> 
> So adding a Fixes: tag pointing to a patch which goes before the actual
> patch didn't make any sense to me last night.
> 
> HOWEVER, Thadeu did backport it here as
> 
> a9c0926fc754 ("x86: Add magic AMD return-thunk")
> 
> but the other patch wasn't backported.
> 
> So the 5.15 build looks good:
> 
> ffffffff81c01f7f <zen_untrain_ret>:
> ffffffff81c01f7f:       f6                      .byte 0xf6
> 
> ffffffff81c01f80 <__x86_return_thunk>:
> ffffffff81c01f80:       c3                      ret
> ffffffff81c01f81:       cc                      int3
> ffffffff81c01f82:       0f ae e8                lfence
> ffffffff81c01f85:       eb f9                   jmp    ffffffff81c01f80 <__x86_return_thunk>
> ffffffff81c01f87:       cc                      int3
> 
> So 5.15 doesn't need it.

Great, thanks for looking into this, much appreciated.

greg k-h

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: FAILED: patch "[PATCH] x86/retbleed: Fix return thunk alignment" failed to apply to 5.15-stable tree
  2023-05-13 10:35   ` Greg KH
@ 2023-05-13 10:38     ` Borislav Petkov
  0 siblings, 0 replies; 4+ messages in thread
From: Borislav Petkov @ 2023-05-13 10:38 UTC (permalink / raw)
  To: Greg KH; +Cc: stable, tglx, torvalds, stable

On Sat, May 13, 2023 at 07:35:05PM +0900, Greg KH wrote:
> Great, thanks for looking into this, much appreciated.

Sure, np.

And I just checked the 6.x streams - yes the backport is needed there
so you taking them there is good. :)

Thx.

-- 
Regards/Gruss,
    Boris.

https://people.kernel.org/tglx/notes-about-netiquette

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2023-05-13 10:38 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-05-13  8:17 FAILED: patch "[PATCH] x86/retbleed: Fix return thunk alignment" failed to apply to 5.15-stable tree gregkh
2023-05-13 10:21 ` Borislav Petkov
2023-05-13 10:35   ` Greg KH
2023-05-13 10:38     ` Borislav Petkov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox