From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755755AbcGHQ5y (ORCPT ); Fri, 8 Jul 2016 12:57:54 -0400 Received: from mx1.redhat.com ([209.132.183.28]:40484 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755171AbcGHQ5p (ORCPT ); Fri, 8 Jul 2016 12:57:45 -0400 Date: Fri, 8 Jul 2016 12:57:40 -0400 From: Jessica Yu To: Christopher Arges Cc: Josh Poimboeuf , Miroslav Benes , Petr Mladek , Jiri Kosina , Eugene Shatokhin , live-patching@vger.kernel.org, x86@kernel.org, linux-kernel@vger.kernel.org Subject: Re: Fix issue with alternatives/paravirt patches Message-ID: <20160708165740.GA20248@packer-debian-8-amd64.digitalocean.com> References: <1467772500-26092-1-git-send-email-jeyu@redhat.com> <20160708052222.GA1549@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: <20160708052222.GA1549@gmail.com> X-OS: Linux eisen.io 3.16.0-4-amd64 x86_64 User-Agent: Mutt/1.5.23 (2014-03-12) X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Fri, 08 Jul 2016 16:57:44 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org +++ Christopher Arges [08/07/16 00:22 -0500]: >On Tue, Jul 05, 2016 at 10:34:58PM -0400, Jessica Yu wrote: >> Hi, >> >> A few months ago, Chris Arges reported a bug involving alternatives/paravirt >> patching that was discussed here [1] and here [2]. To briefly summarize the >> bug, patch modules that contained .altinstructions or .parainstructions >> sections would break because these alternative/paravirt patches would be >> applied first by the module loader (see x86 module_finalize()), then >> livepatch would later clobber these patches when applying per-object >> relocations. This lead to crashes and unpredictable behavior. >> >> One conclusion we reached from our last discussion was that we will >> need to introduce some arch-specific code to address this problem. >> This patchset presents a possible fix for the bug by adding a new >> arch-specific arch_klp_init_object_loaded() function that by default >> does nothing but can be overridden by different arches. >> >> To fix this issue for x86, since we can access a patch module's Elf >> sections through mod->klp_info, we can simply delay the calls to >> apply_paravirt() and apply_alternatives() to arch_klp_init_object_loaded(), >> which is called after relocations have been written for an object. >> In addition, for patch modules, .parainstructions and .altinstructions are >> prefixed by ".klp.arch.${objname}" so that the module loader ignores them >> and livepatch can apply them manually. >> >> Currently for kpatch, we don't support including jump table sections in >> the patch module, and supporting .smp_locks is currently broken, so we >> don't consider those sections (for now). >> >> I did some light testing with some patches to kvm and verified that the >> original issue reported in [2] was fixed. >> >> Based on linux-next. >> > >Jessica, > >I was able to test these patches on top of linux-next. I took your kpatch >branch and hacked it a bit to get it working and was able to >apply a patch to 'kvm_arch_vm_ioctl' while running a VM workload. > >Great job! > >Tested-by: Chris J Arges Excellent, thanks for testing it out Chris! Jessica