LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Masami Hiramatsu <mhiramat@kernel.org>
To: Ingo Molnar <mingo@kernel.org>
Cc: linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org,
	Ingo Molnar <mingo@redhat.com>, "H . Peter Anvin" <hpa@zytor.com>,
	x86@kernel.org, Ananth N Mavinakayanahalli <ananth@in.ibm.com>,
	Anil S Keshavamurthy <anil.s.keshavamurthy@intel.com>,
	"David S . Miller" <davem@davemloft.net>,
	Jon Medhurst <tixy@linaro.org>, Will Deacon <will.deacon@arm.com>,
	Arnd Bergmann <arnd@arndb.de>,
	David Howells <dhowells@redhat.com>,
	Heiko Carstens <heiko.carstens@de.ibm.com>,
	"Tobin C . Harding" <me@tobin.cc>,
	Linus Torvalds <torvalds@linux-foundation.org>,
	Thomas Richter <tmricht@linux.ibm.com>,
	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
Date: Sat, 28 Apr 2018 01:10:56 +0900	[thread overview]
Message-ID: <20180428011056.931092c5eee7ef42f1effe3d@kernel.org> (raw)
In-Reply-To: <20180427071417.lq4swylywht7mdy7@gmail.com>

On Fri, 27 Apr 2018 09:14:17 +0200
Ingo Molnar <mingo@kernel.org> wrote:

> 
> * Masami Hiramatsu <mhiramat@kernel.org> 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?

It's a typo. I mean "show it. Or, it shows..." anyway,

> 
> 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:
> > +	 */

OK, look good to me.

> 
> 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()...

Would you really think we should handle all the address with 'void *'?
IOW, are there any policy that we handle the generic address by 'void *'
or 'unsigned long'?
For example, other address checker like kernel_text_address(),
module_text_address(), and ftrace_location() receive 'unsigned long'.
(only jump_label_text_reserved() using 'void *')

> 
> 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);
> 
> ?

Both are OK to me. I just didn't want to repeat the printk format string there.

> 
> This variant eliminates the unnecessary complication over local variables and 
> makes it abundantly clear what gets printed and how.

Agreed, it may shorten the patch.

> ( Note that the kprobe_blacklist_entry type cleanup should still be done, 
>   regardless of code flow choices. )
> 
> Thanks,
> 
> 	Ingo

Thank you,


-- 
Masami Hiramatsu <mhiramat@kernel.org>

  reply	other threads:[~2018-04-27 16:11 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-04-27  6:39 [PATCH v3 0/7] kprobes: Fix %p in kprobes Masami Hiramatsu
2018-04-27  6:40 ` [PATCH v3 1/7] kprobes: Make blacklist root user read only Masami Hiramatsu
2018-04-27  6:56   ` Greg KH
2018-04-27 14:52     ` Masami Hiramatsu
2018-04-27  7:04   ` Ingo Molnar
2018-04-27 15:58     ` Masami Hiramatsu
2018-04-27  6:40 ` [PATCH v3 2/7] kprobes: Show blacklist addresses as same as kallsyms does Masami Hiramatsu
2018-04-27  7:14   ` Ingo Molnar
2018-04-27 16:10     ` Masami Hiramatsu [this message]
2018-04-27  6:41 ` [PATCH v3 3/7] kprobes: Show address of kprobes if " Masami Hiramatsu
2018-04-27  6:41 ` [PATCH v3 4/7] kprobes: Replace %p with other pointer types Masami Hiramatsu
2018-04-27  6:56   ` Ingo Molnar
2018-04-27 15:42     ` Masami Hiramatsu
2018-04-28  4:43       ` Masami Hiramatsu
2018-04-27  6:42 ` [PATCH v3 5/7] kprobes/x86: Fix %p uses in error messages Masami Hiramatsu
2018-04-27  6:58   ` Ingo Molnar
2018-04-27 15:06     ` Masami Hiramatsu
2018-04-27  6:42 ` [PATCH v3 6/7] kprobes/arm: " Masami Hiramatsu
2018-04-27  6:43 ` [PATCH v3 7/7] kprobes/arm64: " Masami Hiramatsu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180428011056.931092c5eee7ef42f1effe3d@kernel.org \
    --to=mhiramat@kernel.org \
    --cc=acme@kernel.org \
    --cc=akpm@linux-foundation.org \
    --cc=ananth@in.ibm.com \
    --cc=anil.s.keshavamurthy@intel.com \
    --cc=arnd@arndb.de \
    --cc=brueckner@linux.vnet.ibm.com \
    --cc=davem@davemloft.net \
    --cc=dhowells@redhat.com \
    --cc=heiko.carstens@de.ibm.com \
    --cc=hpa@zytor.com \
    --cc=linux-arch@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=me@tobin.cc \
    --cc=mingo@kernel.org \
    --cc=mingo@redhat.com \
    --cc=rostedt@goodmis.org \
    --cc=schwidefsky@de.ibm.com \
    --cc=stable@vger.kernel.org \
    --cc=tixy@linaro.org \
    --cc=tmricht@linux.ibm.com \
    --cc=torvalds@linux-foundation.org \
    --cc=will.deacon@arm.com \
    --cc=x86@kernel.org \
    --subject='Re: [PATCH v3 2/7] kprobes: Show blacklist addresses as same as kallsyms does' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).