All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] livepatch: account for patch offset when applying NOP patch
@ 2022-03-30  8:03 Jan Beulich
  2022-03-30 10:19 ` Roger Pau Monné
  0 siblings, 1 reply; 4+ messages in thread
From: Jan Beulich @ 2022-03-30  8:03 UTC (permalink / raw)
  To: xen-devel@lists.xenproject.org; +Cc: Ross Lagerwall, Konrad Wilk, Andrew Cooper

While not triggered by the trivial xen_nop in-tree patch on
staging/master, that patch exposes a problem on the stable trees, where
all functions have ENDBR inserted. When NOP-ing out a range, we need to
account for this. Handle this right in livepatch_insn_len().

Fixes: 6974c75180f1 ("xen/x86: Livepatch: support patching CET-enhanced functions")
Signed-off-by: Jan Beulich <jbeulich@suse.com>
---
Only build tested, as I don't have a live patching environment available.

For Arm this assumes that the patch_offset field starts out as zero; I
think we can make such an assumption, yet otoh on x86 explicit
initialization was added by the cited commit.

--- a/xen/include/xen/livepatch.h
+++ b/xen/include/xen/livepatch.h
@@ -90,7 +90,7 @@ static inline
 unsigned int livepatch_insn_len(const struct livepatch_func *func)
 {
     if ( !func->new_addr )
-        return func->new_size;
+        return func->new_size - func->patch_offset;
 
     return ARCH_PATCH_INSN_SIZE;
 }



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

end of thread, other threads:[~2022-03-30 10:51 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-03-30  8:03 [PATCH] livepatch: account for patch offset when applying NOP patch Jan Beulich
2022-03-30 10:19 ` Roger Pau Monné
2022-03-30 10:43   ` Jan Beulich
2022-03-30 10:50     ` Jan Beulich

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.