Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp3080137imm; Sun, 1 Jul 2018 11:48:41 -0700 (PDT) X-Google-Smtp-Source: ADUXVKIZm0MvwNuva8a/M/R5QnN1S3E0qGq562Oboexm8sy6SRakCdA0t5naJgGfTAhGcc6yGmX7 X-Received: by 2002:a63:9f1a:: with SMTP id g26-v6mr18728538pge.178.1530470921751; Sun, 01 Jul 2018 11:48:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530470921; cv=none; d=google.com; s=arc-20160816; b=rNq67nMBZxMs8Vl2zNY2qsd3M6lEA1YbC9yzGTQOb7L7plOPYpl+FHV98fdFhfT3p8 gtau/utdog9EpXPfDLEVIqaf0JZIqzYPhnd7Tp7MCmV4nYGCRmFPtpeEYFlGZu7IicNW jDomkmnyWcGE7DLwUVgXmmwsle4M2Zt9+/0gSXe7XCe9Taz3xsPRJDd7Z6jCrxyFzt/t vQtHO3DvRZZ2mvkqoiieLsvt0/mK69cN9G6J9jpfNurfOjFxdB55vSPOT0rNEQUUexlC oKFxS1a6NWoQGodtHAqUvKnwPPEutyUWu0oey546487FJp3a1A76dG5FHgdIY6MtQUFq y6iQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=pTnAmWewJOphyNsQpuZxP/ZWfdn4T+Gg/CSAvbRFUGk=; b=XVQZzOJCVGxuw6YADPHQjoYIzwY+xvP8vosa7Sa9Gnip3QEIddnD50CtP7+QuP8SqX WiPIotNhdmfnCf7BlkehUqgFb4VWG4NeCMGQhNF1FrVHg4txh46+DUXKDvrReVZAv4Db kMytznbvf32NTFAUHAh3ozMdR+989GiFqANsD1rC9Pgej7VONuyHxcOf5IBHxNQ7J8+h rN4ITYdXwGCID++l5rOtdudW+S3lZR0/IaIglJS1cfuLS3GUofl1qzaPXaQcGLG7zDu4 QIdLJB8DrPwPyBHnC6PRkxM8QjmxT6MwxajjPTnUiYYiAEgNurLmqevRhqFHzdWCY3L6 YneQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u7-v6si12827952pgn.194.2018.07.01.11.48.27; Sun, 01 Jul 2018 11:48:41 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752858AbeGAQME (ORCPT + 99 others); Sun, 1 Jul 2018 12:12:04 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:59858 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752461AbeGAQMA (ORCPT ); Sun, 1 Jul 2018 12:12:00 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 93C724A3; Sun, 1 Jul 2018 16:11:59 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Russell King , Santosh Shilimkar , Olof Johansson , Sasha Levin Subject: [PATCH 3.18 30/85] ARM: keystone: fix platform_domain_notifier array overrun Date: Sun, 1 Jul 2018 18:01:48 +0200 Message-Id: <20180701153123.563915696@linuxfoundation.org> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180701153122.365061142@linuxfoundation.org> References: <20180701153122.365061142@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 3.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: Russell King [ Upstream commit 9954b80b8c0e8abc98e17bba0fccd9876211ceaa ] platform_domain_notifier contains a variable sized array, which the pm_clk_notify() notifier treats as a NULL terminated array: for (con_id = clknb->con_ids; *con_id; con_id++) pm_clk_add(dev, *con_id); Omitting the initialiser for con_ids means that the array is zero sized, and there is no NULL terminator. This leads to pm_clk_notify() overrunning into what ever structure follows, which may not be NULL. This leads to an oops: Unable to handle kernel NULL pointer dereference at virtual address 0000008c pgd = c0003000 [0000008c] *pgd=80000800004003c, *pmd=00000000c Internal error: Oops: 206 [#1] PREEMPT SMP ARM Modules linked in:c CPU: 0 PID: 1 Comm: swapper/0 Not tainted 4.16.0+ #9 Hardware name: Keystone PC is at strlen+0x0/0x34 LR is at kstrdup+0x18/0x54 pc : [] lr : [] psr: 20000013 sp : eec73dc0 ip : eed780c0 fp : 00000001 r10: 00000000 r9 : 00000000 r8 : eed71e10 r7 : 0000008c r6 : 0000008c r5 : 014000c0 r4 : c03a6ff4 r3 : c09445d0 r2 : 00000000 r1 : 014000c0 r0 : 0000008c Flags: nzCv IRQs on FIQs on Mode SVC_32 ISA ARM Segment user Control: 30c5387d Table: 00003000 DAC: fffffffd Process swapper/0 (pid: 1, stack limit = 0xeec72210) Stack: (0xeec73dc0 to 0xeec74000) ... [] (strlen) from [] (kstrdup+0x18/0x54) [] (kstrdup) from [] (__pm_clk_add+0x58/0x120) [] (__pm_clk_add) from [] (pm_clk_notify+0x64/0xa8) [] (pm_clk_notify) from [] (notifier_call_chain+0x44/0x84) [] (notifier_call_chain) from [] (__blocking_notifier_call_chain+0x48/0x60) [] (__blocking_notifier_call_chain) from [] (blocking_notifier_call_chain+0x18/0x20) [] (blocking_notifier_call_chain) from [] (device_add+0x36c/0x534) [] (device_add) from [] (of_platform_device_create_pdata+0x70/0xa4) [] (of_platform_device_create_pdata) from [] (of_platform_bus_create+0xf0/0x1ec) [] (of_platform_bus_create) from [] (of_platform_populate+0x5c/0xac) [] (of_platform_populate) from [] (of_platform_default_populate_init+0x8c/0xa8) [] (of_platform_default_populate_init) from [] (do_one_initcall+0x3c/0x164) [] (do_one_initcall) from [] (kernel_init_freeable+0x10c/0x1d0) [] (kernel_init_freeable) from [] (kernel_init+0x8/0xf0) [] (kernel_init) from [] (ret_from_fork+0x14/0x3c) Exception stack(0xeec73fb0 to 0xeec73ff8) 3fa0: 00000000 00000000 00000000 00000000 3fc0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 3fe0: 00000000 00000000 00000000 00000000 00000013 00000000 Code: e3520000 1afffff7 e12fff1e c0801730 (e5d02000) ---[ end trace cafa8f148e262e80 ]--- Fix this by adding the necessary initialiser. Fixes: fc20ffe1213b ("ARM: keystone: add PM domain support for clock management") Signed-off-by: Russell King Acked-by: Santosh Shilimkar Signed-off-by: Olof Johansson Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- arch/arm/mach-keystone/pm_domain.c | 1 + 1 file changed, 1 insertion(+) --- a/arch/arm/mach-keystone/pm_domain.c +++ b/arch/arm/mach-keystone/pm_domain.c @@ -59,6 +59,7 @@ static struct dev_pm_domain keystone_pm_ static struct pm_clk_notifier_block platform_domain_notifier = { .pm_domain = &keystone_pm_domain, + .con_ids = { NULL }, }; static struct of_device_id of_keystone_table[] = {