From nobody Sun Dec 22 01:23:25 2024 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=1727253811; cv=none; d=zohomail.com; s=zohoarc; b=Q4PmIQG+7IBgXTNidWkoH1wlTHhUl6PmTM2BPZGs7t2TUGhQUG2nDF+nqF9rf/J2CtuuQBZEosR30e5pBxLKFVc/4X3+ohiSEQ8LpdQlZFcgwAFpOnKSAdRMx4uAkR7zqK41YDz4/YBLnfSVITHSE5hNeouBmcTFs+Yxc5PDvRs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1727253811; 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=VmANCqOCNLuCE6WgFe5IkbUtz4Dl4MOkNZ8FdlMteZ4=; b=X3ndWyg2t2O/w9faM1anKyD/IFOvGGjnXDjvDoASwutRhZM8ja2lIt3LLmEiynfvMjNkMKgcZzSBh75qfgx69SEFChtMhzNnnpSuaj0uXdDvdJrJ0SZcwP084aO41LIiUVKvY9BohkQLnf6HjKMvPoqAIZ39IjqhRBr203wuQwg= 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 1727253811969221.3064452946129; Wed, 25 Sep 2024 01:43:31 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.803573.1214239 (Exim 4.92) (envelope-from ) id 1stNc4-0005cq-LZ; Wed, 25 Sep 2024 08:43:08 +0000 Received: by outflank-mailman (output) from mailman id 803573.1214239; Wed, 25 Sep 2024 08:43:08 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1stNc4-0005ch-Fv; Wed, 25 Sep 2024 08:43:08 +0000 Received: by outflank-mailman (input) for mailman id 803573; Wed, 25 Sep 2024 08:43:06 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1stNc2-0005NX-St for xen-devel@lists.xenproject.org; Wed, 25 Sep 2024 08:43:06 +0000 Received: from mail-ed1-x52c.google.com (mail-ed1-x52c.google.com [2a00:1450:4864:20::52c]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 2e87d1c4-7b1a-11ef-99a2-01e77a169b0f; Wed, 25 Sep 2024 10:43:05 +0200 (CEST) Received: by mail-ed1-x52c.google.com with SMTP id 4fb4d7f45d1cf-5c5b9d2195eso5114209a12.1 for ; Wed, 25 Sep 2024 01:43:05 -0700 (PDT) Received: from localhost ([213.195.124.163]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5c5cf4974a6sm1620662a12.39.2024.09.25.01.43.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Sep 2024 01:43:03 -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: 2e87d1c4-7b1a-11ef-99a2-01e77a169b0f DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=citrix.com; s=google; t=1727253784; x=1727858584; 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=VmANCqOCNLuCE6WgFe5IkbUtz4Dl4MOkNZ8FdlMteZ4=; b=V+Pl2q8YhftYc7znEWOsw7Xd/KvnbmQRt5JLV77HKkG+ZnsOdh9kDr/J6nVOf+Xcyc msNW00PK6wTLTXfsYLo9kuDnC4YoJzOdY4iZ0psTTIgU8QpNgAcEfSyvnxxtkxksQNUs eqQI4HWvzt/nFsJFmVujUgw62etdBQ8rbvAmY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727253784; x=1727858584; 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=VmANCqOCNLuCE6WgFe5IkbUtz4Dl4MOkNZ8FdlMteZ4=; b=Oipwomul/FYBhcCj0A/fFS+rf6soUu+VL2CTtj3a7GxoyzWkW2nDplq+USvzdaa3+U XV/jhSX0u6UDu+Y55ekmPUAbYx1LszHrGYHjhqrXJ0rEZfJp5Q9eRAiyIqXnFmUODif4 OEpy96PxsJvEkSgQUFq1y06S1aWwd+7sBODQa0Kp5abYuwkEb9uQ8uUod3gEPQbM3360 umu8P7hK7k+Mn+0RWm+Gn2LnczrpKpL+4MbxPB2C6xGo8lTPqjX1wR4jZZ8NNy0aqaaj YU+nah5SO9SiuKH5gmTZ8FPhWeOHVBW/ZNBLuQuAAJFncOjtZPWq/5ybMyfNAKEp/atM 6/OA== X-Gm-Message-State: AOJu0YyaVz91cMZgwHgvKxUwBmPL3FL0iG2s0Cp26dSd1V3yajMDI9Ex hXdpvGM8z3mlLneepbuA+f+K+tt3noiFF1Kw7+HTyHNM3yF/xRuHAjujRgaCsq7mRERvDNOk3dQ k X-Google-Smtp-Source: AGHT+IHcKk7PadNzltiCJe7/SxHQQeAdUrJQe22On1AgtTHr+7rrO+39rxXpoqDaHmR24SJX5+V7XQ== X-Received: by 2002:a05:6402:4416:b0:5c5:c5c0:74ec with SMTP id 4fb4d7f45d1cf-5c7206449d6mr1554436a12.24.1727253784120; Wed, 25 Sep 2024 01:43:04 -0700 (PDT) From: Roger Pau Monne To: xen-devel@lists.xenproject.org Cc: Roger Pau Monne , Ross Lagerwall Subject: [PATCH v2 1/6] xen/livepatch: remove useless check for duplicated sections Date: Wed, 25 Sep 2024 10:42:34 +0200 Message-ID: <20240925084239.85649-2-roger.pau@citrix.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240925084239.85649-1-roger.pau@citrix.com> References: <20240925084239.85649-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: 1727253812190116600 The current check for duplicated sections in a payload is not effective. S= uch check is done inside a loop that iterates over the sections names, it's logically impossible for the bitmap to be set more than once. The usage of a bitmap in check_patching_sections() has been replaced with a boolean, since the function just cares that at least one of the special sections is present. No functional change intended, as the check was useless. Fixes: 29f4ab0b0a4f ('xsplice: Implement support for applying/reverting/rep= lacing patches.') Fixes: 76b3d4098a92 ('livepatch: Do not enforce ELF_LIVEPATCH_FUNC section = presence') Signed-off-by: Roger Pau Monn=C3=A9 Reviewed-by: Andrew Cooper and I'm very --- Changes since v1: - New in this version. --- xen/common/livepatch.c | 19 +++---------------- 1 file changed, 3 insertions(+), 16 deletions(-) diff --git a/xen/common/livepatch.c b/xen/common/livepatch.c index d93a556bcda2..df41dcce970a 100644 --- a/xen/common/livepatch.c +++ b/xen/common/livepatch.c @@ -473,7 +473,6 @@ static int check_special_sections(const struct livepatc= h_elf *elf) static const char *const names[] =3D { ELF_LIVEPATCH_DEPENDS, ELF_LIVEPATCH_XEN_DEPENDS, ELF_BUILD_ID_NOTE}; - DECLARE_BITMAP(found, ARRAY_SIZE(names)) =3D { 0 }; =20 for ( i =3D 0; i < ARRAY_SIZE(names); i++ ) { @@ -493,13 +492,6 @@ static int check_special_sections(const struct livepat= ch_elf *elf) elf->name, names[i]); return -EINVAL; } - - if ( test_and_set_bit(i, found) ) - { - printk(XENLOG_ERR LIVEPATCH "%s: %s was seen more than once\n", - elf->name, names[i]); - return -EINVAL; - } } =20 return 0; @@ -517,7 +509,7 @@ static int check_patching_sections(const struct livepat= ch_elf *elf) ELF_LIVEPATCH_PREREVERT_HOOK, ELF_LIVEPATCH_REVERT_HOOK, ELF_LIVEPATCH_POSTREVERT_HOOK}; - DECLARE_BITMAP(found, ARRAY_SIZE(names)) =3D { 0 }; + bool found =3D false; =20 /* * The patching sections are optional, but at least one @@ -544,16 +536,11 @@ static int check_patching_sections(const struct livep= atch_elf *elf) return -EINVAL; } =20 - if ( test_and_set_bit(i, found) ) - { - printk(XENLOG_ERR LIVEPATCH "%s: %s was seen more than once\n", - elf->name, names[i]); - return -EINVAL; - } + found =3D true; } =20 /* Checking if at least one section is present. */ - if ( bitmap_empty(found, ARRAY_SIZE(names)) ) + if ( !found ) { printk(XENLOG_ERR LIVEPATCH "%s: Nothing to patch. Aborting...\n", elf->name); --=20 2.46.0