Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp1414654imu; Thu, 13 Dec 2018 14:56:40 -0800 (PST) X-Google-Smtp-Source: AFSGD/Ut518ugneAmJlB39tg3WigqEjLKA83f5AVtR1vuhmYM/qI30ZIhAcLeDJaUiCbe2IO+SiH X-Received: by 2002:a17:902:3124:: with SMTP id w33mr608283plb.241.1544741799984; Thu, 13 Dec 2018 14:56:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544741799; cv=none; d=google.com; s=arc-20160816; b=aZ//YD15+JxKBdDuqTbs1SBz++Xdnkx8GaEW8or0JeFo5VBEIk51tIRsCgVGb8k/9T J88nu1j0dUv634hZPS6/lbn6p3JxGcmjOm4BMU9vXtFuV5RODHlc880TOc+AxyUadOR4 DhIzddOilhsjg0XQFnKJhCvTKdeoI5ZQ57l+Bk5DdBCjN9JacQUTRHI71RD+/bJM8EKW l/A1k6+qWq3h6+oWL5Nk6imJHYdZWpSELgtdERA2StERssFtX5DP5maUx8RPEii/+7Y4 uWFi+f3Rn6UpPKbfeWk0gIhAfo/d/nqHgfr5hSMxxnweRNnuQvTQNNVew2g84E//d9y6 4+DQ== 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; bh=W2+SuKfcq+NLTtYxbNuXpTzDnYj3Ue00kBkpii3SJwk=; b=jJvMUClI3ftJyZPFCuHPDOg+rTQVnjO3hC7wOEG6h3HkGaTFaB3SDSoT+13tiVKeXC fxtdyEtna9mqZvjhdkekIBgGfh7+kCQNgUDEG/a9J5QgSzYVsuZILJErpdJQVsquY7HB ZDnTJfji4kDiGgSLCG3ovpB3jjW66ZE5nAxOEmWX/+qdD+LKPmqZneLGkjCq79hEH/NR nCbeZnxHgq37sfolj40UEPub5RpG6nxDnAZrA2nSmMoI56BzDOXITrjPX/f14r8Xc/SE nHCXEm1HSbg2X/iQsjMXKxMsEloaV6BSApRVCBSqsAA1oACvpS7dhecAODNAJ+8v7e88 qZjA== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s19si2433747plp.151.2018.12.13.14.56.23; Thu, 13 Dec 2018 14:56:39 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727403AbeLMWze (ORCPT + 99 others); Thu, 13 Dec 2018 17:55:34 -0500 Received: from mx1.redhat.com ([209.132.183.28]:46962 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726228AbeLMWze (ORCPT ); Thu, 13 Dec 2018 17:55:34 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D59BD86673; Thu, 13 Dec 2018 22:55:33 +0000 (UTC) Received: from treble (ovpn-120-195.rdu2.redhat.com [10.10.120.195]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 715A226349; Thu, 13 Dec 2018 22:55:30 +0000 (UTC) Date: Thu, 13 Dec 2018 16:55:28 -0600 From: Josh Poimboeuf To: Petr Mladek Cc: Jiri Kosina , Miroslav Benes , Jason Baron , Joe Lawrence , Evgenii Shatokhin , live-patching@vger.kernel.org, linux-kernel@vger.kernel.org, Jessica Yu Subject: Re: [PATCH v14 07/11] livepatch: Add atomic replace Message-ID: <20181213225528.ies3kxjjtzl6dmd3@treble> References: <20181129094431.7801-1-pmladek@suse.com> <20181129094431.7801-8-pmladek@suse.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20181129094431.7801-8-pmladek@suse.com> User-Agent: NeoMutt/20180716 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Thu, 13 Dec 2018 22:55:34 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Nov 29, 2018 at 10:44:27AM +0100, Petr Mladek wrote: > @@ -146,6 +150,7 @@ struct klp_object { > * struct klp_patch - patch structure for live patching > * @mod: reference to the live patch module > * @objs: object entries for kernel objects to be patched > + * @replace: replace all already registered patches "all already registered" -> "all existing" ? since we don't have a concept of "registered" patches anymore. > @@ -415,6 +449,124 @@ static struct attribute *klp_patch_attrs[] = { > NULL > }; > > +/* > + * Dynamically allocated objects and functions. > + */ I don't think this comment is needed. > +static void klp_free_object_dynamic(struct klp_object *obj) > +{ > + kfree(obj->name); > + kfree(obj); > +} > @@ -456,6 +620,8 @@ static void klp_free_funcs(struct klp_object *obj) > if (func->kobj_alive) { > func->kobj_alive = false; > kobject_put(&func->kobj); > + } else if (func->nop) { > + klp_free_func_nop(func); This removes 'func' from the list, so it needs to do a 'safe' list iteration. > } > } > } > @@ -467,8 +633,12 @@ static void klp_free_object_loaded(struct klp_object *obj) > > obj->mod = NULL; > > - klp_for_each_func(obj, func) > + klp_for_each_func(obj, func) { > func->old_func = NULL; > + > + if (func->nop) > + func->new_func = NULL; > + } > } > > static void klp_free_objects(struct klp_patch *patch) > @@ -482,6 +652,8 @@ static void klp_free_objects(struct klp_patch *patch) > if (obj->kobj_alive) { > obj->kobj_alive = false; > kobject_put(&obj->kobj); > + } else if (obj->dynamic) { > + klp_free_object_dynamic(obj); Ditto. > +void klp_discard_replaced_patches(struct klp_patch *new_patch) > +{ > + 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; > + > + old_patch->enabled = false; > + klp_unpatch_objects(old_patch); > + klp_free_patch_start(old_patch); > + schedule_work(&old_patch->free_work); > + } This doesn't need the "safe" list iteration because it doesn't remove the patch from the list. Side note, it would probably be useful to have a klp_for_each_patch() helper. -- Josh