From owner-svn-src-all@freebsd.org Thu Mar 19 17:27:09 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 730262656CF; Thu, 19 Mar 2020 17:27:09 +0000 (UTC) (envelope-from tsoome@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 48jv3d0tQJz4CKH; Thu, 19 Mar 2020 17:27:09 +0000 (UTC) (envelope-from tsoome@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id D2552E6CE; Thu, 19 Mar 2020 17:27:08 +0000 (UTC) (envelope-from tsoome@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 02JHR88N048986; Thu, 19 Mar 2020 17:27:08 GMT (envelope-from tsoome@FreeBSD.org) Received: (from tsoome@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 02JHR8gd048985; Thu, 19 Mar 2020 17:27:08 GMT (envelope-from tsoome@FreeBSD.org) Message-Id: <202003191727.02JHR8gd048985@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: tsoome set sender to tsoome@FreeBSD.org using -f From: Toomas Soome Date: Thu, 19 Mar 2020 17:27:08 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r359147 - head/stand/common X-SVN-Group: head X-SVN-Commit-Author: tsoome X-SVN-Commit-Paths: head/stand/common X-SVN-Commit-Revision: 359147 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 19 Mar 2020 17:27:09 -0000 Author: tsoome Date: Thu Mar 19 17:27:08 2020 New Revision: 359147 URL: https://svnweb.freebsd.org/changeset/base/359147 Log: loader: misaligned access of dos_partition structure armv7 crash due to misligned access of dos_partition dp_start field. Allocate and make copy of dos_partition array to make sure the data is aligned. Reported by: marklmi at yahoo.com Modified: head/stand/common/part.c Modified: head/stand/common/part.c ============================================================================== --- head/stand/common/part.c Thu Mar 19 17:20:50 2020 (r359146) +++ head/stand/common/part.c Thu Mar 19 17:27:08 2020 (r359147) @@ -654,6 +654,7 @@ ptable_open(void *dev, uint64_t sectors, uint16_t sect int has_ext; #endif table = NULL; + dp = NULL; buf = malloc(sectorsize); if (buf == NULL) return (NULL); @@ -708,7 +709,11 @@ ptable_open(void *dev, uint64_t sectors, uint16_t sect goto out; } /* Check that we have PMBR. Also do some validation. */ - dp = (struct dos_partition *)(buf + DOSPARTOFF); + dp = malloc(NDOSPART * sizeof(struct dos_partition)); + if (dp == NULL) + goto out; + bcopy(buf + DOSPARTOFF, dp, NDOSPART * sizeof(struct dos_partition)); + /* * In mac we can have PMBR partition in hybrid MBR; * that is, MBR partition which has DOSPTYP_PMBR entry defined as @@ -770,6 +775,7 @@ ptable_open(void *dev, uint64_t sectors, uint16_t sect #endif /* LOADER_MBR_SUPPORT */ #endif /* LOADER_MBR_SUPPORT || LOADER_GPT_SUPPORT */ out: + free(dp); free(buf); return (table); }