Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp1590722pxb; Tue, 8 Feb 2022 23:21:36 -0800 (PST) X-Google-Smtp-Source: ABdhPJwtUG/K4YuFIyuAMoeY7XiYdt+WNwPVTmRnlYEptqamkf/ifoXkKyy+wSI/RVA9dvIOKKsa X-Received: by 2002:a65:4d45:: with SMTP id j5mr873313pgt.443.1644391296087; Tue, 08 Feb 2022 23:21:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644391296; cv=none; d=google.com; s=arc-20160816; b=cjDzMz14/xlZnUuJFp+zG0x43binzhxr82R/H4u1pLAyb3M1XBTgSnAOyLMJDssH+t 13B4aCybo7QJNtminXoQmcUz7a9R3js/sZYexxR+BfFhN7Okhfxb1v178bMan+DG4f8p GIUSDA+I4YAiS49Ctj3UmCIUNMVbah5u/+CzeIhimjFMDeA2z2cE4HVai8FSrqKXR4FH qF74AOXlvTyQyC7wjhWNPLIuioxjTr2RHmyT2KLjr1e/9ygLTTrGDK9QMAyH50869iaL AAwTS0UAFC4iCf8OVAWU6werNyrkiEKQvT9Ow6vqIF07kNQaSZ+us+37oU5TLqcuwSGv 4iMg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:subject:from :references:cc:to:dkim-signature; bh=0qZZ895hE4+IyDyf9RKZqhMfNZ+RmkkBr6db1m6Cv58=; b=PDXev271REKb2HVYepWuNpFtjkt3RaAI3yczMiE7uj0qffZ0JZEK3Wo0KK+xmrJ151 AzAAeYroF+9uoczEc29gshG1Faj+91BD/IJUx4N+T0ZEhAr8oGBgDo7neZY5kVtODv4N /boRFCAp3JMjpkxcCGLJ2D7wSP05VacEoRMvTWtfjursN/RF6IschrcicdCIYbbMnfWI Sh497qfMy9xrvYrkrdcMaaR/DFTdAQytzrbo6mQ5cSFCnHJ07IsoOdVIcy5L0W+88wJD cU07OdPwS+Gww7m2rgK9kuZcKXoSTcdjrzD4+2HsrR+uJFRWLXZhCXmqGMRPcnztWXTJ ABMg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=ZB+Piu3J; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id 81si70350pgb.678.2022.02.08.23.21.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Feb 2022 23:21:36 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=ZB+Piu3J; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 3712FE068F5A; Tue, 8 Feb 2022 22:35:02 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236829AbiBDUaY (ORCPT + 99 others); Fri, 4 Feb 2022 15:30:24 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:46518 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230443AbiBDUaP (ORCPT ); Fri, 4 Feb 2022 15:30:15 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1644006605; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=0qZZ895hE4+IyDyf9RKZqhMfNZ+RmkkBr6db1m6Cv58=; b=ZB+Piu3JBvwSyyL9Gc5nnIPZoc4UK/SfGJ5vDzd7dTCLp3QyiMGfth/6ZIHYzp6mDvNJca t0C/ME3mckrc4x8wZtISjg+h9yv2cYO/3vSm44r9Jroj5ckpjUne9tAl6sA2hmg8j0LEO1 1UehZ0Wt4fuYpOHexXpnQMZrzTEyotQ= Received: from mail-qt1-f199.google.com (mail-qt1-f199.google.com [209.85.160.199]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-544-LEehKwILNYS2goV9qYZv8Q-1; Fri, 04 Feb 2022 15:30:04 -0500 X-MC-Unique: LEehKwILNYS2goV9qYZv8Q-1 Received: by mail-qt1-f199.google.com with SMTP id l15-20020ac84ccf000000b002cf9424cfa5so5518796qtv.7 for ; Fri, 04 Feb 2022 12:30:04 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:to:cc:references:from:subject:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=0qZZ895hE4+IyDyf9RKZqhMfNZ+RmkkBr6db1m6Cv58=; b=PkCCiz7vdYoZQOaSRp2S+xQcUIAP8WV+2sbE+hJT2zLJHClcCNJTIIjEsSW+5l6M+e oQZIbb/E6A3xjrqlkM1FltDvkId9ahtN8kHCQ9F9y2G3th+fe/2igk05VVvjI0WF5K1w qr1mX1HWuYSkb52u3iWYy5vJdtfj9P58IAszDtFQ+KxC1T8XL6o5smTWd/mdDpu+lOiw xkkmMFEhnYpe3F2JxMm6Do97WfCfgiYp/46f824dgZOyugDbdsMfUZxXDRdpgWjcff4s TYFhRR+6lz/bWxevkyah06BV6pcquKL3qsn3gNqbRtPyMCn09WrdNgz43rzH5mX/DX7I bi+A== X-Gm-Message-State: AOAM5302g++Sz7mMzA9nEoaqiQ6rvnaoMfQBB+VK4E+pacMaop8yn/iO 882HvIsKUAKceOuyGk+wXa+gubYwhGF2j1xlK6VVPgxv0tLZ8e+YTOLLSBmNm/NMsPc8w0PIS7A VuU+GOfgnqddUsVuizdNDrGzT X-Received: by 2002:a05:622a:487:: with SMTP id p7mr566849qtx.426.1644006604259; Fri, 04 Feb 2022 12:30:04 -0800 (PST) X-Received: by 2002:a05:622a:487:: with SMTP id p7mr566833qtx.426.1644006604003; Fri, 04 Feb 2022 12:30:04 -0800 (PST) Received: from [192.168.1.9] (pool-68-163-101-245.bstnma.fios.verizon.net. [68.163.101.245]) by smtp.gmail.com with ESMTPSA id z17sm1716843qta.11.2022.02.04.12.30.02 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 04 Feb 2022 12:30:03 -0800 (PST) To: David Vernet , live-patching@vger.kernel.org, linux-kernel@vger.kernel.org, jpoimboe@redhat.com, pmladek@suse.com, jikos@kernel.org, mbenes@suse.cz, corbet@lwn.net Cc: kernel-team@fb.com References: <20220203233205.1554034-1-void@manifault.com> From: Joe Lawrence Subject: Re: [PATCH] livepatch: Skip livepatch tests if ftrace cannot be configured Message-ID: <917650f7-4e8c-4643-77d3-45d1ebbb217f@redhat.com> Date: Fri, 4 Feb 2022 15:30:02 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.10.1 MIME-Version: 1.0 In-Reply-To: <20220203233205.1554034-1-void@manifault.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Spam-Status: No, score=-7.8 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,NICE_REPLY_A,RCVD_IN_DNSWL_HI,SPF_HELO_PASS, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net On 2/3/22 6:32 PM, David Vernet wrote: > livepatch has a set of selftests that are used to validate the behavior of > the livepatching subsystem. One of the testcases in the livepatch > testsuite is test-ftrace.sh, which among other things, validates that > livepatching gracefully fails when ftrace is disabled. In the event that > ftrace cannot be disabled using 'sysctl kernel.ftrace_enabled=0', the test > will fail later due to it unexpectedly successfully loading the > test_klp_livepatch module. > > While the livepatch selftests are careful to remove any of the livepatch > test modules between testcases to avoid this situation, ftrace may still > fail to be disabled if another trace is active on the system that was > enabled with FTRACE_OPS_FL_PERMANENT. For example, any active BPF programs > that use trampolines will cause this test to fail due to the trampoline > being implemented with register_ftrace_direct(). The following is an > example of such a trace: > > tcp_drop (1) R I D tramp: ftrace_regs_caller+0x0/0x58 > (call_direct_funcs+0x0/0x30) > direct-->bpf_trampoline_6442550536_0+0x0/0x1000 > > In order to make the test more resilient to system state that is out of its > control, this patch adds a check to set_ftrace_enabled() to skip the tests > if the sysctl invocation fails. > > Signed-off-by: David Vernet Hi David, Thanks for this test case, comments below... > --- > tools/testing/selftests/livepatch/functions.sh | 6 ++++++ > 1 file changed, 6 insertions(+) > > diff --git a/tools/testing/selftests/livepatch/functions.sh b/tools/testing/selftests/livepatch/functions.sh > index 846c7ed71556..6857fdcb6b45 100644 > --- a/tools/testing/selftests/livepatch/functions.sh > +++ b/tools/testing/selftests/livepatch/functions.sh > @@ -78,6 +78,12 @@ function set_ftrace_enabled() { > result=$(sysctl -q kernel.ftrace_enabled="$1" 2>&1 && \ > sysctl kernel.ftrace_enabled 2>&1) > echo "livepatch: $result" > /dev/kmsg > + # Skip the test if ftrace is busy. This can happen under normal system > + # conditions if a trace is marked as permament. sp: s/permament/permanent > + if [[ "$result" == *"Device or resource busy"* ]]; then > + skip "failed to set kernel.ftrace_enabled=$1" > + fi > + style nit: move the blank line from here to just before the new # Skip comment > } > > function cleanup() { > Can we be more paranoid and just look for the exact result that we expect: if [[ "$result" != "kernel.ftrace_enabled = 1" ]]; then skip "failed to set kernel.ftrace_enabled=$1" fi and that way we catch any other faults. What do you think? Thanks, -- Joe