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

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


  • To: Roger Pau Monné <roger.pau@xxxxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Thu, 31 Mar 2022 10:13:06 +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=/zYxYLTnzn1V59BnPmiQzSwpnOVQR8kmt6PHQpu9ff4=; b=TSnm/9hANDxNu/6HvXidAhB6leHlSPIskJImMTu9DMhjjsVwmpMABc7Ez7XR1ddZSIcH13IXXaVxt9xLoUTzY/F7mFaY64NpiZjrjrbCwTWgOXbdsTP05PnXaxQpUoAQ3QayHJ/UgPuxT51xbbUzxGOb5xmbyq3BXhwXBf4Z1yHg8lYKGzgFRD6BA5NNPABDszof5+ox9Dy4F7U1ggC6aBnm0Mjc+3Ld9qoWDujvGG5hIlVfthhVJwRd9FkJqk8Swz64ygIJXuoeiI/wmJKbLggng0P2tKhWKyZfJ/IIa+QPFprm3cAANWGvk/Y+0NARtOgSMfAKyW2htamGWbjj+A==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Gtz2jJD1b7bIzGcV2lBFDmqMYnrUcLAjSfGjSmyxZguRLVUts83jZhAgrPeY7AbmY/DbsuRHK7gKZ7qoNlqQ878OR4OKEP0kWpjCTtmKcv2vqEJozhiI7SFlbAQmoDKzZtu1mBlF+y0rBcDgM8318NViU5Pj7HLLrmbnRM+TCBuJGYIMfXfBtPSxGAlVB1tuYa1drpGkyIRQtMOU33RCh5nSHEYcZhoN2h91D/Jl2eb6/3IZZ2rI+GCo+2uwKlSOUGA8/Nm5c2eUzpiOCodeaE4PdKOXnIwI5sWqNVz5w6enMgqd9miMxVDTdJWcJG0Xr2fJWuVqOMemOSEiC7eZGw==
  • 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>, Wei Liu <wl@xxxxxxx>, Bjoern Doebel <doebel@xxxxxxxxx>
  • Delivery-date: Thu, 31 Mar 2022 08:13:39 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 31.03.2022 10:01, Roger Pau Monné wrote:
> On Thu, Mar 31, 2022 at 08:42:47AM +0200, Jan Beulich wrote:
>> On 30.03.2022 19:04, Roger Pau Monné wrote:
>>> On Wed, Mar 30, 2022 at 01:05:31PM +0200,>> --- a/xen/arch/x86/livepatch.c
>>>> +++ b/xen/arch/x86/livepatch.c
>>>> @@ -157,9 +157,15 @@ void noinline arch_livepatch_apply(struc
>>>>       * loaded hotpatch (to avoid racing against other fixups 
>>>> adding/removing
>>>>       * ENDBR64 or similar instructions).
>>>>       */
>>>> -    if ( is_endbr64(old_ptr) || is_endbr64_poison(func->old_addr) )
>>>> +    if ( len >= ENDBR64_LEN &&
>>>
>>> Sorry, didn't realize before, but shouldn't this check be using
>>> old_size instead of len (which is based on new_size)?
>>
>> Yes and no: In principle yes, but with len == func->new_size in the NOP
>> case, and with arch_livepatch_verify_func() guaranteeing new_size <=
>> old_size, the check is still fine for that case. Plus: If new_size was
>> less than 4 _but_ there's an ENDBR64 at the start, what would we do? I
>> think there's more that needs fixing in this regard. So I guess I'll
>> make a v3 with this extra fix dropped and with the livepatch_insn_len()
>> invocation simply moved. After all the primary goal is to get the
>> stable trees unstuck.
> 
> Right, I agree to try and get the stable trees unblocked ASAP.
> 
> I think the check for ENDBR is only relevant when we are patching the
> function with a jump, otherwise the new replacement code should
> contain the ENDBR instruction already?

No, the "otherwise" case is when we're NOP-ing out code, i.e. when
there's no replacement code at all. In this case we need to leave
intact the ENDBR, and new_size being less than 4 is bogus afaict in
case there actually is an ENDBR.

Jan




 


Rackspace

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