Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755491Ab3FGBm6 (ORCPT ); Thu, 6 Jun 2013 21:42:58 -0400 Received: from mail-pd0-f170.google.com ([209.85.192.170]:63327 "EHLO mail-pd0-f170.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754842Ab3FGBm5 convert rfc822-to-8bit (ORCPT ); Thu, 6 Jun 2013 21:42:57 -0400 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8BIT To: Lai Jiangshan , =?utf-8?q?S=C3=B6ren_Brinkmann?= From: Mike Turquette In-Reply-To: <51AC5F1B.4020409@cn.fujitsu.com> Cc: Michal Simek , paulmck@linux.vnet.ibm.com, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, git@xilinx.com References: <42b8bfd5-3012-4c49-b9ef-7a9beb5956f1@VA3EHSMHS041.ehs.local> <51AC5F1B.4020409@cn.fujitsu.com> Message-ID: <20130607014243.10233.79471@quantum> User-Agent: alot/0.3.4 Subject: Re: [PATCH] clk: remove the clk_notifier from clk_notifier_list before free it (was: Re: [BUG] zynq | CCF | SRCU) Date: Thu, 06 Jun 2013 18:42:44 -0700 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 4724 Lines: 80 Quoting Lai Jiangshan (2013-06-03 02:17:15) > The @cn is stay in @clk_notifier_list after it is freed, it cause > memory corruption. > > Example, if @clk is registered(first), unregistered(first), > registered(second), unregistered(second). > > The freed @cn will be used when @clk is registered(second), > and the bug will be happened when @clk is unregistered(second): > > [ 517.040000] clk_notif_dbg clk_notif_dbg.1: clk_notifier_unregister() > [ 517.040000] Unable to handle kernel paging request at virtual address 00df3008 > [ 517.050000] pgd = ed858000 > [ 517.050000] [00df3008] *pgd=00000000 > [ 517.060000] Internal error: Oops: 5 [#1] PREEMPT SMP ARM > [ 517.060000] Modules linked in: clk_notif_dbg(O-) [last unloaded: clk_notif_dbg] > [ 517.060000] CPU: 1 PID: 499 Comm: modprobe Tainted: G O 3.10.0-rc3-00119-ga93cb29-dirty #85 > [ 517.060000] task: ee1e0180 ti: ee3e6000 task.ti: ee3e6000 > [ 517.060000] PC is at srcu_readers_seq_idx+0x48/0x84 > [ 517.060000] LR is at srcu_readers_seq_idx+0x60/0x84 > [ 517.060000] pc : [] lr : [] psr: 80070013 > [ 517.060000] sp : ee3e7d48 ip : 00000000 fp : ee3e7d6c > [ 517.060000] r10: 00000000 r9 : ee3e6000 r8 : 00000000 > [ 517.060000] r7 : ed84fe4c r6 : c068ec90 r5 : c068e430 r4 : 00000000 > [ 517.060000] r3 : 00df3000 r2 : 00000000 r1 : 00000002 r0 : 00000000 > [ 517.060000] Flags: Nzcv IRQs on FIQs on Mode SVC_32 ISA ARM Segment user > [ 517.060000] Control: 18c5387d Table: 2d85804a DAC: 00000015 > [ 517.060000] Process modprobe (pid: 499, stack limit = 0xee3e6238) > [ 517.060000] Stack: (0xee3e7d48 to 0xee3e8000) > .... > [ 517.060000] [] (srcu_readers_seq_idx+0x48/0x84) from [] (try_check_zero+0x34/0xfc) > [ 517.060000] [] (try_check_zero+0x34/0xfc) from [] (srcu_advance_batches+0x58/0x114) > [ 517.060000] [] (srcu_advance_batches+0x58/0x114) from [] (__synchronize_srcu+0x114/0x1ac) > [ 517.060000] [] (__synchronize_srcu+0x114/0x1ac) from [] (synchronize_srcu+0x2c/0x34) > [ 517.060000] [] (synchronize_srcu+0x2c/0x34) from [] (srcu_notifier_chain_unregister+0x68/0x74) > [ 517.060000] [] (srcu_notifier_chain_unregister+0x68/0x74) from [] (clk_notifier_unregister+0x7c/0xc0) > [ 517.060000] [] (clk_notifier_unregister+0x7c/0xc0) from [] (clk_notif_dbg_remove+0x34/0x9c [clk_notif_dbg]) > [ 517.060000] [] (clk_notif_dbg_remove+0x34/0x9c [clk_notif_dbg]) from [] (platform_drv_remove+0x24/0x28) > [ 517.060000] [] (platform_drv_remove+0x24/0x28) from [] (__device_release_driver+0x8c/0xd4) > [ 517.060000] [] (__device_release_driver+0x8c/0xd4) from [] (driver_detach+0x9c/0xc4) > [ 517.060000] [] (driver_detach+0x9c/0xc4) from [] (bus_remove_driver+0xcc/0xfc) > [ 517.060000] [] (bus_remove_driver+0xcc/0xfc) from [] (driver_unregister+0x54/0x78) > [ 517.060000] [] (driver_unregister+0x54/0x78) from [] (platform_driver_unregister+0x1c/0x20) > [ 517.060000] [] (platform_driver_unregister+0x1c/0x20) from [] (clk_notif_dbg_driver_exit+0x14/0x1c [clk_notif_dbg]) > [ 517.060000] [] (clk_notif_dbg_driver_exit+0x14/0x1c [clk_notif_dbg]) from [] (SyS_delete_module+0x200/0x28c) > [ 517.060000] [] (SyS_delete_module+0x200/0x28c) from [] (ret_fast_syscall+0x0/0x48) > [ 517.060000] Code: e5973004 e7911102 e0833001 e2881002 (e7933101) > > CC: stable@kernel.org > Reported-by: Sören Brinkmann > Signed-off-by: Lai Jiangshan Thanks! I picked this up for the next set of fixes. Regards, Mike > --- > drivers/clk/clk.c | 1 + > 1 files changed, 1 insertions(+), 0 deletions(-) > > diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c > index 934cfd1..1144e8c 100644 > --- a/drivers/clk/clk.c > +++ b/drivers/clk/clk.c > @@ -1955,6 +1955,7 @@ int clk_notifier_unregister(struct clk *clk, struct notifier_block *nb) > /* XXX the notifier code should handle this better */ > if (!cn->notifier_head.head) { > srcu_cleanup_notifier_head(&cn->notifier_head); > + list_del(&cn->node); > kfree(cn); > } > > -- > 1.7.4.4 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/