Path: csiph.com!aioe.org!bofh.it!news.nic.it!robomod From: Mathieu Poirier Newsgroups: linux.kernel Subject: Re: [PATCH 1/5] coresight: Fix NULL pointer dereference in _coresight_build_path Date: Tue, 31 May 2016 19:40:02 +0200 Message-ID: References: X-Original-To: Suzuki K Poulose , Greg KH Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc; bh=7yC4S72qRfpNf+eGpyDOS8QDWavZet8pa+n2FGrFV3o=; b=hu5e6ry9d77t/cfNxlyzxtqPgndPdLCFNlsJBhGk383KtRkmle6KWZhFdMXhJGh1eB qpqX6fC9CMrdehfXpB6A2ccPFTDlnDN6NWBRb3xPEVC2g++dwH7oZS2OjpcGxZoSAH0C nssJ26PZURxnyjBofiT8uyYvniujMqh+3GRPs= X-Google-Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc; bh=7yC4S72qRfpNf+eGpyDOS8QDWavZet8pa+n2FGrFV3o=; b=V90t7yIKVfE8JQ4GQ80S3py2zZrErLpU2dy93bum7hCMg9v+z/yoRjVqeWzBVQvT7n 8kb2GSWhtzX0uvMBYd9ro4vHjbuT8lFmk2jGfpjSW5kNX2i3eGngxh/OPHMghilUENLW OLOkuzk3JKbk3J87H2lCivabb++EpecPAT+RoGbv5oZdRlNbRlaPQxC2R6ACvbhkR0hY spYvdhFFIkBYMtWVT71c33x3bUCs81O7MTwiU1EdWS2wita67Lk+GXP3qt1O8nklrD7t /XHQnP9NJPA0Hc5dykXuLm2xkDOr83E6+CRifylWH9Lf4Ova7xAwpFu5Sc7tt1yG2Ip9 6u/Q== X-Gm-Message-State: ALyK8tLJHJmh/JCeeQ9CgT5p7KzcWE6ZBo1gBHFgEXocAGiq/OkTjjENapW5RLORkwvmgpP5D6+FB2NH0Ei6HpLV MIME-Version: 1.0 X-Received: by 10.129.110.7 with SMTP id j7mr5546777ywc.49.1464716340985; Tue, 31 May 2016 10:39:00 -0700 (PDT) Content-Type: text/plain; charset=UTF-8 Sender: robomod@news.nic.it List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Approved: robomod@news.nic.it Lines: 76 Organization: linux.* mail to news gateway X-Original-Cc: "linux-arm-kernel@lists.infradead.org" , "linux-kernel@vger.kernel.org" X-Original-Date: Tue, 31 May 2016 11:39:00 -0600 X-Original-Message-ID: X-Original-References: <1464695858-29284-1-git-send-email-suzuki.poulose@arm.com> <1464695858-29284-2-git-send-email-suzuki.poulose@arm.com> X-Original-Sender: linux-kernel-owner@vger.kernel.org Xref: csiph.com linux.kernel:1410483 On 31 May 2016 at 05:57, Suzuki K Poulose wrote: > _coresight_build_path assumes that all the connections of a csdev > has the child_dev initialised. This may not be true if the particular > component is not supported by the kernel config(e.g TPIU) but is > present in the DT. In which case, building a path can cause a crash like this : > > Unable to handle kernel NULL pointer dereference at virtual address 00000010 > pgd = ffffffc9750dd000 > [00000010] *pgd=00000009f5e90003, *pud=00000009f5e90003, *pmd=0000000000000000 > Internal error: Oops: 96000006 [#1] PREEMPT SMP > Modules linked in: > CPU: 4 PID: 1348 Comm: bash Not tainted 4.6.0-next-20160517 #1646 > Hardware name: ARM Juno development board (r0) (DT) > task: ffffffc97517a280 ti: ffffffc9762c4000 task.ti: ffffffc9762c4000 > PC is at _coresight_build_path+0x18/0xe4 > LR is at _coresight_build_path+0xc0/0xe4 > pc : [] lr : [] pstate: 20000145 > sp : ffffffc9762c7ba0 > > [] _coresight_build_path+0x18/0xe4 > [] _coresight_build_path+0xc0/0xe4 > [] _coresight_build_path+0xc0/0xe4 > [] _coresight_build_path+0xc0/0xe4 > [] _coresight_build_path+0xc0/0xe4 > [] _coresight_build_path+0xc0/0xe4 > [] coresight_build_path+0x40/0x68 > [] coresight_enable+0x74/0x1bc > [] enable_source_store+0x3c/0x6c > [] dev_attr_store+0x18/0x28 > [] sysfs_kf_write+0x40/0x50 > [] kernfs_fop_write+0x140/0x1cc > [] __vfs_write+0x28/0x110 > [] vfs_write+0xa0/0x174 > [] SyS_write+0x44/0xa0 > [] el0_svc_naked+0x24/0x28 > > Cc: Mathieu Poirier > Signed-off-by: Suzuki K Poulose > --- > drivers/hwtracing/coresight/coresight.c | 6 +++--- > 1 file changed, 3 insertions(+), 3 deletions(-) > > diff --git a/drivers/hwtracing/coresight/coresight.c b/drivers/hwtracing/coresight/coresight.c > index 5443d03..0fdaaf4 100644 > --- a/drivers/hwtracing/coresight/coresight.c > +++ b/drivers/hwtracing/coresight/coresight.c > @@ -385,7 +385,6 @@ static int _coresight_build_path(struct coresight_device *csdev, > int i; > bool found = false; > struct coresight_node *node; > - struct coresight_connection *conn; > > /* An activated sink has been found. Enqueue the element */ > if ((csdev->type == CORESIGHT_DEV_TYPE_SINK || > @@ -394,8 +393,9 @@ static int _coresight_build_path(struct coresight_device *csdev, > > /* Not a sink - recursively explore each port found on this element */ > for (i = 0; i < csdev->nr_outport; i++) { > - conn = &csdev->conns[i]; > - if (_coresight_build_path(conn->child_dev, path) == 0) { > + struct coresight_device *child_dev = csdev->conns[i].child_dev; > + > + if (child_dev && _coresight_build_path(child_dev, path) == 0) { > found = true; > break; > } > -- > 1.9.1 > Acked-by: Mathieu Poirier Greg, since this is a bug fix can we add it to 4.7-rc2? Thanks, Mathieu