Received: by 10.213.65.68 with SMTP id h4csp1197266imn; Wed, 14 Mar 2018 12:33:33 -0700 (PDT) X-Google-Smtp-Source: AG47ELsjpjxhqnvRqSCKmk9lbBvN2iKG1H/rsrKzPX+4ZxKiG/QOx/fjvVpTrZa5AxPTxub/9l68 X-Received: by 2002:a17:902:7b92:: with SMTP id w18-v6mr5218783pll.159.1521056013337; Wed, 14 Mar 2018 12:33:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521056013; cv=none; d=google.com; s=arc-20160816; b=eZj5ivBg+6Q+bjb8xC/tX4VsV/6ecKSPCcX8uR5t12XsIwSwVcerPkGXr6sSQyvXTh GOh2j05F7TaTtbOPeXqWGQiDe+v2tZBwaYF347AlAhayYEFSbGWHzoU01UxmSl0S5cRQ bhG3KW2icJ/2AptKZLJYgTFJN9vutBRwxs2dqJJcLq0x3+M+JJCTuvaBdQcQhUVOqfGx 80bRStMeAsbNuqSiZOdY3Fw9FAIrHTOei4fofkHdsm1v3Pdke8K62kcMULerB8/4Zctn j2HmDqEpgQ+n/ZM6n+diILpgdav7twaKl6a37MtrwOGR8CDrkymoM/hOvifXQmZ+rKKt 0isg== 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=DvDkmDnzoKBl+Vnp2sQTlOEf2kPPEZciQbRElXOw3wE=; b=sBado1iEG7IdIQQ/p9IKW+bzgG+XkZldt00Vg97uNiF/446ELKQQyoshlLOGhp08Rv CnzrvjN/VNe3diS9AN5kX48ko5M3sq7fjAf5NSZ9pjfDV45XVz/PWAZ9fU5ph8FynSb1 CSSUwsX7pltoeksVTM62a2cNpvDT1SHM5+0U588xVEzqK01mWJtubhxq0ubKnaG1Wrdb Nnx8Y1Dt4goSqIXVvfB8/axuVp6O7PcZA4iZyOvWzJ81T3JzdqDmSLDlqLTrsYKG1JUP B3hdpua+y9J9SwBokwdBJT8NR3Firso5S2IHZcl+hzWxC1OOSpwafOhk73rBifSKujCQ YC1w== 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 o7si2268416pgs.314.2018.03.14.12.33.16; Wed, 14 Mar 2018 12:33:33 -0700 (PDT) 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 S1751314AbeCNTcW (ORCPT + 99 others); Wed, 14 Mar 2018 15:32:22 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:38084 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1750779AbeCNTcV (ORCPT ); Wed, 14 Mar 2018 15:32:21 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 6898680AD238; Wed, 14 Mar 2018 19:32:20 +0000 (UTC) Received: from treble (ovpn-122-218.rdu2.redhat.com [10.10.122.218]) by smtp.corp.redhat.com (Postfix) with SMTP id A42936F9E3; Wed, 14 Mar 2018 19:32:17 +0000 (UTC) Date: Wed, 14 Mar 2018 14:32:17 -0500 From: Josh Poimboeuf To: Petr Mladek Cc: Jiri Kosina , Miroslav Benes , Joe Lawrence , Jessica Yu , Nicolai Stange , live-patching@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 2/2] livepatch: Allow to unregister or free shadow data using a custom function Message-ID: <20180314193217.jl2pkzikzrk7wgpz@treble> References: <20180313155448.1998-1-pmladek@suse.com> <20180313155448.1998-3-pmladek@suse.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20180313155448.1998-3-pmladek@suse.com> User-Agent: Mutt/1.6.0.1 (2016-04-01) X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Wed, 14 Mar 2018 19:32:20 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Wed, 14 Mar 2018 19:32:20 +0000 (UTC) for IP:'10.11.54.5' DOMAIN:'int-mx05.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'jpoimboe@redhat.com' RCPT:'' Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Mar 13, 2018 at 04:54:48PM +0100, Petr Mladek wrote: > We might need to do some actions before the shadow variable is freed. > For example, we might need to remove it from a list or free some data > that it points to. > > This is already possible now. The user can get the shadow variable > by klp_shadow_get(), do the necessary actions, and then call > klp_shadow_free(). > > This patch allow to do this a more elegant way. The user could implement > the needed actions in a callback that is passed to klp_shadow_free() > as a parameter. The callback usually does reverse operations to > the init_func that can be called by klp_shadow_*alloc(). > > It is especially useful for klp_shadow_free_all(). There we need to do > these extra actions for each found shadow variable with the given ID. > > Note that the memory used by the shadow variable itself is still released > later by rcu callback. It is needed to protect internal structures that > keep all shadow variables. But free_func is called immediately. The shadow > variable must not be access anyway after klp_shadow_free() is called. > The user is responsible to protect this any suitable way. > > Be aware that free_func callback is called under klp_shadow_lock. It is > the same as for init_func in klp_shadow_alloc(). > > Signed-off-by: Petr Mladek Makes sense, though I'm not sure "free" is the right name: a) "free" isn't the opposite of "init"; and b) it may be used for things other than freeing. Shall we call them constructor/destructor? -- Josh