From owner-svn-src-stable-10@FreeBSD.ORG Tue Apr 29 00:09:48 2014 Return-Path: Delivered-To: svn-src-stable-10@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id CC722909; Tue, 29 Apr 2014 00:09:48 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id B860E130C; Tue, 29 Apr 2014 00:09:48 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.8/8.14.8) with ESMTP id s3T09muB016882; Tue, 29 Apr 2014 00:09:48 GMT (envelope-from ian@svn.freebsd.org) Received: (from ian@localhost) by svn.freebsd.org (8.14.8/8.14.8/Submit) id s3T09m0J016881; Tue, 29 Apr 2014 00:09:48 GMT (envelope-from ian@svn.freebsd.org) Message-Id: <201404290009.s3T09m0J016881@svn.freebsd.org> From: Ian Lepore Date: Tue, 29 Apr 2014 00:09:48 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r265065 - stable/10/sys/boot/fdt X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-10@freebsd.org X-Mailman-Version: 2.1.17 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 29 Apr 2014 00:09:48 -0000 Author: ian Date: Tue Apr 29 00:09:48 2014 New Revision: 265065 URL: http://svnweb.freebsd.org/changeset/base/265065 Log: MFC r261819 & r262242: Actually validate the header of a loaded dtb file. Modified: stable/10/sys/boot/fdt/fdt_loader_cmd.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/boot/fdt/fdt_loader_cmd.c ============================================================================== --- stable/10/sys/boot/fdt/fdt_loader_cmd.c Mon Apr 28 23:46:04 2014 (r265064) +++ stable/10/sys/boot/fdt/fdt_loader_cmd.c Tue Apr 29 00:09:48 2014 (r265065) @@ -227,10 +227,15 @@ fdt_load_dtb(vm_offset_t va) static int fdt_load_dtb_addr(struct fdt_header *header) { + int err; - // TODO: Verify that there really is an FDT at - // the specified location. fdtp_size = fdt_totalsize(header); + err = fdt_check_header(header); + if (err < 0) { + sprintf(command_errbuf, "error validating blob: %s", + fdt_strerror(err)); + return (err); + } free(fdtp); if ((fdtp = malloc(fdtp_size)) == NULL) { command_errmsg = "can't allocate memory for device tree copy"; @@ -662,7 +667,7 @@ fdt_fixup(void) { const char *env; char *ethstr; - int chosen, err, eth_no, len; + int chosen, eth_no, len; struct sys_info *si; env = NULL; @@ -670,13 +675,8 @@ fdt_fixup(void) ethstr = NULL; len = 0; - if (fdtp == NULL) { - err = fdt_setup_fdtp(); - if (err) { - sprintf(command_errbuf, "No valid device tree blob found!"); - return (0); - } - } + if (fdtp == NULL && fdt_setup_fdtp() != 0) + return (0); /* Create /chosen node (if not exists) */ if ((chosen = fdt_subnode_offset(fdtp, 0, "chosen")) == @@ -742,7 +742,7 @@ fdt_copy(vm_offset_t va) if (fdtp == NULL) { err = fdt_setup_fdtp(); if (err) { - printf("No valid device tree blob found!"); + printf("No valid device tree blob found!\n"); return (0); } }