Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751399AbdH3OUa (ORCPT ); Wed, 30 Aug 2017 10:20:30 -0400 Received: from mx1.redhat.com ([209.132.183.28]:52440 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751359AbdH3OU3 (ORCPT ); Wed, 30 Aug 2017 10:20:29 -0400 DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com E30D381DE2 Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=jpoimboe@redhat.com Date: Wed, 30 Aug 2017 09:20:25 -0500 From: Josh Poimboeuf To: Joe Lawrence Cc: live-patching@vger.kernel.org, linux-kernel@vger.kernel.org, Jessica Yu , Jiri Kosina , Miroslav Benes , Petr Mladek , Chris J Arges Subject: Re: [PATCH v4 1/3] livepatch: add (un)patch callbacks Message-ID: <20170830142025.gjvyo23xt3uzyt7u@treble> References: <1503688202-12121-1-git-send-email-joe.lawrence@redhat.com> <1503688202-12121-2-git-send-email-joe.lawrence@redhat.com> <20170829154902.sw7r4k3ofo7hv4ev@treble> <20170829195912.m7wdoymu7fjmoioi@treble> <20170830132716.6tdjkfafpuay36cs@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20170830132716.6tdjkfafpuay36cs@redhat.com> User-Agent: Mutt/1.6.0.1 (2016-04-01) X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Wed, 30 Aug 2017 14:20:29 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1415 Lines: 38 On Wed, Aug 30, 2017 at 09:27:16AM -0400, Joe Lawrence wrote: > > So instead of 'obj->pre_patch_callback_done', how about > > 'obj->callbacks_enabled'? > > > > It could be set in the following cases: > > > > a) if the object has a pre_patch callback, set obj->callbacks_enabled > > after the pre_patch callback succeeds; > > > > b) else, if the patch does *not* have a pre_patch callback, set > > obj->callbacks_enabled after klp_patch_object() succeeds. > > > > And the variable would need to be cleared after the post_unpatch > > callback was run. > > > > It's a bit complicated, but that seems to be the most logicial behavior > > as far as I can tell. > > > > Thoughts? > > What if we flip it around as "callbacks_disabled"? By default, kzalloc > would init as false. It would only be set to true if the pre-patch > callback is provided and if it returns failure. Would that reduce the > number of conditions when we need to set this var? Yeah, 'callbacks_disabled' sounds better. > Also, as you noted, I think it would need to reset/cleared after the > post-patch callback. (For the livepatch-already-loaded cases.) Since it can only be set when the pre-patch fails, I think it would only need to be cleared after post-unpatch? Or another alternative would be to unconditionally clear and/or set it in klp_pre_patch_callback() so that its previous value doesn't matter. -- Josh