linux-ext4.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Theodore Ts'o <tytso@mit.edu>
To: Ext4 Developers List <linux-ext4@vger.kernel.org>
Cc: tony@bakeyournoodle.com, Theodore Ts'o <tytso@mit.edu>
Subject: [PATCH 7/7] libext2fs: enforce the block group descriptor size in ext2fs_open()
Date: Mon, 30 Jul 2012 17:47:42 -0400	[thread overview]
Message-ID: <1343684862-13181-7-git-send-email-tytso@mit.edu> (raw)
In-Reply-To: <1343684862-13181-1-git-send-email-tytso@mit.edu>

Since various parts of the library depend on the value of s_desc_size,
check to make sure it is the correct, expected value based on the file
system features.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
---
 lib/ext2fs/ext2_err.et.in |  3 +++
 lib/ext2fs/openfs.c       | 15 +++++++++++++++
 2 files changed, 18 insertions(+)

diff --git a/lib/ext2fs/ext2_err.et.in b/lib/ext2fs/ext2_err.et.in
index ccf1894..5987185 100644
--- a/lib/ext2fs/ext2_err.et.in
+++ b/lib/ext2fs/ext2_err.et.in
@@ -443,4 +443,7 @@ ec	EXT2_ET_MMP_CHANGE_ABORT,
 ec	EXT2_ET_MMP_OPEN_DIRECT,
 	"MMP: open with O_DIRECT failed"
 
+ec	EXT2_ET_BAD_DESC_SIZE,
+	"Block group descriptor size incorrect"
+
 	end
diff --git a/lib/ext2fs/openfs.c b/lib/ext2fs/openfs.c
index 482e4ab..fbe9acd 100644
--- a/lib/ext2fs/openfs.c
+++ b/lib/ext2fs/openfs.c
@@ -263,6 +263,21 @@ errcode_t ext2fs_open2(const char *name, const char *io_options,
 		retval = EXT2_ET_CORRUPT_SUPERBLOCK;
 		goto cleanup;
 	}
+
+	/* Enforce the block group descriptor size */
+	if (fs->super->s_feature_incompat & EXT4_FEATURE_INCOMPAT_64BIT) {
+		if (fs->super->s_desc_size != EXT2_MIN_DESC_SIZE_64BIT) {
+			retval = EXT2_ET_BAD_DESC_SIZE;
+			goto cleanup;
+		}
+	} else {
+		if (fs->super->s_desc_size &&
+		    fs->super->s_desc_size != EXT2_MIN_DESC_SIZE) {
+			retval = EXT2_ET_BAD_DESC_SIZE;
+			goto cleanup;
+		}
+	}
+
 	fs->cluster_ratio_bits = fs->super->s_log_cluster_size -
 		fs->super->s_log_block_size;
 	if (EXT2_BLOCKS_PER_GROUP(fs->super) !=
-- 
1.7.12.rc0.22.gcdd159b


  parent reply	other threads:[~2012-07-30 21:55 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-06-15  4:24 Minimal configuration for e2fsprogs Tony Breeds
2012-06-16  0:08 ` Ted Ts'o
2012-06-18  5:58   ` Tony Breeds
2012-06-18 17:12     ` Ted Ts'o
2012-06-19  5:48       ` Tony Breeds
2012-06-19  6:01         ` Andreas Dilger
2012-06-19 13:56           ` Ted Ts'o
2012-06-20  5:26             ` Tony Breeds
2012-06-20  5:33               ` Tony Breeds
2012-06-20 14:14               ` Andreas Dilger
2012-06-20  4:45           ` Tony Breeds
2012-06-26  2:10       ` Tony Breeds
2012-06-26  2:33         ` Theodore Ts'o
2012-06-26  2:47           ` Tony Breeds
2012-06-27 11:21 ` Tony Breeds
2012-06-27 12:54   ` Theodore Ts'o
2012-06-28  2:43     ` Tony Breeds
2012-07-30 21:45       ` Theodore Ts'o
2012-07-31  5:21         ` Tony Breeds
2012-07-31 19:57           ` Theodore Ts'o
2012-08-01  5:42             ` Tony Breeds
2012-07-30 21:47       ` [PATCH 1/7] e2fsck: add SIGABRT to list of signals processed by sigcatcher Theodore Ts'o
2012-07-30 21:47         ` [PATCH 2/7] libext2fs: use abort() instead of perror()/exit() Theodore Ts'o
2012-07-31 18:34           ` Andreas Dilger
2012-07-31 20:04             ` Theodore Ts'o
2012-07-30 21:47         ` [PATCH 3/7] libext2fs: use strcpy()/strcat() instead of sprintf() in bmap functions Theodore Ts'o
2012-07-30 21:47         ` [PATCH 4/7] libext2fs: move ext2fs_get_num_dirs to its own file Theodore Ts'o
2012-07-30 21:47         ` [PATCH 5/7] libext2fs: call numeric_progress functions through a operations struct Theodore Ts'o
2012-07-30 21:47         ` [PATCH 6/7] libext2fs: remove debugging printf from ext2fs_group_desc_csum Theodore Ts'o
2012-07-30 21:47         ` Theodore Ts'o [this message]
2012-07-31 18:38           ` [PATCH 7/7] libext2fs: enforce the block group descriptor size in ext2fs_open() Andreas Dilger
2012-07-31 20:09             ` Theodore Ts'o
2012-08-01 20:45               ` Andreas Dilger
2012-08-03  0:00                 ` Theodore Ts'o

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1343684862-13181-7-git-send-email-tytso@mit.edu \
    --to=tytso@mit.edu \
    --cc=linux-ext4@vger.kernel.org \
    --cc=tony@bakeyournoodle.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).