public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Greg KH <gregkh@suse.de>
To: linux-kernel@vger.kernel.org, stable@kernel.org,
	Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Justin Forbes <jmforbes@linuxtx.org>,
	Zwane Mwaikambo <zwane@arm.linux.org.uk>,
	"Theodore Ts'o" <tytso@mit.edu>,
	Randy Dunlap <rdunlap@xenotime.net>,
	Dave Jones <davej@redhat.com>,
	Chuck Wolber <chuckw@quantumlinux.com>,
	Chris Wedgwood <reviews@ml.cw.f00f.org>,
	Michael Krufky <mkrufky@linuxtv.org>,
	Chuck Ebbert <cebbert@redhat.com>,
	Domenico Andreoli <cavokz@gmail.com>, Willy Tarreau <w@1wt.eu>,
	Rodrigo Rubira Branco <rbranco@la.checkpoint.com>,
	Jake Edge <jake@lwn.net>, Eugene Teo <eteo@redhat.com>,
	torvalds@linux-foundation.org, akpm@linux-foundation.org,
	alan@lxorguk.ukuu.org.uk, Ingo Molnar <mingo@elte.hu>,
	Oliver Pinter <oliver.pntr@gmail.com>,
	Masami Hiramatsu <mhiramat@redhat.com>
Subject: [patch 08/25] Kprobe smoke test lockdep warning
Date: Mon, 4 Aug 2008 14:30:13 -0700	[thread overview]
Message-ID: <20080804213013.GH8014@suse.de> (raw)
In-Reply-To: <20080804212725.GA7944@suse.de>

[-- Attachment #1: kprobe-smoke-test-lockdep-warning.patch --]
[-- Type: text/plain, Size: 4762 bytes --]


2.6.26-stable review patch.  If anyone has any objections, please let us
know.

------------------

From: Peter Zijlstra <peterz@infradead.org>

[ Upstream commit d54191b85e294c46f05a2249b1f55ae54930bcc7 ]

On Mon, 2008-04-21 at 18:54 -0400, Masami Hiramatsu wrote:
> Thank you for reporting.
>
> Actually, kprobes tries to fixup thread's flags in post_kprobe_handler
> (which is called from kprobe_exceptions_notify) by
> trace_hardirqs_fixup_flags(pt_regs->flags). However, even the irq flag
> is set in pt_regs->flags, true hardirq is still off until returning
> from do_debug. Thus, lockdep assumes that hardirq is off without
annotation.
>
> IMHO, one possible solution is that fixing hardirq flags right after
> notify_die in do_debug instead of in post_kprobe_handler.

My reply to BZ 10489:

> [    2.707509] Kprobe smoke test started
> [    2.709300] ------------[ cut here ]------------
> [    2.709420] WARNING: at kernel/lockdep.c:2658 check_flags+0x4d/0x12c()
> [    2.709541] Modules linked in:
> [    2.709588] Pid: 1, comm: swapper Not tainted 2.6.25.jml.057 #1
> [    2.709588]  [<c0126acc>] warn_on_slowpath+0x41/0x51
> [    2.709588]  [<c010bafc>] ? save_stack_trace+0x1d/0x3b
> [    2.709588]  [<c0140a83>] ? save_trace+0x37/0x89
> [    2.709588]  [<c011987d>] ? kernel_map_pages+0x103/0x11c
> [    2.709588]  [<c0109803>] ? native_sched_clock+0xca/0xea
> [    2.709588]  [<c0142958>] ? mark_held_locks+0x41/0x5c
> [    2.709588]  [<c0382580>] ? kprobe_exceptions_notify+0x322/0x3af
> [    2.709588]  [<c0142aff>] ? trace_hardirqs_on+0xf1/0x119
> [    2.709588]  [<c03825b3>] ? kprobe_exceptions_notify+0x355/0x3af
> [    2.709588]  [<c0140823>] check_flags+0x4d/0x12c
> [    2.709588]  [<c0143c9d>] lock_release+0x58/0x195
> [    2.709588]  [<c038347c>] ? __atomic_notifier_call_chain+0x0/0x80
> [    2.709588]  [<c03834d6>] __atomic_notifier_call_chain+0x5a/0x80
> [    2.709588]  [<c0383508>] atomic_notifier_call_chain+0xc/0xe
> [    2.709588]  [<c013b6d4>] notify_die+0x2d/0x2f
> [    2.709588]  [<c038168a>] do_debug+0x67/0xfe
> [    2.709588]  [<c0381287>] debug_stack_correct+0x27/0x30
> [    2.709588]  [<c01564c0>] ? kprobe_target+0x1/0x34
> [    2.709588]  [<c0156572>] ? init_test_probes+0x50/0x186
> [    2.709588]  [<c04fae48>] init_kprobes+0x85/0x8c
> [    2.709588]  [<c04e947b>] kernel_init+0x13d/0x298
> [    2.709588]  [<c04e933e>] ? kernel_init+0x0/0x298
> [    2.709588]  [<c04e933e>] ? kernel_init+0x0/0x298
> [    2.709588]  [<c0105ef7>] kernel_thread_helper+0x7/0x10
> [    2.709588]  =======================
> [    2.709588] ---[ end trace 778e504de7e3b1e3 ]---
> [    2.709588] possible reason: unannotated irqs-off.
> [    2.709588] irq event stamp: 370065
> [    2.709588] hardirqs last  enabled at (370065): [<c0382580>]
kprobe_exceptions_notify+0x322/0x3af
> [    2.709588] hardirqs last disabled at (370064): [<c0381bb7>]
do_int3+0x1d/0x7d
> [    2.709588] softirqs last  enabled at (370050): [<c012b464>]
__do_softirq+0xfa/0x100
> [    2.709588] softirqs last disabled at (370045): [<c0107438>]
do_softirq+0x74/0xd9
> [    2.714751] Kprobe smoke test passed successfully

how I love this stuff...

Ok, do_debug() is a trap, this can happen at any time regardless of the
machine's IRQ state. So the first thing we do is fix up the IRQ state.
Then we call this die notifier stuff; and return with messed up IRQ
state... YAY.

So, kprobes fudges it..

  notify_die(DIE_DEBUG)
    kprobe_exceptions_notify()
      post_kprobe_handler()
        modify regs->flags
        trace_hardirqs_fixup_flags(regs->flags);  <--- must be it

So what's the use of modifying flags if they're not meant to take effect
at some point.

/me tries to reproduce issue; enable kprobes test thingy && boot

OK, that reproduces..

So the below makes it work - but I'm not getting this code; at the time
I wrote that stuff I CC'ed each and every kprobe maintainer listed in
the usual places but got no reposonse - can some please explain this
stuff to me?

Are the saved flags only for the TF bit or are they made in full effect
later (and if so, where) ?

Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Acked-by: Masami Hiramatsu <mhiramat@redhat.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
CC: Oliver Pinter <oliver.pntr@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>

---
 arch/x86/kernel/kprobes.c |    1 -
 1 file changed, 1 deletion(-)

--- a/arch/x86/kernel/kprobes.c
+++ b/arch/x86/kernel/kprobes.c
@@ -860,7 +860,6 @@ static int __kprobes post_kprobe_handler
 
 	resume_execution(cur, regs, kcb);
 	regs->flags |= kcb->kprobe_saved_flags;
-	trace_hardirqs_fixup_flags(regs->flags);
 
 	if ((kcb->kprobe_status != KPROBE_REENTER) && cur->post_handler) {
 		kcb->kprobe_status = KPROBE_HIT_SSDONE;

-- 

  parent reply	other threads:[~2008-08-04 21:38 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20080804203506.816201392@mini.kroah.org>
2008-08-04 21:27 ` [patch 00/25] 2.6.26-stable review Greg KH
2008-08-04 21:29   ` [patch 01/25] ftrace: remove unneeded documentation Greg KH
2008-08-04 21:42     ` Steven Rostedt
2008-08-04 21:46       ` Greg KH
2008-08-04 22:16         ` Steven Rostedt
2008-08-04 21:49       ` Randy Dunlap
2008-08-04 22:02         ` Steven Rostedt
2008-08-04 22:06           ` Randy Dunlap
2008-08-04 21:29   ` [patch 02/25] romfs_readpage: dont report errors for pages beyond i_size Greg KH
2008-08-04 21:29   ` [patch 03/25] netfilter: nf_nat_sip: c= is optional for session Greg KH
2008-08-04 21:29   ` [patch 04/25] SCSI: bsg: fix bsg_mutex hang with device removal Greg KH
2008-08-04 21:29   ` [patch 05/25] x86: idle process - add checking for NULL early param Greg KH
2008-08-04 21:29   ` [patch 06/25] x86: io delay " Greg KH
2008-08-04 21:29   ` [patch 07/25] Close race in md_probe Greg KH
2008-08-04 21:30   ` Greg KH [this message]
2008-08-04 21:30   ` [patch 09/25] netfilter: xt_time: fix times time_mt()s use of do_div() Greg KH
2008-08-04 21:30   ` [patch 10/25] linear: correct disk numbering error check Greg KH
2008-08-04 21:30   ` [patch 11/25] SCSI: ch: fix ch_remove oops Greg KH
2008-08-04 21:30   ` [patch 12/25] NFS: Ensure we zap only the access and acl caches when setting new acls Greg KH
2008-08-04 21:30   ` [patch 13/25] jbd: fix race between free buffer and commit transaction Greg KH
2008-08-04 21:30   ` [patch 14/25] Input: i8042 - add Intel D845PESV to nopnp list Greg KH
2008-08-04 21:30   ` [patch 15/25] Input: i8042 - add Gericom Bellagio to nomux blacklist Greg KH
2008-08-04 21:30   ` [patch 16/25] Input: i8042 - add Acer Aspire 1360 " Greg KH
2008-08-04 21:30   ` [patch 17/25] Bluetooth: Signal user-space for HIDP and BNEP socket errors Greg KH
2008-08-04 21:30   ` [patch 18/25] Add compat handler for PTRACE_GETSIGINFO Greg KH
2008-08-04 21:30   ` [patch 19/25] ALSA: hda - Fix wrong volumes in AD1988 auto-probe mode Greg KH
2008-08-04 21:30   ` [patch 20/25] ALSA: hda - Fix DMA position inaccuracy Greg KH
2008-08-04 21:30   ` [patch 21/25] ALSA: hda - Add missing Thinkpad Z60m support Greg KH
2008-08-04 21:30   ` [patch 22/25] ALSA: emu10k1 - Fix inverted Analog/Digital mixer switch on Audigy2 Greg KH
2008-08-04 21:30   ` [patch 23/25] vfs: fix lookup on deleted directory Greg KH
2008-08-04 21:30   ` [patch 24/25] Ath5k: fix memory corruption Greg KH
2008-08-04 21:30   ` [patch 25/25] Ath5k: kill tasklets on shutdown Greg KH

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=20080804213013.GH8014@suse.de \
    --to=gregkh@suse.de \
    --cc=a.p.zijlstra@chello.nl \
    --cc=akpm@linux-foundation.org \
    --cc=alan@lxorguk.ukuu.org.uk \
    --cc=cavokz@gmail.com \
    --cc=cebbert@redhat.com \
    --cc=chuckw@quantumlinux.com \
    --cc=davej@redhat.com \
    --cc=eteo@redhat.com \
    --cc=jake@lwn.net \
    --cc=jmforbes@linuxtx.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mhiramat@redhat.com \
    --cc=mingo@elte.hu \
    --cc=mkrufky@linuxtv.org \
    --cc=oliver.pntr@gmail.com \
    --cc=rbranco@la.checkpoint.com \
    --cc=rdunlap@xenotime.net \
    --cc=reviews@ml.cw.f00f.org \
    --cc=stable@kernel.org \
    --cc=torvalds@linux-foundation.org \
    --cc=tytso@mit.edu \
    --cc=w@1wt.eu \
    --cc=zwane@arm.linux.org.uk \
    /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
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox