Received: by 10.223.185.116 with SMTP id b49csp464599wrg; Tue, 20 Feb 2018 02:23:33 -0800 (PST) X-Google-Smtp-Source: AH8x227+GqwI5bqtOUDaIeR02aymBFKFxRP9qe21LIYcGZ/KYva5zxK/6G1sX7kwbuUO/58LLchZ X-Received: by 10.99.146.3 with SMTP id o3mr14773225pgd.309.1519122213505; Tue, 20 Feb 2018 02:23:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519122213; cv=none; d=google.com; s=arc-20160816; b=XUKEo3Icz5LDlJ/G9xlYQnpPw40YtYM5xSvWVnn8k7JsIe3olCdP9BzXRC33m0OXlQ 2oJN6EoX2MuLT6dpMNfvgT1A1yw8aRb7XnyxHomzKbyBnb9z+EAtd86eb6xb9qonLw21 1r3LTr2nFn6qq5z+KtQAh7d5hK1MzjMghXmDoHrnsRAIPaG1hC0y0s2RJBwDfcIAjgjz gZut7501pP/6Z/htva7FxnjTbZMl2uZOrPSHGIyMtjm1ltKnmqJuAshesIuyhpB4v4nD mq9Fg5VqtyqH7xhvezBhx+3a7aDXHL4z7QttdVUQbx4UEufRBWQ3l+z8UjCpEqF+Xat6 eNcQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :arc-authentication-results; bh=00xG03ccfX2JM/9TDbzrwG/Jx9OSrSTo4X24fwfKiRw=; b=y94RJgSLmz0DGYQ+LbpXm0gaqMDVkd5N8D/bZcvdmkC/HOEsMQWjZ595SAD83RWI8m M60iJcuEI9evVGkIxOrbDffSvCaO6UwJcPK7BNj82MUu15MARhcqiX+aOs+gsLI6QfXW PBUmxDVIT8CCvXSJagOC18X5KmQtU6bC7V+mjdmx43HJjxbURclOJfSQuuRUYMg3BBuD cV6JZDd5LZym1vA96dnlD0dnkYdxklJk/8Bs7W7iILPOHs4gsCE9rl5Zalj06nmCh6Lv TtIjmPR6ycZG4saXLh3xM1qMHSwniLXefH69+Kl1TU6Se7FvMgp55JyDfuTN/AspcOx6 M/yw== 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 f78si2634106pfa.56.2018.02.20.02.23.19; Tue, 20 Feb 2018 02:23:33 -0800 (PST) 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 S1751324AbeBTKWH (ORCPT + 99 others); Tue, 20 Feb 2018 05:22:07 -0500 Received: from michel.telenet-ops.be ([195.130.137.88]:54360 "EHLO michel.telenet-ops.be" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751338AbeBTKVu (ORCPT ); Tue, 20 Feb 2018 05:21:50 -0500 Received: from ayla.of.borg ([84.194.111.163]) by michel.telenet-ops.be with bizsmtp id CyMo1x00V3XaVaC06yMo6G; Tue, 20 Feb 2018 11:21:49 +0100 Received: from ramsan.of.borg ([192.168.97.29] helo=ramsan) by ayla.of.borg with esmtp (Exim 4.86_2) (envelope-from ) id 1eo4fp-0002mu-2T; Tue, 20 Feb 2018 10:57:21 +0100 Received: from geert by ramsan with local (Exim 4.86_2) (envelope-from ) id 1eo3pX-00089o-GB; Tue, 20 Feb 2018 10:03:19 +0100 From: Geert Uytterhoeven To: Jaehoon Chung , Ulf Hansson Cc: linux-mmc@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Geert Uytterhoeven Subject: [PATCH] mmc: dw_mmc-k3: Fix out-of-bounds access through DT alias Date: Tue, 20 Feb 2018 10:03:13 +0100 Message-Id: <1519117393-31302-1-git-send-email-geert+renesas@glider.be> X-Mailer: git-send-email 2.7.4 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The hs_timing_cfg[] array is indexed using a value derived from the "mshcN" alias in DT, which may lead to an out-of-bounds access. Fix this by adding a range check. Fixes: 7d92895208a008a2 ("mmc: dw_mmc-k3: Fix out-of-bounds access through DT alias") Signed-off-by: Geert Uytterhoeven --- Compile-tested only. There is another possible out-of-bounds access in drivers/mmc/host/dw_mmc.c:dw_mci_init_slot(): if (drv_data && drv_data->caps) mmc->caps |= drv_data->caps[ctrl_id]; With ctrl_id derived from "mshcN". Unfortunately the upper bound is not known at run-time, without adding such a field to struct dw_mci_drv_data first. --- drivers/mmc/host/dw_mmc-k3.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/mmc/host/dw_mmc-k3.c b/drivers/mmc/host/dw_mmc-k3.c index 73fd75c3c824904d..75ae5803b0db24dd 100644 --- a/drivers/mmc/host/dw_mmc-k3.c +++ b/drivers/mmc/host/dw_mmc-k3.c @@ -135,6 +135,9 @@ static int dw_mci_hi6220_parse_dt(struct dw_mci *host) if (priv->ctrl_id < 0) priv->ctrl_id = 0; + if (priv->ctrl_id >= TIMING_MODE) + return -EINVAL; + host->priv = priv; return 0; } -- 2.7.4