From nobody Wed Nov 23 21:03:33 2022 X-Original-To: dev-commits-src-all@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 4NHYWT5YB7z4jJVk; Wed, 23 Nov 2022 21:03:33 +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 4NHYWT50xwz3xdX; Wed, 23 Nov 2022 21:03:33 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1669237413; 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=Cjxasf1zDcfwqviDm6LSUhhbODWpcQrHkzt1JcbpejI=; b=bgHinGP3Lq2Jh1M6Z8Pp7DKTjTYDEDd40XhbhPZ81CWVkEjejAGx3YkTDXCzpxwGXP45d7 jeJrgOtp4OLn31lgONA2qV03nuVKlrI7XUjEOf4nj+dA8+X+toNhB6NbCFv3vlinY4Wel3 +SSL5e2MWkPobo+PT+RuFSEIfdSnXQika5AmLVJA/AuQgSuPpBwi5nXEvhMJWUPsXU3H9a lI5CJcD0t3OSQLrlegu5iJXagwb/0qWEWvXOrM9KGA79IJquZLwA7Z31MIBB13ua+3/muM Fhaq+8KdreLsDPahoxFk6nCuX8q3gOUqINSHMRvcnQbLO82UbZO12JfS5Ug8QA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1669237413; 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=Cjxasf1zDcfwqviDm6LSUhhbODWpcQrHkzt1JcbpejI=; b=Dfm3HhwQvSPhr9wD0v6bsoQrBSQ5L7A1pAgWetXlcBYB9g6GXYEe6P0AqBOkiz6GT0iEGY UNiL30BviS+C/CJqMx9eTUcYJiFXPhgOBt4CGX9NZU8NLuiLdPHgWAS5uJzx/aZmcGW4AS NlvlnqQ6KU0w3Ru0RlkUvepPNgLkWklgI4yVlV27lzszXo8r78bZplMZ/B/dn8+eKCswfO ZL9oMy7w3JW+e08+U/KOhLTTRvm6wjfDCAemhYDI8BafhgZuVekYkfCKTPr0YcC0YQ64qS JqCddhx1udkweFYrk8NYE/sg5brGrKbiZXpEzoEzh2lp4V7eb0vkP81wdbPYRw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1669237413; a=rsa-sha256; cv=none; b=Hm3+xYun06GCWojF+dSUNR3cmzHDX5e1mmfp9YXxmJfBGwOk81n7bR+ox4I06AngJIwp6Y MqHmuqMdQombT4iJTRU/sA6th+Ay/RU2cVE6Z8rNc/ZwQkElxr1JFXYsurkZxq6fDzDb61 eT3Bi5KL1z3DMxmWqh4RUwe3spFriatW+LYZVTD8xcWiNcrtBbcqDbupp17VzWNRpPqYfX ys9gW1OP0fjqxmLJlUfyIqT23WcZg2H1np0dxhVbZHxWEP8/UEDvLr1C5Sg9uZGk8Fq8Ih grAM/rYQLH++ohqWWPfbyFUJkI6z+bd2njq02HoFg0BJqYa1K9OVAC0533ogQA== 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 4NHYWT44cmzc0V; Wed, 23 Nov 2022 21:03:33 +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 2ANL3XKd080611; Wed, 23 Nov 2022 21:03:33 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 2ANL3X3U080610; Wed, 23 Nov 2022 21:03:33 GMT (envelope-from git) Date: Wed, 23 Nov 2022 21:03:33 GMT Message-Id: <202211232103.2ANL3X3U080610@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Alan Somers Subject: git: 0e86854450b4 - stable/13 - Don't panic when tasting a disk with sectorsize=0 List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: asomers X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 0e86854450b49af5d3f7c85656d6874a3851dcb0 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by asomers: URL: https://cgit.FreeBSD.org/src/commit/?id=0e86854450b49af5d3f7c85656d6874a3851dcb0 commit 0e86854450b49af5d3f7c85656d6874a3851dcb0 Author: Alan Somers AuthorDate: 2022-11-09 02:59:50 +0000 Commit: Alan Somers CommitDate: 2022-11-23 20:57:47 +0000 Don't panic when tasting a disk with sectorsize=0 This can sometimes happen with broken HDDs. Sponsored by: Axcient Reviewed by: markj Differential Revision: https://reviews.freebsd.org/D37313 (cherry picked from commit 05d0f4308caaa3e9b8cbcbb30b2d7f39dd367a57) --- sys/geom/label/g_label.c | 4 ++++ sys/geom/label/g_label_ext2fs.c | 5 +++-- sys/geom/label/g_label_iso9660.c | 5 +++-- sys/geom/label/g_label_reiserfs.c | 5 +++-- sys/geom/label/g_label_ufs.c | 1 + 5 files changed, 14 insertions(+), 6 deletions(-) diff --git a/sys/geom/label/g_label.c b/sys/geom/label/g_label.c index 2244931cd19b..8f6ac38179a6 100644 --- a/sys/geom/label/g_label.c +++ b/sys/geom/label/g_label.c @@ -394,6 +394,10 @@ g_label_taste(struct g_class *mp, struct g_provider *pp, int flags __unused) if (pp->acw > 0) return (NULL); + /* Skip broken disks that don't set their sector size */ + if (pp->sectorsize == 0) + return (NULL); + if (strcmp(pp->geom->class->name, mp->name) == 0) return (NULL); diff --git a/sys/geom/label/g_label_ext2fs.c b/sys/geom/label/g_label_ext2fs.c index 3420efb7ca3a..0f21de1ce313 100644 --- a/sys/geom/label/g_label_ext2fs.c +++ b/sys/geom/label/g_label_ext2fs.c @@ -62,10 +62,11 @@ g_label_ext2fs_taste(struct g_consumer *cp, char *label, size_t size) pp = cp->provider; label[0] = '\0'; - if ((EXT2FS_SB_OFFSET % pp->sectorsize) != 0) - return; + KASSERT(pp->sectorsize != 0, ("Tasting a disk with 0 sectorsize")); if (pp->sectorsize < sizeof(*fs)) return; + if ((EXT2FS_SB_OFFSET % pp->sectorsize) != 0) + return; fs = g_read_data(cp, EXT2FS_SB_OFFSET, pp->sectorsize, NULL); if (fs == NULL) diff --git a/sys/geom/label/g_label_iso9660.c b/sys/geom/label/g_label_iso9660.c index b46a47bbd36a..1ac7283b34e6 100644 --- a/sys/geom/label/g_label_iso9660.c +++ b/sys/geom/label/g_label_iso9660.c @@ -52,10 +52,11 @@ g_label_iso9660_taste(struct g_consumer *cp, char *label, size_t size) pp = cp->provider; label[0] = '\0'; - if ((ISO9660_OFFSET % pp->sectorsize) != 0) - return; + KASSERT(pp->sectorsize != 0, ("Tasting a disk with 0 sectorsize")); if (pp->sectorsize < 0x28 + VOLUME_LEN) return; + if ((ISO9660_OFFSET % pp->sectorsize) != 0) + return; sector = g_read_data(cp, ISO9660_OFFSET, pp->sectorsize, NULL); if (sector == NULL) return; diff --git a/sys/geom/label/g_label_reiserfs.c b/sys/geom/label/g_label_reiserfs.c index d6f9a0428b6a..8fe1a72458e4 100644 --- a/sys/geom/label/g_label_reiserfs.c +++ b/sys/geom/label/g_label_reiserfs.c @@ -59,10 +59,11 @@ g_label_reiserfs_read_super(struct g_consumer *cp, off_t offset) secsize = cp->provider->sectorsize; - if ((offset % secsize) != 0) - return (NULL); + KASSERT(secsize != 0, ("Tasting a disk with 0 sectorsize")); if (secsize < sizeof(*fs)) return (NULL); + if ((offset % secsize) != 0) + return (NULL); fs = g_read_data(cp, offset, secsize, NULL); if (fs == NULL) diff --git a/sys/geom/label/g_label_ufs.c b/sys/geom/label/g_label_ufs.c index ababbaa4b43a..8b2776e034fe 100644 --- a/sys/geom/label/g_label_ufs.c +++ b/sys/geom/label/g_label_ufs.c @@ -74,6 +74,7 @@ g_label_ufs_taste_common(struct g_consumer *cp, char *label, size_t size, int wh label[0] = '\0'; fs = NULL; + KASSERT(pp->sectorsize != 0, ("Tasting a disk with 0 sectorsize")); if (SBLOCKSIZE % pp->sectorsize != 0 || ffs_sbget(cp, &fs, STDSB_NOHASHFAIL, M_GEOM, g_use_g_read_data) != 0) { KASSERT(fs == NULL,