Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp2022733ybi; Thu, 18 Jul 2019 02:09:51 -0700 (PDT) X-Google-Smtp-Source: APXvYqxnD2WXeoZ1WVHzRooaiL2ie4HeLEUUQxVNQNWsmiAfmKzeaePhuuPu7Z/Vbh+Dsxx95Po0 X-Received: by 2002:a17:90a:1ac5:: with SMTP id p63mr48864134pjp.25.1563440991105; Thu, 18 Jul 2019 02:09:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563440991; cv=none; d=google.com; s=arc-20160816; b=EiwQmCwnaNa5GZHATU/a1vMRoJzI5pWw8QyqZFWB8MY7KZddfYBmM98f2vo69bbd5e H4AqUZyYQanMyNR1hoxUURUx1LZD6X6T185Rm0ZWuYgDEia9hogqEgtAv4awhGJNQnFG Rp/6wPmmyg2Tzivltum9Z0ArBkDzAcykv/SHJVK0MwF7njfgsNvqkMjA9poNDtnELvSz u1MypVcCWmZPMmpIrodlXniCtU6A5F+HVoMJ++LLI2QNh8WzR5ylDaKXMgm/Iwk2bsdA KucWDidiJH/3yh05Gkdm9sUhg6vHhLI6NGEGD+VsdayxQ9/N+p1wio9NKNPyK5Uob8K4 fZ9w== 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=nN6/8QBZDm8fW8vvDheQPpnlE5KD2r15wli6gCU+0+A=; b=dG7mjBkbFCWW69swezknUcYaeYan2PDkt63VQUzNpr1mR+04zxu0LwfFBClLtK7SPD CzrKkrtk0RydpGTWmIpJZDVULqk+TteZBnvyPOkESm9r3o5tcIXWbsvhBi6F201kpu7h B/WTjrnUn/+KyK5YcDL1K9mkd47eJ4jeBXsj65sVQGlquCRqu12vIQOIpnS8wP9E+sir MRslKkIJU9Of2wvkFblABgVBQqaIzc9Xpy/uNucUoGGGG4KqNNBGZaEgKuTBXEF5i4Id WTrDN3AtBZuVSueuwToRWM4AVmH7z9ZQoaxPQFPxYkSp98yl71XhwRpqF6MDdW//gz6i 4Tug== 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 x4si25575121pln.70.2019.07.18.02.09.34; Thu, 18 Jul 2019 02:09:51 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389453AbfGRJIC (ORCPT + 99 others); Thu, 18 Jul 2019 05:08:02 -0400 Received: from mx2.suse.de ([195.135.220.15]:52048 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726513AbfGRJIB (ORCPT ); Thu, 18 Jul 2019 05:08:01 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id B9942AF95; Thu, 18 Jul 2019 09:08:00 +0000 (UTC) Date: Thu, 18 Jul 2019 11:08:00 +0200 From: Petr Mladek To: Jiri Kosina , Josh Poimboeuf , Miroslav Benes Cc: Joe Lawrence , Kamalesh Babulal , Nicolai Stange , live-patching@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [RFC 3/5] livepatch: Allow to distinguish different version of system state changes Message-ID: <20190718090800.gd2neswknsnmey2h@pathway.suse.cz> References: <20190611135627.15556-1-pmladek@suse.com> <20190611135627.15556-4-pmladek@suse.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190611135627.15556-4-pmladek@suse.com> User-Agent: NeoMutt/20170912 (1.9.0) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue 2019-06-11 15:56:25, Petr Mladek wrote: > It might happen that an older change is not enough and the same system > state has to be modified another way. Different changes need to get > distinguished by a version number added to struct klp_state. > > The version can also be used to prevent loading incompatible livepatches. > The check is done when the livepatch is enabled. The rules are: > > + Any completely new system state modification is allowed. > > + System state modifications with the same or higher version are allowed > for already modified system states. > > + Cumulative livepatches must handle all system state modifications from > already installed livepatches. > > + Non-cumulative livepatches are allowed to touch already modified > system states. > > Signed-off-by: Petr Mladek > --- > include/linux/livepatch.h | 2 ++ > kernel/livepatch/core.c | 8 ++++++++ > kernel/livepatch/state.c | 40 +++++++++++++++++++++++++++++++++++++++- > kernel/livepatch/state.h | 9 +++++++++ > 4 files changed, 58 insertions(+), 1 deletion(-) > create mode 100644 kernel/livepatch/state.h > > diff --git a/include/linux/livepatch.h b/include/linux/livepatch.h > index 591abdee30d7..8bc4c6cc3f3f 100644 > --- a/include/linux/livepatch.h > +++ b/include/linux/livepatch.h > @@ -135,10 +135,12 @@ struct klp_object { > /** > * struct klp_state - state of the system modified by the livepatch > * @id: system state identifier (non zero) > + * @version: version of the change (non-zero) > * @data: custom data > */ > struct klp_state { > int id; As suggested by Nicolay, there will be in v2: unsigned long id; > + int version; It would make sense to make "version" unsigned as well. I am just unsure about the size: + "unsigned long" looks like an overhead to me + "u8" might be enough But I would stay on the safe side and use: unsigned int version; Is anyone against? Best Regards, Petr