[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] livepatch: account for patch offset when applying NOP patch
- To: Roger Pau Monné <roger.pau@xxxxxxxxxx>
- From: Jan Beulich <jbeulich@xxxxxxxx>
- Date: Wed, 30 Mar 2022 12:43:48 +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=f6G8ov2OQZezSXYL4zu8Fe5J/pEDAfYS//mEASkyFCE=; b=EIrBKf9nQsdVWjuBy8TsqJ9ytHUX89NVS//8Jo1PqCvjpFucnG/H0vArlmE0zeYCVQ6iLhlduHdzxKYaTZ2k4ZTUGlKJkwqyX4z0YF1YPTvSi/r97xpBZq6UCF15Jbby6ys2Owzb2tPrJadviN9xn5YbTit8EDORfAxGF1LaZO/SaH+yMrBNAkPZdNygaG7IQixruFL5vmYdKQCDN6vp2n20nIYOTd69WDrT0R/yv7rcXIWioi8NBo7H8R/m8o9YMKSRfsIMY5p0LiV2So62wB1kZlqdDQXO/bGQPcDzbteMhm4ZTHI2FKL3oWmu3m/dbEzgg2rS06f2P4MnPyromQ==
- Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=O1/hZcttWNrpoyZ1egoMUIzbyk5YuUrNIivIuGVtscPiOsVyJccE4Dz0G5WAfMKjjXarfIRyBC1zkfxfY7WK8SYjSvewBMEuAlcHaJoBihkqNQVeibE3MOeMYfBDHxExvHFoQYWkysDX/SFMQKTjBn75Tnoz/jnbtK2498EgN2AJqJgXsyiqK7KuRtgXsMN7ttdRSTy7/U6J0WRWgoA6zzwA4wa4syaBQABz3uUKMsGzKiEwyhX/4SMhhWYI3S6SBrrJVIHjw8XlsjuvDLngwSi6JxMwCqPUQ6F33+K9Ke0I7fJ/qyldHBOwHAogafQvsXNiNoh+a93D4doPDy69Lw==
- Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com;
- Cc: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>, Ross Lagerwall <ross.lagerwall@xxxxxxxxxx>, Konrad Wilk <konrad.wilk@xxxxxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
- Delivery-date: Wed, 30 Mar 2022 10:43:54 +0000
- List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
On 30.03.2022 12:19, Roger Pau Monné wrote:
> On Wed, Mar 30, 2022 at 10:03:11AM +0200, Jan Beulich wrote:
>> 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;
>> }
>
> Don't you also need to move the call to livepatch_insn_len() in
> arch_livepatch_apply() after func->patch_offset has been adjusted to
> account for ENDBR presence?
Oh, yes, I definitely need to.
Jan
|