From nobody Sat Jan 15 00:51:42 2022 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 67A5A19510FC; Sat, 15 Jan 2022 00:51:43 +0000 (UTC) (envelope-from git@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) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4JbKPB5hF9z4kDT; Sat, 15 Jan 2022 00:51:42 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1642207903; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=x7RbWjGAOESaDG7H+bQS36w40ZZsmMbkIUd+Pg3ttEg=; b=H3n1D/dnnNvydqEkhv44o6EZbSihS5+gXNB6s/frilD76xaUAJNc8pkjGD7PtyMZP0exWl Pkh/9X5sld5Ub6nRCjaqyBq7Us3HNhWMGK3yv8e3s14rgT2us87LJW6dRvmBH+qI8FFgMu 4hF8dJggI9ru4MgGclWJtDxrnraTMjfp6DFiAhyL2ggBj8p8fWG8+9vSZ94SHQHRMrfH8+ E8A7VKm5vJb5td0xNC6RGTAwGJb6KWQ1KuSylT55ofIjdfyl/1MAz6X0LIWYpVu066WggY ZknQXSga1/xzAwUBySrycZdY5RNC+u5aYcvXns2UJkFErJF4bQTgC3jfgfqhug== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4E12B1DF8C; Sat, 15 Jan 2022 00:51:42 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 20F0pgpW031224; Sat, 15 Jan 2022 00:51:42 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 20F0pgZR031223; Sat, 15 Jan 2022 00:51:42 GMT (envelope-from git) Date: Sat, 15 Jan 2022 00:51:42 GMT Message-Id: <202201150051.20F0pgZR031223@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Konstantin Belousov Subject: git: c5c1537dc7ff - stable/13 - msdosfs: sanity check sector count from BPB List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: c5c1537dc7ffd27066d035b8e236d3dcb548a3c8 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1642207903; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=x7RbWjGAOESaDG7H+bQS36w40ZZsmMbkIUd+Pg3ttEg=; b=LfHRKLzppspx3MDq83mKe7HNDi6wupehkzOjkQoD8t1Ip+b1dM9IQlJs9RFsDRZd1B0GcF if4IsQDf1qvjgfiqWzPN7uPUaCOI1byZwJ3GwSDJZebMeWlBD+IaxkO3muU18gX4NMAbPR kKwuKr4yeJVWB/RYzrydaT1uZo0QIbxpvL8HE/Y4smvkBldURTX9z5IPyC0EiNimV7oSSn DJvaNU7jgrNO4+tTMInrHbCCw2edcJFM/iUemnVNZAK+CKem/fmVmnAG+1c6z9kdcLTHAv MC+YLvUGdQgRhrq5j/YDalFsSn3iDqiNlRuFP83yJiqk2y7XyOLYr3bU4tBcBw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1642207903; a=rsa-sha256; cv=none; b=omtaF4xAifKp7ORpOQ05sMaVnNW+2uFsibjnCi3ozJszqj3M7k+5fKrqPOK5WGQIaOcIML xu2tXLiXJAmJZx5Q1n1dF0Z3suSKrCyUC0iLRVAd0ys4NSSKgOuabYtGpITY6DMalhvNM3 4SdMKGS+QTJuJcej7cSHM9FoMAFJrWSjUqDmMP2ZzQn8NqP9P31C3sgzY8bpjeKKd6n3ol foPAKtnAxipS+zwO+39XSkQW5R7lRpgyIK5iwCfNewnTek2IdOL23zexe3X7EzqJ/Bi4KK 62vXWBKknzFRUobaUHiTAkwskm17B/6oyRTytiCl/0SyI6ffapH4KU6RpSptyw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=c5c1537dc7ffd27066d035b8e236d3dcb548a3c8 commit c5c1537dc7ffd27066d035b8e236d3dcb548a3c8 Author: Konstantin Belousov AuthorDate: 2021-12-30 19:45:40 +0000 Commit: Konstantin Belousov CommitDate: 2022-01-14 18:11:02 +0000 msdosfs: sanity check sector count from BPB (cherry picked from commit ba2c98389b78b548aedac0be53121df909c3fe2f) --- sys/fs/msdosfs/msdosfs_vfsops.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/sys/fs/msdosfs/msdosfs_vfsops.c b/sys/fs/msdosfs/msdosfs_vfsops.c index 939badf458fb..77942ed88ce4 100644 --- a/sys/fs/msdosfs/msdosfs_vfsops.c +++ b/sys/fs/msdosfs/msdosfs_vfsops.c @@ -558,6 +558,14 @@ mountmsdosfs(struct vnode *devvp, struct mount *mp) } pmp->pm_HugeSectors *= pmp->pm_BlkPerSec; + if ((off_t)pmp->pm_HugeSectors * pmp->pm_BytesPerSec < + pmp->pm_HugeSectors /* overflow */ || + (off_t)pmp->pm_HugeSectors * pmp->pm_BytesPerSec > + cp->provider->mediasize /* past end of vol */) { + error = EINVAL; + goto error_exit; + } + pmp->pm_HiddenSects *= pmp->pm_BlkPerSec; /* XXX not used? */ pmp->pm_FATsecs *= pmp->pm_BlkPerSec; SecPerClust *= pmp->pm_BlkPerSec; @@ -577,6 +585,10 @@ mountmsdosfs(struct vnode *devvp, struct mount *mp) pmp->pm_firstcluster = pmp->pm_rootdirblk + pmp->pm_rootdirsize; } + if (pmp->pm_HugeSectors <= pmp->pm_firstcluster) { + error = EINVAL; + goto error_exit; + } pmp->pm_maxcluster = (pmp->pm_HugeSectors - pmp->pm_firstcluster) / SecPerClust + 1; pmp->pm_fatsize = pmp->pm_FATsecs * DEV_BSIZE; /* XXX not used? */