From: Lukas Czerner <lczerner@redhat.com>
To: linux-ext4@vger.kernel.org
Subject: [PATCH v2 2/2] tune2fs: Warn if page size != blocksize when enabling encrypt
Date: Thu, 22 Aug 2019 14:17:25 +0200 [thread overview]
Message-ID: <20190822121725.22550-1-lczerner@redhat.com> (raw)
In-Reply-To: <20190821131813.9456-2-lczerner@redhat.com>
With encrypt feature enabled the file system block size must match
system page size. Currently tune2fs will not complain at all when we try
to enable encrypt on a file system that does not satisfy this
requirement for the system. Add a warning for this case.
Signed-off-by: Lukas Czerner <lczerner@redhat.com>
---
misc/tune2fs.c | 39 +++++++++++++++++++++++++++++++++++++++
1 file changed, 39 insertions(+)
diff --git a/misc/tune2fs.c b/misc/tune2fs.c
index 7d2d38d7..f1604447 100644
--- a/misc/tune2fs.c
+++ b/misc/tune2fs.c
@@ -130,6 +130,8 @@ void do_findfs(int argc, char **argv);
int journal_enable_debug = -1;
#endif
+static int sys_page_size = 4096;
+
static void usage(void)
{
fprintf(stderr,
@@ -1407,6 +1409,30 @@ mmp_error:
stderr);
return 1;
}
+
+ /*
+ * When encrypt feature is enabled, the file system blocksize
+ * needs to match system page size otherwise the file system
+ * won't mount.
+ */
+ if (fs->blocksize != sys_page_size) {
+ if (!f_flag) {
+ com_err(program_name, 0,
+ _("Encryption feature requested, but "
+ "block size (%dB) does not match "
+ "system page size (%dB). File "
+ "system won't be usable on this "
+ "system"),
+ fs->blocksize, sys_page_size);
+ proceed_question(-1);
+ }
+ fprintf(stderr,_("Warning: Encrypt feature enabled, "
+ "but block size (%dB) does not match "
+ "system page size (%dB), forced to "
+ "cointinue\n"),
+ fs->blocksize, sys_page_size);
+ }
+
fs->super->s_encrypt_algos[0] =
EXT4_ENCRYPTION_MODE_AES_256_XTS;
fs->super->s_encrypt_algos[1] =
@@ -2844,6 +2870,7 @@ int main(int argc, char **argv)
int tune2fs_main(int argc, char **argv)
#endif /* BUILD_AS_LIB */
{
+ long sysval;
errcode_t retval;
ext2_filsys fs;
struct ext2_super_block *sb;
@@ -2879,6 +2906,18 @@ int tune2fs_main(int argc, char **argv)
#endif
io_ptr = unix_io_manager;
+ /* Determine the system page size if possible */
+#ifdef HAVE_SYSCONF
+#if (!defined(_SC_PAGESIZE) && defined(_SC_PAGE_SIZE))
+#define _SC_PAGESIZE _SC_PAGE_SIZE
+#endif
+#ifdef _SC_PAGESIZE
+ sysval = sysconf(_SC_PAGESIZE);
+ if (sysval > 0)
+ sys_page_size = sysval;
+#endif /* _SC_PAGESIZE */
+#endif /* HAVE_SYSCONF */
+
retry_open:
if ((open_flag & EXT2_FLAG_RW) == 0 || f_flag)
open_flag |= EXT2_FLAG_SKIP_MMP;
--
2.21.0
next prev parent reply other threads:[~2019-08-22 12:17 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-08-21 13:18 [PATCH 1/2] mke2fs: Warn if page size != blocksize when ecnrypt is enabled Lukas Czerner
2019-08-21 13:18 ` [PATCH 2/2] tune2fs: Warn if page size != blocksize when enabling encrypt Lukas Czerner
2019-08-21 15:17 ` Eric Sandeen
2019-08-22 9:48 ` Lukas Czerner
2019-08-22 12:17 ` Lukas Czerner [this message]
2019-10-03 13:48 ` [PATCH v2 " Eric Sandeen
2019-08-21 15:19 ` [PATCH 1/2] mke2fs: Warn if page size != blocksize when ecnrypt is enabled Eric Sandeen
2019-10-03 12:51 ` Lukas Czerner
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=20190822121725.22550-1-lczerner@redhat.com \
--to=lczerner@redhat.com \
--cc=linux-ext4@vger.kernel.org \
/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).