Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp1621979imu; Sun, 16 Dec 2018 05:13:06 -0800 (PST) X-Google-Smtp-Source: AFSGD/WBx5sxcuKeNnTJlZUryMkwaeFCrADqMZK3H4k+0B0vxO1+dryTZF1cWgBxtRpr8uP3BKkV X-Received: by 2002:a63:c10f:: with SMTP id w15mr8875225pgf.199.1544965986485; Sun, 16 Dec 2018 05:13:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544965986; cv=none; d=google.com; s=arc-20160816; b=ZWlHKN+37zQachl5HRwo1ft2PACpktcFxCZjKWoOFnw3HngMTIx1txeG2DyyPXr/iA InBydRg6injMYM2AZEFnzxGDOwNPJFlNWiHTWoBxNYoBDoHA/jH16VoPg+KvkiZ9xCki vLONfVHNCrltJOUfZzjNJeF5ezTrGKoyJfCb6dL62N5d5TaRHMfSEZeVh7ubqJa9b/jL G1wMy/1nfop+riOvjfW3MA3Tz8rEtka71/6ow1kZW6Z2IP24cdVzWf9w3vClHoHJIZOu VfuSpsVjDY4forCneFwXGylnux02g/heuVCp2PCr2E/uorsM6Y3BnQi+D/WIinJBIk/n ysSw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from; bh=oZjbuD+8aDNHyfemtDo4n3onzRN824quxreBwpA8mu8=; b=WFoMcGzf1rxPr2HlXuKtzS6vS41YFPeSLZOIcWZ/8rAW9ZWr7T3ooB9n6wSl2zhSWm JtruX0m01cHLV0jWK77EvMP5/Yn2z9Vz/+doYmmmTO8A0cERmJlhlCHHEyfAPJKS0fzn sFVWNT2BV3BYX24lVmM7aWmTI40T6HxhAJDOUsUu49RUZ2/GnHXEc0kZ0jBLeFXvQlLO zeL8PeR3ucTNJqRPW5bbhOfdkZxFm7drQRDy+CZ0KS0vnMs7lvzj5svHZiUNfcOFjxSM xRbz67sgOpOKpgKaBIDQgkiIpVOEt/drvl56w08ZtiMvlKcZNmaTqEaHz9hS3NmdLAmV FhEw== 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 g8si9598241pfa.11.2018.12.16.05.12.48; Sun, 16 Dec 2018 05:13:06 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730419AbeLPNLz (ORCPT + 99 others); Sun, 16 Dec 2018 08:11:55 -0500 Received: from www.osadl.org ([62.245.132.105]:47366 "EHLO www.osadl.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730197AbeLPNLy (ORCPT ); Sun, 16 Dec 2018 08:11:54 -0500 Received: from debian01.hofrr.at (178.115.242.59.static.drei.at [178.115.242.59]) by www.osadl.org (8.13.8/8.13.8/OSADL-2007092901) with ESMTP id wBGDBNQU021573; Sun, 16 Dec 2018 14:11:23 +0100 From: Nicholas Mc Guire To: Josh Poimboeuf Cc: Jessica Yu , Jiri Kosina , Miroslav Benes , Petr Mladek , live-patching@vger.kernel.org, linux-kernel@vger.kernel.org, Nicholas Mc Guire Subject: [PATCH V2] livepatch: fix non-static warnings Date: Sun, 16 Dec 2018 14:07:37 +0100 Message-Id: <1544965657-26804-1-git-send-email-hofrat@osadl.org> X-Mailer: git-send-email 2.1.4 X-Spam-Status: No, score=-1.9 required=6.0 tests=BAYES_00 autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on www.osadl.org Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Sparse reported warnings about non-static symbols. For the variables a simple static attribute is fine - for those symbols referenced by livepatch via klp_func the symbol-names must be unmodified in the symbol table - to resolve this the __noclone attribute is used for the shared statically declared functions. Signed-off-by: Nicholas Mc Guire Suggested-by: Joe Lawrence Link: https://lkml.org/lkml/2018/12/13/827 --- V2: not all static functions shared need to carry the __noclone attribute only those that need to be resolved at runtime by livepatch - so drop the unnecessary __noclone attributes as well as the Note on __noclone as suggested by Joe Lawrence - thanks ! Sparse reported the following findings: CHECK samples/livepatch/livepatch-shadow-mod.c samples/livepatch/livepatch-shadow-mod.c:99:1: warning: symbol 'dummy_list' was not declared. Should it be static? samples/livepatch/livepatch-shadow-mod.c:100:1: warning: symbol 'dummy_list_mutex' was not declared. Should it be static? samples/livepatch/livepatch-shadow-mod.c:107:23: warning: symbol 'dummy_alloc' was not declared. Should it be static? samples/livepatch/livepatch-shadow-mod.c:128:15: warning: symbol 'dummy_free' was not declared. Should it be static? samples/livepatch/livepatch-shadow-mod.c:136:15: warning: symbol 'dummy_check' was not declared. Should it be static? CHECK samples/livepatch/livepatch-shadow-fix1.c samples/livepatch/livepatch-shadow-fix1.c:74:14: warning: symbol 'livepatch_fix1_dummy_alloc' was not declared. Should it be static? samples/livepatch/livepatch-shadow-fix1.c:111:6: warning: symbol 'livepatch_fix1_dummy_free' was not declared. Should it be static? CHECK samples/livepatch/livepatch-shadow-fix2.c samples/livepatch/livepatch-shadow-fix2.c:53:6: warning: symbol 'livepatch_fix2_dummy_check' was not declared. Should it be static? samples/livepatch/livepatch-shadow-fix2.c:81:6: warning: symbol 'livepatch_fix2_dummy_free' was not declared. Should it be static? Patch was compile tested with: x86_64_defconfig + FTRACE=y FUNCTION_TRACER=y, EXPERT=y, LATENCYTOP=y, SAMPLES=y, SAMPLE_LIVEPATCH=y Patch was runtested with: insmod samples/livepatch/livepatch-shadow-mod.ko insmod samples/livepatch/livepatch-shadow-fix1.ko insmod samples/livepatch/livepatch-shadow-fix2.ko echo 0 > /sys/kernel/livepatch/livepatch_shadow_fix2/enabled echo 0 > /sys/kernel/livepatch/livepatch_shadow_fix1/enabled rmmod livepatch-shadow-fix2 rmmod livepatch-shadow-fix1 rmmod livepatch-shadow-mod and dmesg output compared with the run before the patch was applied. Patch is against 4.20-rc6 (localversion-next is next-20181214) samples/livepatch/livepatch-shadow-fix1.c | 4 ++-- samples/livepatch/livepatch-shadow-fix2.c | 4 ++-- samples/livepatch/livepatch-shadow-mod.c | 11 ++++++----- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/samples/livepatch/livepatch-shadow-fix1.c b/samples/livepatch/livepatch-shadow-fix1.c index 49b1355..ebe78e2 100644 --- a/samples/livepatch/livepatch-shadow-fix1.c +++ b/samples/livepatch/livepatch-shadow-fix1.c @@ -71,7 +71,7 @@ static int shadow_leak_ctor(void *obj, void *shadow_data, void *ctor_data) return 0; } -struct dummy *livepatch_fix1_dummy_alloc(void) +static struct dummy *livepatch_fix1_dummy_alloc(void) { struct dummy *d; void *leak; @@ -108,7 +108,7 @@ static void livepatch_fix1_dummy_leak_dtor(void *obj, void *shadow_data) __func__, d, *shadow_leak); } -void livepatch_fix1_dummy_free(struct dummy *d) +static void livepatch_fix1_dummy_free(struct dummy *d) { void **shadow_leak; diff --git a/samples/livepatch/livepatch-shadow-fix2.c b/samples/livepatch/livepatch-shadow-fix2.c index b34c7bf..b6dac2b 100644 --- a/samples/livepatch/livepatch-shadow-fix2.c +++ b/samples/livepatch/livepatch-shadow-fix2.c @@ -50,7 +50,7 @@ struct dummy { unsigned long jiffies_expire; }; -bool livepatch_fix2_dummy_check(struct dummy *d, unsigned long jiffies) +static bool livepatch_fix2_dummy_check(struct dummy *d, unsigned long jiffies) { int *shadow_count; @@ -78,7 +78,7 @@ static void livepatch_fix2_dummy_leak_dtor(void *obj, void *shadow_data) __func__, d, *shadow_leak); } -void livepatch_fix2_dummy_free(struct dummy *d) +static void livepatch_fix2_dummy_free(struct dummy *d) { void **shadow_leak; int *shadow_count; diff --git a/samples/livepatch/livepatch-shadow-mod.c b/samples/livepatch/livepatch-shadow-mod.c index 4c54b25..2168d57 100644 --- a/samples/livepatch/livepatch-shadow-mod.c +++ b/samples/livepatch/livepatch-shadow-mod.c @@ -96,15 +96,15 @@ MODULE_DESCRIPTION("Buggy module for shadow variable demo"); * Keep a list of all the dummies so we can clean up any residual ones * on module exit */ -LIST_HEAD(dummy_list); -DEFINE_MUTEX(dummy_list_mutex); +static LIST_HEAD(dummy_list); +static DEFINE_MUTEX(dummy_list_mutex); struct dummy { struct list_head list; unsigned long jiffies_expire; }; -noinline struct dummy *dummy_alloc(void) +static __noclone noinline struct dummy *dummy_alloc(void) { struct dummy *d; void *leak; @@ -125,7 +125,7 @@ noinline struct dummy *dummy_alloc(void) return d; } -noinline void dummy_free(struct dummy *d) +static __noclone noinline void dummy_free(struct dummy *d) { pr_info("%s: dummy @ %p, expired = %lx\n", __func__, d, d->jiffies_expire); @@ -133,7 +133,8 @@ noinline void dummy_free(struct dummy *d) kfree(d); } -noinline bool dummy_check(struct dummy *d, unsigned long jiffies) +static __noclone noinline bool dummy_check(struct dummy *d, + unsigned long jiffies) { return time_after(jiffies, d->jiffies_expire); } -- 2.1.4