Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp1409335imu; Thu, 13 Dec 2018 14:48:57 -0800 (PST) X-Google-Smtp-Source: AFSGD/VDLAjr8eSENpBvWK4oBJe5Jd0zxB2WLVEiHnMvGMW3Nsy/QmRlUjG1QlDIz5DAGNmRUy5r X-Received: by 2002:a17:902:7588:: with SMTP id j8mr597566pll.215.1544741337072; Thu, 13 Dec 2018 14:48:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544741337; cv=none; d=google.com; s=arc-20160816; b=cp7liJdrLe1YdWg7DZLu+d+kEFlHhLHpHb/OSdaudEoLuqp0+fH16bCsEBlGtwqIsA 0pkec7WwXtux5ctiEwfceugaIltpURAcWBwLbJDcMsL0xmw/cryOsGzCbbNnZ43Jo7Gq BajBDul3zuD7vnHmpzfykNn5kL97VgKLeInz5ofIcY1N/Ff92GBAkUvah0Kv4XilbCjI EJsahK3HHoHCi2vkOP/cYv66pBtTe2fcuXHbF0NbIHaBDlAkvHOoC7AHPx8wfpuLsPvU YdmrQ7lgFhXEOeJB4epm/WTrSQT6LCDsSjiKelJgAwfEZRGVTcmKbN1FtDXddr7pNeKq B17A== 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=yHJgJaGDvh5mf0OEq1wcZtzf0piqZo6vSUvkkw4TzrE=; b=NkIwCrZXySr716uE2v32tNV5QtG/mDwcNAZ5dQRddyfzNTA4VKblumz88cnPdWbBjO 1SenGu3ynUP+3BJhDQRQ7f8BzPaVvwYOo/Xl7YWG8hVRPY17ngqpJM/KXMKf49u9nQKF p/wz4c85fO46feJ3SZVNgjDF7sTibQx0yomJFAv7m80wOL1qU92HA4djHCdrzq2Y1nOE UmbzUoxwD2KeFbUbdhfThByF76E1ogbICltYFbmdgDi8Le6J5IG6AndOeMYndj2oxYYM 0DbghtJ/lyOVIkeh3G7D1ayDkQnFeVZY+Zdup+O3TFQLdhf28uOtOVcloJDbCsVItbgw Yr2w== 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 2si2430660pgz.395.2018.12.13.14.48.41; Thu, 13 Dec 2018 14:48:57 -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 S1727928AbeLMWqd (ORCPT + 99 others); Thu, 13 Dec 2018 17:46:33 -0500 Received: from mx1.redhat.com ([209.132.183.28]:38646 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726457AbeLMWqc (ORCPT ); Thu, 13 Dec 2018 17:46:32 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 57392300207A; Thu, 13 Dec 2018 22:46:32 +0000 (UTC) Received: from treble (ovpn-120-195.rdu2.redhat.com [10.10.120.195]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D829760FE5; Thu, 13 Dec 2018 22:46:27 +0000 (UTC) Date: Thu, 13 Dec 2018 16:46:25 -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 Subject: Re: [PATCH v14 05/11] livepatch: Simplify API by removing registration step Message-ID: <20181213224625.65o77z75u4njocnp@treble> References: <20181129094431.7801-1-pmladek@suse.com> <20181129094431.7801-6-pmladek@suse.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20181129094431.7801-6-pmladek@suse.com> User-Agent: NeoMutt/20180716 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.47]); Thu, 13 Dec 2018 22:46:32 +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:25AM +0100, Petr Mladek wrote: > @@ -309,40 +297,33 @@ static ssize_t enabled_store(struct kobject *kobj, struct kobj_attribute *attr, > > mutex_lock(&klp_mutex); > > - if (!klp_is_patch_registered(patch)) { > - /* > - * Module with the patch could either disappear meanwhile or is > - * not properly initialized yet. > - */ > - ret = -EINVAL; > - goto err; > - } > - > if (patch->enabled == enabled) { > /* already in requested state */ > ret = -EINVAL; > - goto err; > + goto out; > } > > - if (patch == klp_transition_patch) { > + /* > + * Allow to reverse a pending transition in both ways. It might be > + * necessary to complete the transition without forcing and breaking > + * the system integrity. > + * > + * Do not allow to re-enable a disabled patch because this interface > + * is being destroyed. > + */ > + if (patch == klp_transition_patch) > klp_reverse_transition(); > - } else if (enabled) { > - ret = __klp_enable_patch(patch); > - if (ret) > - goto err; > - } else { > + else if (!enabled) > ret = __klp_disable_patch(patch); > - if (ret) > - goto err; > - } > + else > + ret = -EINVAL; Now that we can't re-enable a patch, I wonder if we really need both the 'patch->enabled' and 'klp_target_state' variables? A patch is now always enabled, unless it's in transition, in which case its 'enabled' state is the same as 'klp_target_state'. For example I wonder if we could get rid of 'klp_target_state', since it should be the same as 'klp_transition_patch->enabled'. Or alternatively we could get rid of 'patch->enabled', since it should be the same as patch == klp_transition_patch ? klp_target_state : true Of course this could be a follow-on cleanup patch, which could be done in the future, so as not to hold up the merging of these patches anymore. -- Josh