From patchwork Fri Sep 13 12:49:14 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 20031 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-qc0-f197.google.com (mail-qc0-f197.google.com [209.85.216.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 93BEE28E9A for ; Fri, 13 Sep 2013 12:49:48 +0000 (UTC) Received: by mail-qc0-f197.google.com with SMTP id r5sf1174138qcx.4 for ; Fri, 13 Sep 2013 05:49:48 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :list-post:list-help:list-archive:list-unsubscribe; bh=RDS8BPeny3DAJJ2z3t4z17DyJaH3dpyh3MjFl/wiyJc=; b=U4d61gtx6usdzGzHJbyWD7hKvK0FSXb9FAKa4UAynIpR5V1pFFmOvYNSzzBI4pWdAV lYYMiobXZARGM50CEOlmtceUpeXMqfwUgyjTbqfjneVUWBM6j+3SN4JnGYS86lnPUPe/ ZD5cseb0XZSlKN7oKWV0pO18RVBC2vkVFgVnzJucWt3dJ65nH+losK3GPU0dKQ6Xla14 3G91mVL76fakpmcy7Z+ayfTIDvHoK47KsXsdQbk8LhklIAb3IYrlfq9aYcoQWLSx4pOn 91ff3f2fmbRRrfAAz7tba4JkqlMJB3ATG9EyyDUJUEWpAXORA9cLsD13sqybr0p37/n+ 8Qnw== X-Gm-Message-State: ALoCoQno1T2SjZxWLTDTex08FXEif6Jo1Bj04SWfvKhRYo/jseeoo+90AdHnWWqe91wnNUdFQ+Ym X-Received: by 10.236.66.244 with SMTP id h80mr5094216yhd.30.1379076588240; Fri, 13 Sep 2013 05:49:48 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.29.167 with SMTP id l7ls1122753qeh.47.gmail; Fri, 13 Sep 2013 05:49:48 -0700 (PDT) X-Received: by 10.221.51.206 with SMTP id vj14mr11885920vcb.17.1379076587979; Fri, 13 Sep 2013 05:49:47 -0700 (PDT) Received: from mail-ve0-f181.google.com (mail-ve0-f181.google.com [209.85.128.181]) by mx.google.com with ESMTPS id bp7si3094310vcb.7.1969.12.31.16.00.00 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 13 Sep 2013 05:49:47 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.128.181 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.128.181; Received: by mail-ve0-f181.google.com with SMTP id oy12so894223veb.26 for ; Fri, 13 Sep 2013 05:49:47 -0700 (PDT) X-Received: by 10.52.34.109 with SMTP id y13mr10187771vdi.8.1379076587893; Fri, 13 Sep 2013 05:49:47 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.220.174.196 with SMTP id u4csp78771vcz; Fri, 13 Sep 2013 05:49:47 -0700 (PDT) X-Received: by 10.14.107.68 with SMTP id n44mr18332813eeg.26.1379076586571; Fri, 13 Sep 2013 05:49:46 -0700 (PDT) Received: from mail-ea0-f178.google.com (mail-ea0-f178.google.com [209.85.215.178]) by mx.google.com with ESMTPS id i5si3776901eeg.295.1969.12.31.16.00.00 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 13 Sep 2013 05:49:46 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.215.178 is neither permitted nor denied by best guess record for domain of julien.grall@linaro.org) client-ip=209.85.215.178; Received: by mail-ea0-f178.google.com with SMTP id a15so558054eae.37 for ; Fri, 13 Sep 2013 05:49:46 -0700 (PDT) X-Received: by 10.15.56.199 with SMTP id y47mr1339792eew.73.1379076585946; Fri, 13 Sep 2013 05:49:45 -0700 (PDT) Received: from belegaer.uk.xensource.com. ([185.25.64.249]) by mx.google.com with ESMTPSA id p5sm14678420eeg.5.1969.12.31.16.00.00 (version=TLSv1.2 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 13 Sep 2013 05:49:45 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xen.org Cc: stefano.stabellini@eu.citrix.com, ian.campbell@citrix.com, patches@linaro.org, andre.przywara@linaro.org, Julien Grall Subject: [PATCH v4 07/27] xen/dts: Check "reg" property length in process_multiboot_node Date: Fri, 13 Sep 2013 13:49:14 +0100 Message-Id: <1379076574-28316-8-git-send-email-julien.grall@linaro.org> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1379076574-28316-1-git-send-email-julien.grall@linaro.org> References: <1379076574-28316-1-git-send-email-julien.grall@linaro.org> X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: julien.grall@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.128.181 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , The device tree compiler (dtc) will only warn if the "reg" property doesn't match #address-cells and #size-cells size. It won't update the different property. Therefore, Xen needs to check if the size match both properties, otherwise Xen can retrieve a wrong range. Signed-off-by: Julien Grall --- Changes in v3: - Rework comment --- xen/common/device_tree.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/xen/common/device_tree.c b/xen/common/device_tree.c index f867dfd..9d300ec 100644 --- a/xen/common/device_tree.c +++ b/xen/common/device_tree.c @@ -467,10 +467,14 @@ static void __init process_multiboot_node(const void *fdt, int node, mod = &early_info.modules.module[nr]; - prop = fdt_get_property(fdt, node, "reg", NULL); + prop = fdt_get_property(fdt, node, "reg", &len); if ( !prop ) early_panic("node %s missing `reg' property\n", name); + if ( len < dt_cells_to_size(address_cells + size_cells) ) + early_panic("fdt: node `%s': `reg` property length is too short\n", + name); + cell = (const u32 *)prop->data; device_tree_get_reg(&cell, address_cells, size_cells, &mod->start, &mod->size);