Received: by 10.213.65.68 with SMTP id h4csp1628828imn; Mon, 26 Mar 2018 11:13:18 -0700 (PDT) X-Google-Smtp-Source: AG47ELsjbxmxlrG1hl7XJ8Tdue/Vdm+z1DV7uYIIpWEGylRPQpPPahZC/ZYzPf2kvpR1QDgR8VEH X-Received: by 2002:a17:902:20cb:: with SMTP id v11-v6mr11930644plg.82.1522087997937; Mon, 26 Mar 2018 11:13:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522087997; cv=none; d=google.com; s=arc-20160816; b=ls9SttkjMM7NI2N8o0Xl5ASWPE1KPFL9+kYIgZRDHwhzFUYUlmO8lWV8S4yr936Y+i +/g79if73yKXL5QWN2CAWmbqqc/Pu2++LPCUcnlq06BdpW2dt5E3APD/bWbVMUg5rreE wkwbQmi2gGMSqIg4rbgY5I37LhzIlF8LgTWgCYxXZcr03MsjEwMiLgep9OwbaHAyFGTd l0OtM9KVxjsQEXGnVsXw9SKHlulu3PU8DzfKVR3GONCHcsA5BmgYsRKMgL7jBb22YdAX halChGh9O+WqTnp4ykIlQhWFEErmhzLBM/r21/xrEskBF/gikdTcDcunHffu8sF/W6q6 pFow== 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=lSZYYNZ0SmLHeoIrKab2T9DpYjqfr7jJhLGxDqyqZ1A=; b=IXEyCVcOnLoSZXx1Ncy9CA/bW/UU1p0USlyMjK7ILXg3Lc8DmcrWJXTvN2cgqqxxFO cE7wEt/4NUQJYSteYku7gd+tjOBmf0I5yieI3z4+VhW7fRLcOU/pCWW3ZO2H78gCnZ8z U/xvAhjJKV+zNr1Fb7qsA4cA5tnDiz7cSRx6HuFXDUnTnQeP9PRKbPvsSw+GkhS6SW4Z wRYSD3bw5wF1PW4Nb/2IRKHc1cx4Owtxh5+ukXIBu2qbO8zOTEd9Jo37A0ztj/ZxFiSo TiWTbDfKCYZTNWTLpa5eb+T/R+imgCutLDd2iL4TAS9NNc6jOzfUc+NwY4dvh3ZIoS9i 6I4w== 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 m5si3719951pgp.624.2018.03.26.11.13.02; Mon, 26 Mar 2018 11:13:17 -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 S1752618AbeCZSMG (ORCPT + 99 others); Mon, 26 Mar 2018 14:12:06 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:59428 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751964AbeCZSMF (ORCPT ); Mon, 26 Mar 2018 14:12:05 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 9AB0CEBFEC; Mon, 26 Mar 2018 18:12:04 +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 BC587215CDAE; Mon, 26 Mar 2018 18:12:03 +0000 (UTC) Subject: Re: [PATCH v10 00/10] livepatch: Atomic replace feature To: Petr Mladek Cc: Jiri Kosina , Josh Poimboeuf , Miroslav Benes , Jason Baron , Jessica Yu , Evgenii Shatokhin , live-patching@vger.kernel.org, linux-kernel@vger.kernel.org References: <2f94c399-fe72-58f9-bd63-b08c46bb47b3@redhat.com> <1520881024-29386-1-git-send-email-joe.lawrence@redhat.com> <20180326105610.fzjfotkaljbuoa57@pathway.suse.cz> From: Joe Lawrence Organization: Red Hat Message-ID: <6b1c58e4-9dc3-36bd-1fb6-e136605d0c66@redhat.com> Date: Mon, 26 Mar 2018 14:12:03 -0400 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: <20180326105610.fzjfotkaljbuoa57@pathway.suse.cz> 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.6 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.1]); Mon, 26 Mar 2018 18:12:04 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.1]); Mon, 26 Mar 2018 18:12:04 +0000 (UTC) for IP:'10.11.54.6' DOMAIN:'int-mx06.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 03/26/2018 06:56 AM, Petr Mladek wrote: > On Mon 2018-03-12 14:57:04, Joe Lawrence wrote: >> Hi Petr, >> >> These are the callback tests that I hacked up into a livepatch >> kselftest. (Basically I copied a bunch of the sample modules and >> verified the expected dmesg output as I had listed in in the >> Documentation/livepatch/callbacks.txt file.) The script is still a >> little rough and maybe this isn't the direction we want to go for proper >> kselftests, but perhaps it saves you some time/sanity for verifying this >> patchset. > > > >> Hope this helps, >> >> -- Joe >> >> -- >8 -- >8 -- >8 -- >8 -- >> >> >From 0364430c53e12e21923bed20cb651374b4cf9ba9 Mon Sep 17 00:00:00 2001 >> From: Joe Lawrence >> Date: Tue, 6 Mar 2018 17:32:25 -0500 >> Subject: WIP - livepatch kselftest >> >> CONFIG_TEST_LIVEPATCH=m >> % make -C tools/testing/selftests TARGETS=livepatch run_tests >> >> Signed-off-by: Joe Lawrence >> --- >> lib/Kconfig.debug | 11 + >> lib/Makefile | 9 + >> lib/test_klp_callbacks_busy.c | 58 ++ >> lib/test_klp_callbacks_demo.c | 205 +++++++ >> lib/test_klp_callbacks_demo2.c | 149 +++++ >> lib/test_klp_callbacks_mod.c | 39 ++ > > I would suggest to put it into lib/livepatch/ subdirectory. I hope > that we will add more tests in the long term. Good idea, we should encourage more tests in a livepatch/ subdir and not clutter up the lib/ directory. >> diff --git a/tools/testing/selftests/livepatch/livepatch-test b/tools/testing/selftests/livepatch/livepatch-test >> new file mode 100755 >> index 000000000000..798317bf69f6 >> --- /dev/null >> +++ b/tools/testing/selftests/livepatch/livepatch-test > > s/livepatch-test/livepatch-test.sh/ ? > > It seems to be common to add .sh suffix for bash script names. I'll rename with the suffix. >> @@ -0,0 +1,658 @@ >> +#!/bin/bash >> +# SPDX-License-Identifier: GPL-2.0 >> +# Copyright (C) 2018 Joe Lawrence >> + >> +MAX_RETRIES=30 >> +RETRY_INTERVAL=2 # seconds >> +BETWEEN_TESTS=20 # seconds > > These 20 seconds kept me in a tense (waiting for the final result) > for a very long time ;-) Is there any particular reason for such > a long delay? It certainly builds suspense :) > I wonder if we need a delay at all or if let's say 2 seconds might > be enough. I removed the delays completely and the tests ran successfully. What might be better than a between test delay would be some kind of initial-condition verification, ie, make sure that the test starts/ends with none of the livepatch test modules loaded. For the test cases which load multiple livepatches, is there an easy way to determine the patch stack order from userspace? I think that would be helpful when trying to remove all of them. >> +echo -n "TEST1 ... " >> +dmesg -C >> + >> +load_mod $MOD_TARGET >> +load_mod $MOD_LIVEPATCH >> +wait_for_transition $MOD_LIVEPATCH >> +disable_lp $MOD_LIVEPATCH >> +unload_mod $MOD_LIVEPATCH >> +unload_mod $MOD_TARGET >> + >> +check_result "% modprobe $MOD_TARGET >> +$MOD_TARGET: livepatch_callbacks_mod_init >> +% modprobe $MOD_LIVEPATCH >> +livepatch: enabling patch '$MOD_LIVEPATCH' >> +livepatch: '$MOD_LIVEPATCH': initializing patching transition >> +$MOD_LIVEPATCH: pre_patch_callback: $MOD_TARGET -> [MODULE_STATE_LIVE] Normal state >> +$MOD_LIVEPATCH: pre_patch_callback: vmlinux >> +livepatch: '$MOD_LIVEPATCH': starting patching transition >> +livepatch: '$MOD_LIVEPATCH': completing patching transition >> +$MOD_LIVEPATCH: post_patch_callback: $MOD_TARGET -> [MODULE_STATE_LIVE] Normal state >> +$MOD_LIVEPATCH: post_patch_callback: vmlinux >> +livepatch: '$MOD_LIVEPATCH': patching complete >> +% echo 0 > /sys/kernel/livepatch/$MOD_LIVEPATCH/enabled >> +livepatch: '$MOD_LIVEPATCH': initializing unpatching transition >> +$MOD_LIVEPATCH: pre_unpatch_callback: $MOD_TARGET -> [MODULE_STATE_LIVE] Normal state >> +$MOD_LIVEPATCH: pre_unpatch_callback: vmlinux >> +livepatch: '$MOD_LIVEPATCH': starting unpatching transition >> +livepatch: '$MOD_LIVEPATCH': completing unpatching transition >> +$MOD_LIVEPATCH: post_unpatch_callback: $MOD_TARGET -> [MODULE_STATE_LIVE] Normal state >> +$MOD_LIVEPATCH: post_unpatch_callback: vmlinux >> +livepatch: '$MOD_LIVEPATCH': unpatching complete >> +% rmmod $MOD_LIVEPATCH >> +% rmmod $MOD_TARGET >> +$MOD_TARGET: livepatch_callbacks_mod_exit" > > I was a bit surprised when seeing this way of checking results. > But on the other hand, it looks pretty effective, especially for > the callbacks. And the 3rd look, any patched function might write > something into the log when called. This was a quickly scripted version of what I was manually verifying with the sample example livepatches. I don't know if it will scale, but it was pretty easy to add tests this way. I wonder though if better dmesg filters will be required as the livepatch core adds more debug msgs? > I like it. Let's see how it works in the long term. But I am rather > positive. > > Thanks a lot for working on it. Thanks for taking a look and running the tests. I'll make some of your suggested changes and send it up for a proper review soon. -- Joe