From owner-svn-src-head@freebsd.org Thu Jan 12 06:58:33 2017 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 33E02CAC69B; Thu, 12 Jan 2017 06:58:33 +0000 (UTC) (envelope-from cem@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 mx1.freebsd.org (Postfix) with ESMTPS id D06441658; Thu, 12 Jan 2017 06:58:32 +0000 (UTC) (envelope-from cem@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v0C6wWig010967; Thu, 12 Jan 2017 06:58:32 GMT (envelope-from cem@FreeBSD.org) Received: (from cem@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v0C6wVrU010965; Thu, 12 Jan 2017 06:58:31 GMT (envelope-from cem@FreeBSD.org) Message-Id: <201701120658.v0C6wVrU010965@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: cem set sender to cem@FreeBSD.org using -f From: "Conrad E. Meyer" Date: Thu, 12 Jan 2017 06:58:31 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r311964 - head/sys/geom/raid X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 12 Jan 2017 06:58:33 -0000 Author: cem Date: Thu Jan 12 06:58:31 2017 New Revision: 311964 URL: https://svnweb.freebsd.org/changeset/base/311964 Log: g_raid: Prevent tasters from attempting excessively large reads Some g_raid tasters attempt metadata reads in multiples of the provider sectorsize. Reads larger than MAXPHYS are invalid, so detect and abort in such situations. Spiritually similar to r217305 / PR 147851. PR: 214721 Sponsored by: Dell EMC Isilon Modified: head/sys/geom/raid/md_ddf.c head/sys/geom/raid/md_promise.c Modified: head/sys/geom/raid/md_ddf.c ============================================================================== --- head/sys/geom/raid/md_ddf.c Thu Jan 12 06:38:03 2017 (r311963) +++ head/sys/geom/raid/md_ddf.c Thu Jan 12 06:58:31 2017 (r311964) @@ -1161,6 +1161,16 @@ hdrerror: (GET16(meta, hdr->Configuration_Record_Length) * ss - 512) / 12)); } + if (GET32(meta, hdr->cd_length) * ss >= MAXPHYS || + GET32(meta, hdr->pdr_length) * ss >= MAXPHYS || + GET32(meta, hdr->vdr_length) * ss >= MAXPHYS || + GET32(meta, hdr->cr_length) * ss >= MAXPHYS || + GET32(meta, hdr->pdd_length) * ss >= MAXPHYS || + GET32(meta, hdr->bbmlog_length) * ss >= MAXPHYS) { + G_RAID_DEBUG(1, "%s: Blocksize is too big.", pp->name); + goto hdrerror; + } + /* Read controller data. */ buf = g_read_data(cp, (lba + GET32(meta, hdr->cd_section)) * ss, GET32(meta, hdr->cd_length) * ss, &error); Modified: head/sys/geom/raid/md_promise.c ============================================================================== --- head/sys/geom/raid/md_promise.c Thu Jan 12 06:38:03 2017 (r311963) +++ head/sys/geom/raid/md_promise.c Thu Jan 12 06:58:31 2017 (r311964) @@ -341,6 +341,11 @@ promise_meta_read(struct g_consumer *cp, pp = cp->provider; subdisks = 0; + + if (pp->sectorsize * 4 > MAXPHYS) { + G_RAID_DEBUG(1, "%s: Blocksize is too big.", pp->name); + return (subdisks); + } next: /* Read metadata block. */ buf = g_read_data(cp, pp->mediasize - pp->sectorsize *