From nobody Tue Nov 4 01:06:13 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=reject dis=none) header.from=citrix.com ARC-Seal: i=1; a=rsa-sha256; t=1726825053; cv=none; d=zohomail.com; s=zohoarc; b=N5FKDyB2k6DgDDOI3glfdDQAghnG+eX2X1lJB/gVkCd8f1jZX6qElwR2bRvC61DeSbgxMP8GqRIQji7JJ5y2zqWXE07SaSE9TMB3FysRUlzZpxYm2WDjTQvskX1EoojT4duRfPQomYj+5LbypDx1XFw29Xvm3Hy3XgOTIHz6xIE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1726825053; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=1N4dCytGEzetjbXwIG17gkrBm9HHnJ0smkpdbjRf43Q=; b=PEQF5b+QPy79H+MqBTlvkZpDV/EcTxdhivq2Rt8xpr6JBY3lHCHY9NtfcVSLV78AHJrfEtRSIJ1KY5PQQfEVXIRAeXL/59hnCVcAIOa2+8NCJyGc5s9WMxYOlX4y4rBYXYGOy3T0iQ2Gu/iyFmZBfixyDrA5zJFQUM3CVINbPuU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1726825053068775.510657827498; Fri, 20 Sep 2024 02:37:33 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.801080.1211129 (Exim 4.92) (envelope-from ) id 1sra4b-00016A-FY; Fri, 20 Sep 2024 09:37:09 +0000 Received: by outflank-mailman (output) from mailman id 801080.1211129; Fri, 20 Sep 2024 09:37:09 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sra4b-000161-Co; Fri, 20 Sep 2024 09:37:09 +0000 Received: by outflank-mailman (input) for mailman id 801080; Fri, 20 Sep 2024 09:37:07 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sra4Z-0000OC-LW for xen-devel@lists.xenproject.org; Fri, 20 Sep 2024 09:37:07 +0000 Received: from mail-lf1-x129.google.com (mail-lf1-x129.google.com [2a00:1450:4864:20::129]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id e6d5e6e2-7733-11ef-a0b8-8be0dac302b0; Fri, 20 Sep 2024 11:37:07 +0200 (CEST) Received: by mail-lf1-x129.google.com with SMTP id 2adb3069b0e04-5365aa568ceso2249042e87.0 for ; Fri, 20 Sep 2024 02:37:07 -0700 (PDT) Received: from localhost ([213.195.124.163]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a90612b38c8sm818163366b.103.2024.09.20.02.37.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Sep 2024 02:37:05 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: e6d5e6e2-7733-11ef-a0b8-8be0dac302b0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=citrix.com; s=google; t=1726825026; x=1727429826; darn=lists.xenproject.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=1N4dCytGEzetjbXwIG17gkrBm9HHnJ0smkpdbjRf43Q=; b=apagAd7c7Wg+RAKFdXbBLHh4Zb2iNPASR2DAs/sfvFUQZYzi2K96LJygLj4KGvbON1 /3kj9vHnZtr8auqUQN4DEMiWxv7bw/S7kljT45kfb/gAjZUw3jY7DSIPrLdiCZAltwMz MvAf3+eiR/8/hcGEn6nfViPnas0m7hDKfbBx4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726825026; x=1727429826; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=1N4dCytGEzetjbXwIG17gkrBm9HHnJ0smkpdbjRf43Q=; b=ma9IV+AvXHLy9rel65YIarkx+tsk85IjHJw8CCppIFV9l3fOCPxdsKTRD1lSqWY0B1 1ym8RX/XADj+qmK5shCc7WDJmxjNYiizUPkAHWpeo2cxp6jxEsH1IxI9XhBifmH1EKql mI1xqxcGwCBlEmA1cJsZYzvTV6DkNfAsk9Fvf3+7e+XuFDrLOjF1eE3Gl/49dy0wKeZL 1blDlGK1WDp3q4NLnb431qLOvmSHmTQw+39gD6OVaGFk5C59eOqtDqJdZUcuvQ+AEBkW couOzR56AdwZ2pLk2Q+pCBD2WLnnJjhsaDnzn060NCzJXXKaKHR0YjuSHpJSPKDbfjoT 6d7w== X-Gm-Message-State: AOJu0YxeYtYXRK3LXm5sn6WpsNzB0bTTVwu1J/32pAS5F9kFcJKiyfwV BWiwIqTWsz4/8fVGKpTaZ9MZxxanmLFvoChoBiAkAYC81VGuNewF+cSzjQYBVOzVeQs8C91zjA+ E X-Google-Smtp-Source: AGHT+IHhvvIt+KgvTO9l5R4mcB4EbpcBhhw6Mx5U5GtLiA1CWcOQ0GlWTILJbgfX9YNYLOncwU8dNQ== X-Received: by 2002:a05:6512:39c4:b0:536:a4f1:d214 with SMTP id 2adb3069b0e04-536ac2e705bmr1758118e87.19.1726825025701; Fri, 20 Sep 2024 02:37:05 -0700 (PDT) From: Roger Pau Monne To: xen-devel@lists.xenproject.org Cc: Roger Pau Monne , Ross Lagerwall Subject: [PATCH 2/3] xen/livepatch: do build-id check earlier Date: Fri, 20 Sep 2024 11:36:55 +0200 Message-ID: <20240920093656.48879-4-roger.pau@citrix.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240920093656.48879-1-roger.pau@citrix.com> References: <20240920093656.48879-1-roger.pau@citrix.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @citrix.com) X-ZM-MESSAGEID: 1726825054922116600 The check against the expected Xen build ID should be done ahead of attempt= ing to apply the alternatives contained in the livepatch. If the CPUID in the alternatives patching data is out of the scope of the running Xen featureset the BUG() in _apply_alternatives() will trigger thus bringing the system down. Note the layout of struct alt_instr could also change between versions. It's also possible for struct exception_table_ent= ry to have changed format, hence possibly leading to other errors. Move the Xen build ID check to be done ahead of any processing of the livep= atch payload sections. Signed-off-by: Roger Pau Monn=C3=A9 --- xen/common/livepatch.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/xen/common/livepatch.c b/xen/common/livepatch.c index 8043954ad0fc..a20f9fb2294d 100644 --- a/xen/common/livepatch.c +++ b/xen/common/livepatch.c @@ -765,6 +765,11 @@ static int prepare_payload(struct payload *payload, if ( rc ) return rc; =20 + /* Perform the Xen build-id check ahead of doing any more processing. = */ + rc =3D xen_build_id_dep(payload); + if ( rc ) + return rc; + /* Setup the virtual region with proper data. */ region =3D &payload->region; =20 @@ -1097,10 +1102,6 @@ static int load_payload_data(struct payload *payload= , void *raw, size_t len) if ( rc ) goto out; =20 - rc =3D xen_build_id_dep(payload); - if ( rc ) - goto out; - rc =3D build_symbol_table(payload, &elf); if ( rc ) goto out; --=20 2.46.0