Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp3692474imm; Mon, 18 Jun 2018 02:24:23 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJoPVAjHEHdiqTTbXO+2qb99AU+bQkR3R7wfjEDCmf74L/cx9QwZRM46NngdGRZhrRiLdWN X-Received: by 2002:a62:10c2:: with SMTP id 63-v6mr12643612pfq.229.1529313862995; Mon, 18 Jun 2018 02:24:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529313862; cv=none; d=google.com; s=arc-20160816; b=QL5oVNqk0z0T4N5QW4cnXolRQ3x1NQ7bzQnRTYe4wO1m8AdaK0RmADgx1z6DD6PMBZ MX+9mPeJZgwOqzIHCG4BnW2gysQ0wBVFzUZ/N9FVccSXkzxc4Q4iH5Zs7b75cbnQSHF2 URRnefn7zkU0t2RABHtTBmKra+oWpkI/OYGbt/kgZekMx5Vbj/bdzJUXk/ShGHrfaob+ HGsQHiaJr87DHiN+0zHxSgoxzGgFflOAvtgKB4niGalKLrg7UX/HE3Yauu5DosD/nTjc n7ghVFBAfAsMMh9JuM/lCa16GXqECdPpi6F6H/WVq1KFGfXBjfPM7H6EBkHmvXS+256f CGDA== 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=DOUnD+BEfrVNuvWK2KDI8GcbWfD8RKshXLkxxVugXe0=; b=SnTNNw+nrt77wdWEVngvD1nZQPfoXzzWRAAlUZqs4GGMtwqgPZQkuuVOXzIDm0KrAp m9u/Gtvbn6YNsGqJNKHCZmJgMene0T4zSQv8Mvxp/vY8N7NzHVhiSe/e9nMgJIUXNG9z yKrsDLCz1KNdW0AYpE+W4k+drAcn681sR++SOvc0se+hgv9w89x2E/sVN926v5kTuxfX rgmi2lK4tUmc4eRik1UraSpfxlDot+elWH+uPcL80dhiE1LuFVDqlVltgUVrXmG+k5W1 pmiMTIGSdkZCJpzoCiXs1c55dwKVQoYlaa0MKLR+QoHkm2aA4VZHTVz0COtX8nTFz767 WFzw== 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 y89-v6si14665553pfd.47.2018.06.18.02.24.09; Mon, 18 Jun 2018 02:24:22 -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 S966030AbeFRI1Z (ORCPT + 99 others); Mon, 18 Jun 2018 04:27:25 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:57592 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S936545AbeFRI1V (ORCPT ); Mon, 18 Jun 2018 04:27:21 -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 171A3C5C; Mon, 18 Jun 2018 08:27:20 +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 4.16 257/279] ARM: keystone: fix platform_domain_notifier array overrun Date: Mon, 18 Jun 2018 10:14:02 +0200 Message-Id: <20180618080619.364826637@linuxfoundation.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180618080608.851973560@linuxfoundation.org> References: <20180618080608.851973560@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 4.16-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 @@ -29,6 +29,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 const struct of_device_id of_keystone_table[] = {