2017-11-06 19:03:49

by Liu, Changcheng

[permalink] [raw]
Subject: Re: [PATCH 0001/0001] format idle IP output func+offset/length

Thx Josh. I'll refine the patch.
Answer question as below.

On 07:11 Mon 06 Nov, Josh Poimboeuf wrote:
> On Mon, Nov 06, 2017 at 06:52:03PM +0800, Liu, Changcheng wrote:
> > kaslr feature is enabled in kernel.
> > Remove kernel text address when dumping idle IP info
> >
> > Signed-off-by: Liu Changcheng <[email protected]>
> > Signed-off-by: Jerry Liu <[email protected]>
> >
> > diff --git a/lib/nmi_backtrace.c b/lib/nmi_backtrace.c
> > index 0bc0a35..9cc4178 100644
> > --- a/lib/nmi_backtrace.c
> > +++ b/lib/nmi_backtrace.c
> > @@ -92,7 +92,7 @@ bool nmi_cpu_backtrace(struct pt_regs *regs)
> > if (cpumask_test_cpu(cpu, to_cpumask(backtrace_mask))) {
> > arch_spin_lock(&lock);
> > if (regs && cpu_in_idle(instruction_pointer(regs))) {
> > - pr_warn("NMI backtrace for cpu %d skipped: idling at pc %#lx\n",
> > + pr_warn("NMI backtrace for cpu %d skipped: idling at %pS\n",
> > cpu, instruction_pointer(regs));
> > } else {
> > pr_warn("NMI backtrace for cpu %d\n", cpu);
>
> 1) The patch introduces a compile warning.
I've got the point because the conversion between pointer and unsigned long.
>
> 2) When posting a new version of the patch, it should have a new version
> in the subject, e.g. "PATCH v2".
Thx for your guide. I'm on the way to work with community.
>
> 3) The subject is missing a prefix, like "lib_backtrace: "
>
> 4) The subject isn't very clear, how about something like:
>
> lib_backtrace: fix kernel text address leak
I'll use this subject.
>
> 5) The description isn't correct. KASLR isn't always enabled, it
> depends on the user's config. But even without KASLR, we don't want
> to leak kernel text addresses.
That's fine.
>
> 6) The description should use complete sentences.
Yes.
>
> 7) I'm not sure the "Signed-off-by:" chain is correct. Was Jerry Liu
> the original author of the patch?
This is my personal bad habit. I'll correct it.
>
> --
> Josh

From 1583322458483195420@xxx Mon Nov 06 13:12:43 +0000 2017
X-GM-THRID: 1583285189293629278
X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread


2017-11-06 18:16:03

by Liu, Changcheng

[permalink] [raw]
Subject: Re: [PATCH v2] lib_backtrace: fix kernel text address leak

Don't leak idle function address in NMI backtrace.

Signed-off-by: Liu Changcheng <[email protected]>

diff --git a/lib/nmi_backtrace.c b/lib/nmi_backtrace.c
index 46e4c749..61a6b5a 100644
--- a/lib/nmi_backtrace.c
+++ b/lib/nmi_backtrace.c
@@ -93,8 +93,8 @@ bool nmi_cpu_backtrace(struct pt_regs *regs)
if (cpumask_test_cpu(cpu, to_cpumask(backtrace_mask))) {
arch_spin_lock(&lock);
if (regs && cpu_in_idle(instruction_pointer(regs))) {
- pr_warn("NMI backtrace for cpu %d skipped: idling at pc %#lx\n",
- cpu, instruction_pointer(regs));
+ pr_warn("NMI backtrace for cpu %d skipped: idling at %pS\n",
+ cpu, (void *)instruction_pointer(regs));
} else {
pr_warn("NMI backtrace for cpu %d\n", cpu);
if (regs)
--
2.7.4

From 1583338614296935305@xxx Mon Nov 06 17:29:30 +0000 2017
X-GM-THRID: 1583338614296935305
X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread

2017-11-06 17:29:31

by Josh Poimboeuf

[permalink] [raw]
Subject: Re: [PATCH v2] lib_backtrace: fix kernel text address leak

On Tue, Nov 07, 2017 at 12:56:48AM +0800, Liu, Changcheng wrote:
> Don't leak idle function address in NMI backtrace.
>
> Signed-off-by: Liu Changcheng <[email protected]>
>
> diff --git a/lib/nmi_backtrace.c b/lib/nmi_backtrace.c
> index 46e4c749..61a6b5a 100644
> --- a/lib/nmi_backtrace.c
> +++ b/lib/nmi_backtrace.c
> @@ -93,8 +93,8 @@ bool nmi_cpu_backtrace(struct pt_regs *regs)
> if (cpumask_test_cpu(cpu, to_cpumask(backtrace_mask))) {
> arch_spin_lock(&lock);
> if (regs && cpu_in_idle(instruction_pointer(regs))) {
> - pr_warn("NMI backtrace for cpu %d skipped: idling at pc %#lx\n",
> - cpu, instruction_pointer(regs));
> + pr_warn("NMI backtrace for cpu %d skipped: idling at %pS\n",
> + cpu, (void *)instruction_pointer(regs));
> } else {
> pr_warn("NMI backtrace for cpu %d\n", cpu);
> if (regs)

Sorry, I had a typo in my suggestion. The subject prefix should be:
"nmi_backtrace" instead of "lib_backtrace".

Also, when posting a followup patch, please remove the "Re: " from the
subject so that it's clear that it's a new patch, and not a comment for
the old one.

Otherwise it looks great to me. Thanks!

--
Josh

From 1583307297844566418@xxx Mon Nov 06 09:11:44 +0000 2017
X-GM-THRID: 1583307297844566418
X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread