Received: by 10.223.176.46 with SMTP id f43csp440258wra; Fri, 26 Jan 2018 01:09:54 -0800 (PST) X-Google-Smtp-Source: AH8x225jGffclvGqGCtqw+N0vjYiViqXNEGg/UwtkbcpfnOYXMpmJxir5tNu4plnrivstXupAPCM X-Received: by 10.101.64.4 with SMTP id f4mr14748501pgp.171.1516957794644; Fri, 26 Jan 2018 01:09:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516957794; cv=none; d=google.com; s=arc-20160816; b=yWKiV17W2T7ti68rqsGpWIkPy7F1Vqra1XDS29i3onesCBNejBspPeALxwC7imyS2U vOFO7MKSp/1KlDTg9fXHzyWQPo9IDjnOzr6656QwblaMYEiYJd6UqFBAvzQKz8a+uM3J 9bKpc3ErEWZ/lxDtITvBdRQEoq5LTZQs/v4OXtn8FHlZDD0b5XaqqAdpL4UmUEPAAYEf uirDVzAbuVeHnoi5SL6GuZlW0wCHIIpKnPlfbO/q3uK+u2YnUPsRX54lfT6Vf8idmKot xsIm8OZ5EJw3082tPGkqlae5kq7RkIJxMUVvFh6A4NAwZ09FcrClfcAyAvHbAcgYmiR7 rzJg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:arc-authentication-results; bh=tlsUTjG5rjslxW41PbpDRg8zqmz+BWit4lsgAqmFZ1Q=; b=a+eT3B2MamFmTlmJSz/wkdYXraKnu5ei4LO4kgiKlOrpFdkdzmCGI4FB3Q3MawWeNr L7MRjqT9cpBz18ph0dKFrhTg9dBCeZjzS4ah3T/zArlJu9RaTiT3vEiuhfO+G3jm8b8P BtG0F2UtnQju4E6VRnCtI2JCS5CGtbVYaVV42lgpw7eD8CMxyQhmPVi03OOcD0/jnxr2 +BcpupacXYCITLHfDZdmes/29leIZy4GPvD1nVXil7tNYyWs1qY//rg5V3EkOaYYDy/7 ryqrXItgaFreOdp2j+PCEfaQJ9RKlubHhFUdQqfxCDcniCmBvv8/+zA4uSoGtTbbTQVd n/Eg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v11-v6si3471496plz.285.2018.01.26.01.09.40; Fri, 26 Jan 2018 01:09:54 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752775AbeAZJJL (ORCPT + 99 others); Fri, 26 Jan 2018 04:09:11 -0500 Received: from mx2.suse.de ([195.135.220.15]:33317 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752642AbeAZJJD (ORCPT ); Fri, 26 Jan 2018 04:09:03 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 7BFBFABD0; Fri, 26 Jan 2018 09:09:02 +0000 (UTC) Date: Fri, 26 Jan 2018 10:09:01 +0100 From: Petr Mladek To: Jason Baron Cc: jpoimboe@redhat.com, jikos@kernel.org, mbenes@suse.cz, jeyu@kernel.org, Evgenii Shatokhin , linux-kernel@vger.kernel.org, live-patching@vger.kernel.org Subject: Re: PATCH v6 6/6] livepatch: Add atomic replace Message-ID: <20180126090901.z36n2tn67b2nz75m@pathway.suse.cz> References: <20180125160203.28959-1-pmladek@suse.com> <20180125160203.28959-7-pmladek@suse.com> <693db35b-3bc8-d5de-207e-6321226d7f58@akamai.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <693db35b-3bc8-d5de-207e-6321226d7f58@akamai.com> User-Agent: NeoMutt/20170421 (1.8.2) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu 2018-01-25 23:27:57, Jason Baron wrote: > On 01/25/2018 11:02 AM, Petr Mladek wrote: > > From: Jason Baron > > A better solution would be to create cumulative patch and say that > > it replaces all older ones. > > > > Signed-off-by: Jason Baron > > [pmladek@suse.com: Split, reuse existing code, simplified] > > Hi Petr, > > Thanks for cleaning this up - it looks good. Uff, I feel relief :-) > > diff --git a/kernel/livepatch/core.c b/kernel/livepatch/core.c > > index 6ad3195d995a..c606b291dfcd 100644 > > --- a/kernel/livepatch/core.c > > +++ b/kernel/livepatch/core.c > > +/* > > + * This function removes replaced patches from both func_stack > > + * and klp_patches stack. > > + * > > + * We could be pretty aggressive here. It is called in situation > > + * when these structures are not longer accessible. All functions > > + * are redirected using the klp_transition_patch. They use either > > + * a new code or they in the original code because of the special > > + * nop function patches. > > + */ > > +void klp_throw_away_replaced_patches(struct klp_patch *new_patch, > > + bool keep_module) > > +{ > > + struct klp_patch *old_patch, *tmp_patch; > > + > > + list_for_each_entry_safe(old_patch, tmp_patch, &klp_patches, list) { > > + if (old_patch == new_patch) > > + return; > > + > > + klp_unpatch_objects(old_patch, KLP_FUNC_ANY); > > + old_patch->enabled = false; > > + > > + /* > > + * Replaced patches could not get re-enabled to keep > > + * the code sane. > > + */ > > + list_del_init(&old_patch->list); > > I'm wondering if this should be: > > list_move(&old_patch->list, &klp_replaced_patches); Yes, great catch! The list_del() comes from one iteration where I got rid of the extra list. I though that it might be enough to check patch->kobj.state_initialized. But then I realized that this kobject state was modified outside klp_mutex. To be honest, I did not only minimal testing with my changes. Mirek promised to port a battery of his kGraft-based tests and run it. Thanks a lot for review. Best Regards, Petr