[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] livepatch: account for patch offset when applying NOP patch


  • To: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Wed, 30 Mar 2022 10:03:11 +0200
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=19fw190Rlq8J0IAtb64UF2ef5nBuRCtZhBBySpjPYDg=; b=M7fStqI0IwmnIqxGPjmdCl1hwoVMgJEmGKdMHhbEle5DsJ+uRGTlyzlcym/K7Lu2R23GgmgHCGMTqRnIQDjhGHQpoG2sFTMbl1+U/c/n+O+odfBUoo6yI0ReMr0VjyPeAOGQxDb5jGowPaHcDqY4DfsyR8b8XSchze4fXsQCd+WkdRH7amn4heDbxG9RajdMmf+sKn1rcU/mVedwwG9NmzuVY9Zzv5HPIG6bV68nAocQM88fTQlPkytv33GWKfYByRNXoRh7Ln7yzl3UQRgg5CvQomw6DwIxP/C8GDmN/aOeqDBm4TAVufQ5ZUeWQ6lDY6KuJ/PkPRnAawqfSQ49Eg==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=aFg/8FLRNtObBkiKtu/WGm2RQ/egNRQtuIwnubNKEhEKS9sGmae7b+6VIJE9Uh69SL97r2eDYoDT4FCKhcpEx3re/Y9nwaAOxHNoxCPpq+LdLTXwSux3xscn6MA95U/wOCJntMmeXGKKMjDWyT+kd5PMM/mQyph9tfDY6b7Z6ruV9ILgQDwRMVeSJYdoQmCrsx5gDxVm9qEzbyoZwCjkg+TkuyuhIxMlsRKNwCy0eoBP7Y2a//4IWBRHtSMqGQj4JSrdMIOiQ2pekc/R1CyL/921STrLsDDWG0AM3KYwB+WMEQI3S9JR64KKf9LKQd9D3cTL4+1QOWWhscjn91MJSA==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com;
  • Cc: Ross Lagerwall <ross.lagerwall@xxxxxxxxxx>, Konrad Wilk <konrad.wilk@xxxxxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
  • Delivery-date: Wed, 30 Mar 2022 08:03:21 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

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@xxxxxxxx>
---
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;
 }




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.