From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr0-f193.google.com ([209.85.128.193]:44669 "EHLO mail-wr0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753079AbeD0HOW (ORCPT ); Fri, 27 Apr 2018 03:14:22 -0400 Date: Fri, 27 Apr 2018 09:14:17 +0200 From: Ingo Molnar To: Masami Hiramatsu Cc: linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org, Ingo Molnar , "H . Peter Anvin" , x86@kernel.org, Ananth N Mavinakayanahalli , Anil S Keshavamurthy , "David S . Miller" , Jon Medhurst , Will Deacon , Arnd Bergmann , David Howells , Heiko Carstens , "Tobin C . Harding" , Linus Torvalds , Thomas Richter , akpm@linux-foundation.org, acme@kernel.org, rostedt@goodmis.org, brueckner@linux.vnet.ibm.com, schwidefsky@de.ibm.com, stable@vger.kernel.org Subject: Re: [PATCH v3 2/7] kprobes: Show blacklist addresses as same as kallsyms does Message-ID: <20180427071417.lq4swylywht7mdy7@gmail.com> References: <152481117776.22588.1210388093668905564.stgit@devbox> <152481123945.22588.459569704440210836.stgit@devbox> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <152481123945.22588.459569704440210836.stgit@devbox> Sender: stable-owner@vger.kernel.org List-ID: * Masami Hiramatsu wrote: > + /* > + * As long as kallsyms shows the address, kprobes blacklist also > + * show it, Or, it shows null address and symbol. > + */ Please _read_ the comments you write! In which universe does a capitalized 'Or' make sense, even if we ignore the various other spelling mistakes? Also, that sentence is unnecessarily complex, just say this: > + /* > + * If /proc/kallsyms is not showing kernel addresses then we won't show > + * them here either: > + */ But I'm unhappy about the messy typing and the messy code flow: + void *start = (void *)ent->start_addr, *end = (void *)ent->end_addr; + /* + * As long as kallsyms shows the address, kprobes blacklist also + * show it, Or, it shows null address and symbol. + */ + if (!kallsyms_show_value()) + start = end = NULL; + + seq_printf(m, "0x%px-0x%px\t%ps\n", start, end, + (void *)ent->start_addr); All three 'void *' type casts here are due to the bad type choices here: struct kprobe_blacklist_entry { struct list_head list; unsigned long start_addr; unsigned long end_addr; }; The natural type of ->start_addr and ->end_addr is 'void *', AFAICS this would remove some other type casts from the kprobes code as well, such as from the arch_deref_entry_point()... But the whole code flow introduced by this patch is messy as hell as well. Why cannot this do the obvious thing: if (!kallsyms_show_value()) seq_printf(m, "0x%px-0x%px\t%ps\n", NULL, NULL, ent->start_addr); else seq_printf(m, "0x%px-0x%px\t%ps\n", ent->start_addr, ent->end_addr, ent->start_addr); ? This variant eliminates the unnecessary complication over local variables and makes it abundantly clear what gets printed and how. ( Note that the kprobe_blacklist_entry type cleanup should still be done, regardless of code flow choices. ) Thanks, Ingo