Received: by 10.223.185.116 with SMTP id b49csp926220wrg; Fri, 23 Feb 2018 08:56:55 -0800 (PST) X-Google-Smtp-Source: AH8x227Fkg5sE+lnHjFZ5zhBBmEGtl2tozax2NZfzbr1rbpK4LTg6PusHINcF2BrwFEflkFNfmFl X-Received: by 2002:a17:902:822:: with SMTP id 31-v6mr2326422plk.362.1519405014983; Fri, 23 Feb 2018 08:56:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519405014; cv=none; d=google.com; s=arc-20160816; b=Y20T9uw3o75oVIUtPdAAn4Z6NzfGq2klCrpfu+ztY8Coqby/hNP4+yz89FK9AfoL/U POg489bww5qYixOmKuwewHchFg2edUulq1Hkm3B7YxKRpzlIEOSJ33iRS8LHwyDognVW ayp5Ef41O54bu9TVea7qGEuWPhasQsN+Bus8InoSqD0f+pb3UD9TAxsu1JzsKSEdV/qk ZPTh5aMJqW706VF9wKB3fiIpzzN8wFr/1UQ0mAXvNdgIwa+O5disqI0JK61gMml0CLln tpopxWOrTXN3AmSXoJiR7SkEO0cug1xH7MiPOfWj25DlXLT004WjO9iy80PxSKY8MfsQ ERzw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:organization:from:references:cc:to:subject :arc-authentication-results; bh=iLhH7KVCfS9acsNDbB/lcviq6v3VCnNQhLe30i7BUkw=; b=BTQFe62k2CrjGbke35uV6PVwQ9fmhw0BHMv/iGVwAyqCtRGFvGPw8fe2qVLWqa9zSJ v4ebFgD7zE7rRPXTlFyIKzmH96grogq1Cidg9bVGkxv+O6NovKcfrTxlZTge2fqACdeV KD3YLTxZFY5e+VfDtiSEzklLOPZmEityfzukV7wkFuA6xJUCQ/S/cUG1AgS4rRp/0q3O wUzoyg2n+OoIis8zCjlt8ox2pRYxYM0Dmc/F9x8C5Ujwbnu8uiSj0KL62lghD5vXNrhN B9TediWHZJzoRryi/zksuld1aOt582TPqd7o+ap3ZEuYWxyebV/0dPEvYdVSUkEQpr7o +nIQ== 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 u76si1733366pgc.218.2018.02.23.08.56.40; Fri, 23 Feb 2018 08:56:54 -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 S1751707AbeBWQzy (ORCPT + 99 others); Fri, 23 Feb 2018 11:55:54 -0500 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:38532 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751366AbeBWQzw (ORCPT ); Fri, 23 Feb 2018 11:55:52 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id EF224407A9AA; Fri, 23 Feb 2018 16:55:51 +0000 (UTC) Received: from jlaw-desktop.bos.csb (dhcp-17-208.bos.redhat.com [10.18.17.208]) by smtp.corp.redhat.com (Postfix) with ESMTP id 820E410AF9FA; Fri, 23 Feb 2018 16:55:51 +0000 (UTC) Subject: Re: [PATCH v8 8/8] livepatch: Atomic replace and cumulative patches documentation To: Miroslav Benes , Petr Mladek Cc: Jiri Kosina , Josh Poimboeuf , Jason Baron , Jessica Yu , Evgenii Shatokhin , live-patching@vger.kernel.org, linux-kernel@vger.kernel.org References: <20180221132914.4809-1-pmladek@suse.com> <20180221132914.4809-9-pmladek@suse.com> From: Joe Lawrence Organization: Red Hat Message-ID: Date: Fri, 23 Feb 2018 11:55:51 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Fri, 23 Feb 2018 16:55:52 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Fri, 23 Feb 2018 16:55:52 +0000 (UTC) for IP:'10.11.54.3' DOMAIN:'int-mx03.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'joe.lawrence@redhat.com' RCPT:'' Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 02/23/2018 05:41 AM, Miroslav Benes wrote: > On Wed, 21 Feb 2018, Petr Mladek wrote: > >> User documentation for the atomic replace feature. It makes it easier >> to maintain livepatches using so-called cumulative patches. >> >> Signed-off-by: Petr Mladek > > Acked-by: Miroslav Benes > > Joe, are you planning to extend shadow vars documentation you mentioned > before (v7), or do you want Petr to do it? I created a sample cumulative patch for testing (I can post later), but I had a quick question regarding the callbacks... From v8 of the patch: + Only the (un)patching callbacks from the _new_ cumulative livepatch are executed. Any callbacks from the replaced patches are ignored. maybe I'm not testing this as intended, but I'm not seeing this behavior with the latest version of the patch. See below. Init ==== Setup dynamic debug messages: % echo "file kernel/livepatch/* +p" > /sys/kernel/debug/dynamic_debug/control % echo "func klp_try_switch_task -p" >> /sys/kernel/debug/dynamic_debug/control Test 1 ====== Copy the original callbacks demo, leave the atomic .replace feature off: diff -upr samples/livepatch/livepatch-callbacks-{demo.c,demo2.c} --- samples/livepatch/livepatch-callbacks-demo.c 2018-02-23 09:42:10.370223095 -0500 +++ samples/livepatch/livepatch-callbacks-demo2.c 2018-02-23 11:38:08.372557153 -0500 @@ -191,6 +191,7 @@ static struct klp_object objs[] = { static struct klp_patch patch = { .mod = THIS_MODULE, .objs = objs, + .replace = false, }; static int livepatch_callbacks_demo_init(void) Load the two modules, disable and unload: % dmesg -C % insmod samples/livepatch/livepatch-callbacks-demo.ko % insmod samples/livepatch/livepatch-callbacks-demo2.ko % echo 0 > /sys/kernel/livepatch/livepatch_callbacks_demo2/enabled % echo 0 > /sys/kernel/livepatch/livepatch_callbacks_demo/enabled % rmmod samples/livepatch/livepatch-callbacks-demo2.ko % rmmod samples/livepatch/livepatch-callbacks-demo.ko All callbacks are called for both livepatch modules (expected): % dmesg [ 5755.608999] livepatch: enabling patch 'livepatch_callbacks_demo' [ 5755.609014] livepatch: 'livepatch_callbacks_demo': initializing patching transition > [ 5755.609054] livepatch_callbacks_demo: pre_patch_callback: vmlinux [ 5755.609055] livepatch: 'livepatch_callbacks_demo': starting patching transition [ 5756.704163] livepatch: 'livepatch_callbacks_demo': completing patching transition > [ 5756.704259] livepatch_callbacks_demo: post_patch_callback: vmlinux [ 5756.704260] livepatch: 'livepatch_callbacks_demo': patching complete [ 5760.231035] livepatch: enabling patch 'livepatch_callbacks_demo2' [ 5760.231038] livepatch: 'livepatch_callbacks_demo2': initializing patching transition > [ 5760.231077] livepatch_callbacks_demo2: pre_patch_callback: vmlinux [ 5760.231078] livepatch: 'livepatch_callbacks_demo2': starting patching transition [ 5761.696067] livepatch: 'livepatch_callbacks_demo2': completing patching transition > [ 5761.696166] livepatch_callbacks_demo2: post_patch_callback: vmlinux [ 5761.696166] livepatch: 'livepatch_callbacks_demo2': patching complete [ 5765.738278] livepatch: 'livepatch_callbacks_demo2': initializing unpatching transition > [ 5765.738319] livepatch_callbacks_demo2: pre_unpatch_callback: vmlinux [ 5765.738319] livepatch: 'livepatch_callbacks_demo2': starting unpatching transition [ 5767.712143] livepatch: 'livepatch_callbacks_demo2': completing unpatching transition > [ 5767.712502] livepatch_callbacks_demo2: post_unpatch_callback: vmlinux [ 5767.712503] livepatch: 'livepatch_callbacks_demo2': unpatching complete [ 5770.909701] livepatch: 'livepatch_callbacks_demo': initializing unpatching transition > [ 5770.909743] livepatch_callbacks_demo: pre_unpatch_callback: vmlinux [ 5770.909743] livepatch: 'livepatch_callbacks_demo': starting unpatching transition [ 5772.704108] livepatch: 'livepatch_callbacks_demo': completing unpatching transition > [ 5772.704215] livepatch_callbacks_demo: post_unpatch_callback: vmlinux [ 5772.704216] livepatch: 'livepatch_callbacks_demo': unpatching complete Test 2 ====== Make the second livepatch a cumulative one: diff -upr samples/livepatch/livepatch-callbacks-{demo.c,demo2.c} --- samples/livepatch/livepatch-callbacks-demo.c 2018-02-23 09:42:10.370223095 -0500 +++ samples/livepatch/livepatch-callbacks-demo2.c 2018-02-23 11:16:20.557557153 -0500 @@ -191,6 +191,7 @@ static struct klp_object objs[] = { static struct klp_patch patch = { .mod = THIS_MODULE, .objs = objs, + .replace = true, }; static int livepatch_callbacks_demo_init(void) Load the two modules, disable and unload: % dmesg -C % insmod samples/livepatch/livepatch-callbacks-demo.ko % insmod samples/livepatch/livepatch-callbacks-demo2.ko % echo 0 > /sys/kernel/livepatch/livepatch_callbacks_demo2/enabled % rmmod samples/livepatch/livepatch-callbacks-demo2.ko % rmmod samples/livepatch/livepatch-callbacks-demo.ko Pre and post patch callbacks are called for both modules (expected), but *no* unpatch callbacks are executed: % dmesg [ 5442.244332] livepatch: enabling patch 'livepatch_callbacks_demo' [ 5442.244334] livepatch: 'livepatch_callbacks_demo': initializing patching transition > [ 5442.244372] livepatch_callbacks_demo: pre_patch_callback: vmlinux [ 5442.244372] livepatch: 'livepatch_callbacks_demo': starting patching transition [ 5444.704089] livepatch: 'livepatch_callbacks_demo': completing patching transition > [ 5444.704183] livepatch_callbacks_demo: post_patch_callback: vmlinux [ 5444.704184] livepatch: 'livepatch_callbacks_demo': patching complete [ 5448.567820] livepatch: enabling patch 'livepatch_callbacks_demo2' [ 5448.567823] livepatch: 'livepatch_callbacks_demo2': initializing patching transition > [ 5448.567860] livepatch_callbacks_demo2: pre_patch_callback: vmlinux [ 5448.567861] livepatch: 'livepatch_callbacks_demo2': starting patching transition [ 5451.744131] livepatch: 'livepatch_callbacks_demo2': completing patching transition > [ 5451.744212] livepatch_callbacks_demo2: post_patch_callback: vmlinux [ 5451.744213] livepatch: 'livepatch_callbacks_demo2': patching complete [ 5455.002339] livepatch: 'livepatch_callbacks_demo2': initializing unpatching transition [ 5455.002378] livepatch: 'livepatch_callbacks_demo2': starting unpatching transition [ 5456.736068] livepatch: 'livepatch_callbacks_demo2': completing unpatching transition [ 5456.736132] livepatch: 'livepatch_callbacks_demo2': unpatching complete BTW, should we just add this test-case to the doc / samples? -- Joe