From patchwork Fri Jul 15 11:35:52 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 102011 Delivered-To: patch@linaro.org Received: by 10.140.29.52 with SMTP id a49csp566646qga; Fri, 15 Jul 2016 04:36:02 -0700 (PDT) X-Received: by 10.98.106.133 with SMTP id f127mr20613395pfc.139.1468582562638; Fri, 15 Jul 2016 04:36:02 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o6si8797615paf.168.2016.07.15.04.36.02; Fri, 15 Jul 2016 04:36:02 -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 S932751AbcGOLgA (ORCPT + 29 others); Fri, 15 Jul 2016 07:36:00 -0400 Received: from mout.kundenserver.de ([212.227.126.135]:57635 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932590AbcGOLf5 (ORCPT ); Fri, 15 Jul 2016 07:35:57 -0400 Received: from wuerfel.localnet ([78.42.132.4]) by mrelayeu.kundenserver.de (mreue002) with ESMTPSA (Nemesis) id 0Ltibd-1bGQl21RIb-0118q7; Fri, 15 Jul 2016 13:35:53 +0200 From: Arnd Bergmann To: Kees Cook Cc: linux-kernel@vger.kernel.org, Greg Kroah-Hartman Subject: [PATCH] lkdtm: hide unused functions Date: Fri, 15 Jul 2016 13:35:52 +0200 Message-ID: <2180832.bWdqFupBK3@wuerfel> User-Agent: KMail/5.1.3 (Linux/4.4.0-28-generic; KDE/5.18.0; x86_64; ; ) In-Reply-To: <1467844411-32373-13-git-send-email-keescook@chromium.org> References: <1467844411-32373-1-git-send-email-keescook@chromium.org> <1467844411-32373-13-git-send-email-keescook@chromium.org> MIME-Version: 1.0 X-Provags-ID: V03:K0:Y+36uNMg6vMjyLl9pUEYSdWvYrjRbHtNYp4ln9/7HXgiUA/b1xG mNscM099W2H9ltypi7WtNuFu1S3zy2oeU47SAqA5/2WFQY66bwAQb19qnTGslmRz0vYkX5g hECuV+voa9sbIFvJ36EyLVFjF3HbIn/+3RTvOa7O8keEKF3w2AqCiVcpkC7OndAxccaqyvE T465OYN4/mE/7aP72U8Gw== X-UI-Out-Filterresults: notjunk:1; V01:K0:JZTMbkZ/Lgg=:sTKlCCy/rz6Rx+yMwRCPxB NCdII8C4GJrJi0livvyHLlAAsiGFbESg5mGeUyWhO880spbeL3OWzWqtdkCwqZ5IB5gqNWnSH fOO6MM3pl18MdeDUM5h9P6E/jR5uBBMjgRanAzPjONfQy1sIw3vQkF3cpPhNVfdiVs4pvUE9J upMHp6Q9FaJdgdy5FfBWDxuTlqI7h0ZzXRlQfGbyDPCn0lVv627HzlLm2IKSwvgCpIkdICd0M Li1/HoJgFDcqJVgthPnVrPDg2EiA9qRt7PooECu49Pw8DH5+ckEsfx5xJn1OMitoYT9cQk5Xi dtw3KtvaBadxxezkvSDvGEdWABxKIq6WGNsqXVjtQMVFltWyJ1xi0mD9SUPVGSTSUakJBGMc2 F0dfl+TLDvHkA8uLmAjP9OhjcbMgtYG9kCX4UewU2D51k4b2hZbrhzd2JUChPZ8NgR5XpY/rI gLe9Xfb5vXScNfSjld5kErEQl1ljA4AVQk98c0QBvc83C/UqyYnSRUZ1QpST1G3pfB6b8oKkR WRhxIc3YEm7Aw7WiZuD8PY0I1ioL/hdTPVBpjjhZZbhDNwqZQw9AuIbR2UZ3Nhk4gN9Rrcz9W Q+5bhMzyPU97xWsKGjvD8FuUb4Vvbib2GugqCsSk0jDPyPNFa6OxurUTbblUzLtQvpYumreGf JPIbZaIbQCVx0sJ/B1jiJqWIqDmnSggTf4T8YKWHctg4NbeUaINE8XC6y7SHorxldTvot97QO ODW/Vmy1ek4OGkkD Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org A conversion of the lkdtm core module added an "#ifdef CONFIG_KPROBES" check, but a number of functions then become unused: drivers/misc/lkdtm_core.c:340:16: error: 'lkdtm_debugfs_entry' defined but not used [-Werror=unused-function] drivers/misc/lkdtm_core.c:122:12: error: 'jp_generic_ide_ioctl' defined but not used [-Werror=unused-function] drivers/misc/lkdtm_core.c:114:12: error: 'jp_scsi_dispatch_cmd' defined but not used [-Werror=unused-function] drivers/misc/lkdtm_core.c:106:12: error: 'jp_hrtimer_start' defined but not used [-Werror=unused-function] drivers/misc/lkdtm_core.c:97:22: error: 'jp_shrink_inactive_list' defined but not used [-Werror=unused-function] drivers/misc/lkdtm_core.c:89:13: error: 'jp_ll_rw_block' defined but not used [-Werror=unused-function] drivers/misc/lkdtm_core.c:83:13: error: 'jp_tasklet_action' defined but not used [-Werror=unused-function] drivers/misc/lkdtm_core.c:75:20: error: 'jp_handle_irq_event' defined but not used [-Werror=unused-function] drivers/misc/lkdtm_core.c:68:21: error: 'jp_do_irq' defined but not used [-Werror=unused-function] This adds the same #ifdef everywhere. There is probably a better way to do the same thing, but for now this avoids the new warnings. Signed-off-by: Arnd Bergmann Fixes: c479e3fd8870 ("lkdtm: use struct arrays instead of enums") --- On Wednesday, July 6, 2016 3:33:31 PM CEST Kees Cook wrote: > + > +/* Define the possible places where we can trigger a crash point. */ > +struct crashpoint crashpoints[] = { > + CRASHPOINT("DIRECT", direct_entry, > + NULL, NULL), > +#ifdef CONFIG_KPROBES > + CRASHPOINT("INT_HARDWARE_ENTRY", lkdtm_debugfs_entry, > + "do_IRQ", jp_do_irq), > + CRASHPOINT("INT_HW_IRQ_EN", lkdtm_debugfs_entry, > + "handle_IRQ_event", jp_handle_irq_event), > + CRASHPOINT("INT_TASKLET_ENTRY", lkdtm_debugfs_entry, diff --git a/drivers/misc/lkdtm_core.c b/drivers/misc/lkdtm_core.c index de29a339242a..6bdef16f95a2 100644 --- a/drivers/misc/lkdtm_core.c +++ b/drivers/misc/lkdtm_core.c @@ -53,12 +53,14 @@ #define DEFAULT_COUNT 10 -static void lkdtm_handler(void); static int lkdtm_debugfs_open(struct inode *inode, struct file *file); static ssize_t lkdtm_debugfs_read(struct file *f, char __user *user_buf, size_t count, loff_t *off); static ssize_t direct_entry(struct file *f, const char __user *user_buf, size_t count, loff_t *off); + +#ifdef CONFIG_KPROBES +static void lkdtm_handler(void); static ssize_t lkdtm_debugfs_entry(struct file *f, const char __user *user_buf, size_t count, loff_t *off); @@ -128,7 +130,7 @@ static int jp_generic_ide_ioctl(ide_drive_t *drive, struct file *file, return 0; } #endif - +#endif /* Crash points */ struct crashpoint { @@ -240,7 +242,9 @@ struct crashtype *lkdtm_crashtype; /* Global crash counter and spinlock. */ static int crash_count = DEFAULT_COUNT; +#ifdef CONFIG_KPROBES static DEFINE_SPINLOCK(crash_count_lock); +#endif /* Module parameters */ static int recur_count = -1; @@ -285,6 +289,7 @@ static noinline void lkdtm_do_action(struct crashtype *crashtype) crashtype->func(); } +#ifdef CONFIG_KPROBES /* Called by jprobe entry points. */ static void lkdtm_handler(void) { @@ -307,6 +312,7 @@ static void lkdtm_handler(void) if (do_it) lkdtm_do_action(lkdtm_crashtype); } +#endif static int lkdtm_register_cpoint(struct crashpoint *crashpoint, struct crashtype *crashtype) @@ -337,6 +343,7 @@ static int lkdtm_register_cpoint(struct crashpoint *crashpoint, return ret; } +#ifdef CONFIG_KPROBES static ssize_t lkdtm_debugfs_entry(struct file *f, const char __user *user_buf, size_t count, loff_t *off) @@ -374,6 +381,7 @@ static ssize_t lkdtm_debugfs_entry(struct file *f, return count; } +#endif /* Generic read callback that just prints out the available crash types */ static ssize_t lkdtm_debugfs_read(struct file *f, char __user *user_buf,