From nobody Mon Nov 29 17:54:08 2021 X-Original-To: dev-commits-src-main@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 7359118B6274; Mon, 29 Nov 2021 17:54:09 +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 4J2tJd1PV2z4crS; Mon, 29 Nov 2021 17:54:09 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 06FDA26F11; Mon, 29 Nov 2021 17:54:09 +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 1ATHs8E5040511; Mon, 29 Nov 2021 17:54:08 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1ATHs804040510; Mon, 29 Nov 2021 17:54:08 GMT (envelope-from git) Date: Mon, 29 Nov 2021 17:54:08 GMT Message-Id: <202111291754.1ATHs804040510@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Neel Chauhan Subject: git: 3dd3a395ba97 - main - ext2: Check for e2fs_first_dblock in ext2_compute_sb_data() List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: nc X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 3dd3a395ba975d0fbe13320e6e69fb85b037da5e Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1638208449; 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=6XupuY9b6Ww3jO9cVvR1QnzQAd0Sx0hMfbQdaZai/pw=; b=ZY4tk84cxxZ1n05AObWb5cNo0qAraG53/x5DE+4Az5WrPYOae14WZ7ubglfCmURJf2IH0R FNIuFWwM0CRMrTepKk6aQtT8JWJwt1utHFYgv1FrY/SP4tV2DSyhQW0H2LR54w5gVc3oe4 dbYxBktbRYP9j2WvbiwvrqU7dKgo8kURa9e839R3tiPWKpxwjzlVifk/qukfq845g65xXQ xs2YCWPaGOWR6y/U05b8nWrhqtPeKoq0pOmKy8u8c82DiHTjxkAOWjL14M6YaAxjacO+eG 6rVfuliSYRpgECng861ZYhpd7STMFpRr4LBEGf/xpkFG4rpN1ug1nyfFElWIfg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1638208449; a=rsa-sha256; cv=none; b=tOs+dxh8KXHHMAgkSyuU43oYBo+sEBxzbHWiRAYhHkouKBIqg/hO4CPA3u+sTAwpc0s/1n p132hts61dFGO0KVemc5omvpAy+28i/pkKAtKU3SC5TnNalu6+NSmxvJJxWY2a4HKRmaph /MlQKh/KaGA4r6NlbhmTtREaM5n8/gW7ZwidGjYW7rG6qau6T9wF4ehGL8Wu2sU0yteCna th4d+XkwzOoxOul8r/Shxn8Xjjo+cNmT1Lknmy9uKzhbpl8BM+5onyhnStvqwCkO67R3tY Rr0ZAZqDVtqSRqpjDdy1pIsbDo2UXk3B7/eqNAFtNM4t8wNtwZXcjP067uaWRQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by nc (ports committer): URL: https://cgit.FreeBSD.org/src/commit/?id=3dd3a395ba975d0fbe13320e6e69fb85b037da5e commit 3dd3a395ba975d0fbe13320e6e69fb85b037da5e Author: Neel Chauhan AuthorDate: 2021-11-16 22:59:26 +0000 Commit: Neel Chauhan CommitDate: 2021-11-29 17:53:45 +0000 ext2: Check for e2fs_first_dblock in ext2_compute_sb_data() This prevents a kernel panic on a damaged ext2 superblock. PR: 259107 Reported by: Robert Morris Differential Revision: https://reviews.freebsd.org/D33029 --- sys/fs/ext2fs/ext2_vfsops.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/sys/fs/ext2fs/ext2_vfsops.c b/sys/fs/ext2fs/ext2_vfsops.c index 65f429949f55..0ab0327ae074 100644 --- a/sys/fs/ext2fs/ext2_vfsops.c +++ b/sys/fs/ext2fs/ext2_vfsops.c @@ -465,6 +465,13 @@ ext2_compute_sb_data(struct vnode *devvp, struct ext2fs *es, int g_count = 0; int error; + /* Check if first dblock is valid */ + if (fs->e2fs->e2fs_bcount >= 1024 && fs->e2fs->e2fs_first_dblock) { + SDT_PROBE1(ext2fs, , vfsops, ext2_compute_sb_data_error, + "first dblock is invalid"); + return (EINVAL); + } + /* Check checksum features */ if (EXT2_HAS_RO_COMPAT_FEATURE(fs, EXT2F_ROCOMPAT_GDT_CSUM) && EXT2_HAS_RO_COMPAT_FEATURE(fs, EXT2F_ROCOMPAT_METADATA_CKSUM)) { @@ -611,7 +618,8 @@ ext2_compute_sb_data(struct vnode *devvp, struct ext2fs *es, return (EINVAL); } - if (le32toh(es->e2fs_first_dblock) >= fs->e2fs_bcount) { + if (le32toh(es->e2fs_first_dblock) != (fs->e2fs_bsize > 1024 ? 0 : 1) || + le32toh(es->e2fs_first_dblock) >= fs->e2fs_bcount) { SDT_PROBE1(ext2fs, , vfsops, ext2_compute_sb_data_error, "first data block out of range"); return (EINVAL);