From patchwork Tue Sep 10 14:48:55 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 19908 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-vb0-f72.google.com (mail-vb0-f72.google.com [209.85.212.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id AD4E9260BE for ; Tue, 10 Sep 2013 14:49:32 +0000 (UTC) Received: by mail-vb0-f72.google.com with SMTP id f12sf8867761vbg.3 for ; Tue, 10 Sep 2013 07:49:32 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=mime-version:x-gm-message-state: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=Du1qDB/A+NGS+iAR3YdEqNjVI9hRRWcPtjFLfXg9v1jFjyrPL6j0BBnvv+SxPAoPwI JPpSG0c5AjZ2rEeBB09qRTBsNLSqysGaXFoFU1pofHnfmtwGgGZmASzk7U6J3VNaWmf+ xNqFC8bHX3QZZrSMie9QDGD8RM/tT8ObaeUUwcIo7uZ3I0Br3iQEqKJFo/0sBl42BFQp nvJ4DP13O68vkAtl06OQR+MLolPb5Pc1bcDxFadMby/oBsoS8TxaXdG9rEnae90Uu1FP O7UZSz50ybOo2XAyNXSg7nvU6rpIPpxgiiwWXMpX7bR2UZ8csDgM8bhUwiHIZ8q0H/vA oH+Q== X-Received: by 10.236.4.69 with SMTP id 45mr8416300yhi.20.1378824572373; Tue, 10 Sep 2013 07:49:32 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.74.35 with SMTP id q3ls2215834qev.50.gmail; Tue, 10 Sep 2013 07:49:32 -0700 (PDT) X-Received: by 10.58.73.202 with SMTP id n10mr23403719vev.7.1378824572123; Tue, 10 Sep 2013 07:49:32 -0700 (PDT) Received: from mail-vc0-f173.google.com (mail-vc0-f173.google.com [209.85.220.173]) by mx.google.com with ESMTPS id tj1si4515700vdc.92.1969.12.31.16.00.00 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 10 Sep 2013 07:49:32 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.220.173 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.220.173; Received: by mail-vc0-f173.google.com with SMTP id id13so4956141vcb.4 for ; Tue, 10 Sep 2013 07:49:32 -0700 (PDT) X-Gm-Message-State: ALoCoQnFSP+Gqnl0r4VZfLQh1lVPtbOXvlPeIxcOvd+pNaITIDj9+iYwUfCdu5qavbBHBeL5WAd+ X-Received: by 10.52.75.165 with SMTP id d5mr19734115vdw.1.1378824572049; Tue, 10 Sep 2013 07:49:32 -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 u4csp4652vcz; Tue, 10 Sep 2013 07:49:31 -0700 (PDT) X-Received: by 10.14.219.198 with SMTP id m46mr13715010eep.41.1378824570297; Tue, 10 Sep 2013 07:49:30 -0700 (PDT) Received: from mail-ea0-f177.google.com (mail-ea0-f177.google.com [209.85.215.177]) by mx.google.com with ESMTPS id l45si15271453eep.334.1969.12.31.16.00.00 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 10 Sep 2013 07:49:30 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.215.177 is neither permitted nor denied by best guess record for domain of julien.grall@linaro.org) client-ip=209.85.215.177; Received: by mail-ea0-f177.google.com with SMTP id f15so3960175eak.36 for ; Tue, 10 Sep 2013 07:49:29 -0700 (PDT) X-Received: by 10.14.223.1 with SMTP id u1mr39829102eep.10.1378824569564; Tue, 10 Sep 2013 07:49:29 -0700 (PDT) Received: from belegaer.uk.xensource.com. ([185.25.64.249]) by mx.google.com with ESMTPSA id i1sm31911644eeg.0.1969.12.31.16.00.00 (version=TLSv1.2 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 10 Sep 2013 07:49:28 -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 v3 07/27] xen/dts: Check "reg" property length in process_multiboot_node Date: Tue, 10 Sep 2013 15:48:55 +0100 Message-Id: <1378824555-16564-8-git-send-email-julien.grall@linaro.org> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1378824555-16564-1-git-send-email-julien.grall@linaro.org> References: <1378824555-16564-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.220.173 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);