linux-ext4.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] mke2fs: Warn if page size != blocksize when ecnrypt is enabled
@ 2019-08-21 13:18 Lukas Czerner
  2019-08-21 13:18 ` [PATCH 2/2] tune2fs: Warn if page size != blocksize when enabling encrypt Lukas Czerner
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Lukas Czerner @ 2019-08-21 13:18 UTC (permalink / raw)
  To: linux-ext4

With encrypt feature enabled the file system block size must match
system page size. Currently mke2fs will not complain at all when we try
to create 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/mke2fs.c | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/misc/mke2fs.c b/misc/mke2fs.c
index d7cf257e..aa9590d8 100644
--- a/misc/mke2fs.c
+++ b/misc/mke2fs.c
@@ -2468,6 +2468,26 @@ profile_error:
 		      exit (1);
 	}
 
+	/*
+	 * Encrypt feature requires blocksize to be the same as page size,
+	 * otherwise file system won't mount
+	 */
+	if (ext2fs_has_feature_encrypt(&fs_param) &&
+	   (blocksize != sys_page_size)) {
+		if (!force) {
+			com_err(program_name, 0,
+				_("Encrypt feature is enabled, but block size "
+				  "(%dB) does not match system page size "
+				  "(%dB)"),
+				blocksize, sys_page_size);
+			proceed_question(proceed_delay);
+		}
+		fprintf(stderr,_("Warning: Encrypt feature enabled, but block "
+				 "size (%dB) does not match system page size "
+				 "(%dB), forced to continue\n"),
+			blocksize, sys_page_size);
+	}
+
 	/* Don't allow user to set both metadata_csum and uninit_bg bits. */
 	if (ext2fs_has_feature_metadata_csum(&fs_param) &&
 	    ext2fs_has_feature_gdt_csum(&fs_param))
-- 
2.21.0


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 2/2] tune2fs: Warn if page size != blocksize when enabling encrypt
  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 ` Lukas Czerner
  2019-08-21 15:17   ` Eric Sandeen
  2019-08-22 12:17   ` [PATCH v2 " Lukas Czerner
  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
  2 siblings, 2 replies; 8+ messages in thread
From: Lukas Czerner @ 2019-08-21 13:18 UTC (permalink / raw)
  To: linux-ext4

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 | 38 ++++++++++++++++++++++++++++++++++++++
 1 file changed, 38 insertions(+)

diff --git a/misc/tune2fs.c b/misc/tune2fs.c
index 7d2d38d7..26b1b1d0 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,29 @@ 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,
+					_("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 +2869,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 +2905,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


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH 2/2] tune2fs: Warn if page size != blocksize when enabling encrypt
  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   ` [PATCH v2 " Lukas Czerner
  1 sibling, 1 reply; 8+ messages in thread
From: Eric Sandeen @ 2019-08-21 15:17 UTC (permalink / raw)
  To: Lukas Czerner, linux-ext4



On 8/21/19 8:18 AM, Lukas Czerner wrote:
> 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 | 38 ++++++++++++++++++++++++++++++++++++++
>  1 file changed, 38 insertions(+)
> 
> diff --git a/misc/tune2fs.c b/misc/tune2fs.c
> index 7d2d38d7..26b1b1d0 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,29 @@ 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,
> +					_("Block size (%dB) does not match "
> +					  "system page size (%dB). File "
> +					  "system won't be usable on this "
> +					  "system"),

I wonder if this message should explicitly mention the encryption option, right
now it doesn't give a lot of context as to why this is being printed.

Perhaps "Encryption feature requested, but block size (%dB) does not match ...?"

-Eric

> +					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 +2869,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 +2905,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;
> 

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 1/2] mke2fs: Warn if page size != blocksize when ecnrypt is enabled
  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:19 ` Eric Sandeen
  2019-10-03 12:51 ` Lukas Czerner
  2 siblings, 0 replies; 8+ messages in thread
From: Eric Sandeen @ 2019-08-21 15:19 UTC (permalink / raw)
  To: Lukas Czerner, linux-ext4

On 8/21/19 8:18 AM, Lukas Czerner wrote:
> With encrypt feature enabled the file system block size must match
> system page size. Currently mke2fs will not complain at all when we try
> to create 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>

This matches the warnings we give for block size > system page size, for example,
so this makes sense to me.

Reviewed-by: Eric Sandeen <sandeen@redhat.com>

> ---
>  misc/mke2fs.c | 20 ++++++++++++++++++++
>  1 file changed, 20 insertions(+)
> 
> diff --git a/misc/mke2fs.c b/misc/mke2fs.c
> index d7cf257e..aa9590d8 100644
> --- a/misc/mke2fs.c
> +++ b/misc/mke2fs.c
> @@ -2468,6 +2468,26 @@ profile_error:
>  		      exit (1);
>  	}
>  
> +	/*
> +	 * Encrypt feature requires blocksize to be the same as page size,
> +	 * otherwise file system won't mount
> +	 */
> +	if (ext2fs_has_feature_encrypt(&fs_param) &&
> +	   (blocksize != sys_page_size)) {
> +		if (!force) {
> +			com_err(program_name, 0,
> +				_("Encrypt feature is enabled, but block size "
> +				  "(%dB) does not match system page size "
> +				  "(%dB)"),
> +				blocksize, sys_page_size);
> +			proceed_question(proceed_delay);
> +		}
> +		fprintf(stderr,_("Warning: Encrypt feature enabled, but block "
> +				 "size (%dB) does not match system page size "
> +				 "(%dB), forced to continue\n"),
> +			blocksize, sys_page_size);
> +	}
> +
>  	/* Don't allow user to set both metadata_csum and uninit_bg bits. */
>  	if (ext2fs_has_feature_metadata_csum(&fs_param) &&
>  	    ext2fs_has_feature_gdt_csum(&fs_param))
> 

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 2/2] tune2fs: Warn if page size != blocksize when enabling encrypt
  2019-08-21 15:17   ` Eric Sandeen
@ 2019-08-22  9:48     ` Lukas Czerner
  0 siblings, 0 replies; 8+ messages in thread
From: Lukas Czerner @ 2019-08-22  9:48 UTC (permalink / raw)
  To: sandeen; +Cc: linux-ext4

On Wed, Aug 21, 2019 at 10:17:09AM -0500, Eric Sandeen wrote:
> 
> 
> On 8/21/19 8:18 AM, Lukas Czerner wrote:
> > 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 | 38 ++++++++++++++++++++++++++++++++++++++
> >  1 file changed, 38 insertions(+)
> > 
> > diff --git a/misc/tune2fs.c b/misc/tune2fs.c
> > index 7d2d38d7..26b1b1d0 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,29 @@ 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,
> > +					_("Block size (%dB) does not match "
> > +					  "system page size (%dB). File "
> > +					  "system won't be usable on this "
> > +					  "system"),
> 
> I wonder if this message should explicitly mention the encryption option, right
> now it doesn't give a lot of context as to why this is being printed.

Ah right, I suppose people can change more things at once. I'll get it
fixed.

Thanks!
-Lukas

> 
> Perhaps "Encryption feature requested, but block size (%dB) does not match ...?"
> 
> -Eric
> 
> > +					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 +2869,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 +2905,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;
> > 

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH v2 2/2] tune2fs: Warn if page size != blocksize when enabling encrypt
  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 12:17   ` Lukas Czerner
  2019-10-03 13:48     ` Eric Sandeen
  1 sibling, 1 reply; 8+ messages in thread
From: Lukas Czerner @ 2019-08-22 12:17 UTC (permalink / raw)
  To: linux-ext4

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


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH 1/2] mke2fs: Warn if page size != blocksize when ecnrypt is enabled
  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:19 ` [PATCH 1/2] mke2fs: Warn if page size != blocksize when ecnrypt is enabled Eric Sandeen
@ 2019-10-03 12:51 ` Lukas Czerner
  2 siblings, 0 replies; 8+ messages in thread
From: Lukas Czerner @ 2019-10-03 12:51 UTC (permalink / raw)
  To: linux-ext4

ping

On Wed, Aug 21, 2019 at 03:18:12PM +0200, Lukas Czerner wrote:
> With encrypt feature enabled the file system block size must match
> system page size. Currently mke2fs will not complain at all when we try
> to create 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/mke2fs.c | 20 ++++++++++++++++++++
>  1 file changed, 20 insertions(+)
> 
> diff --git a/misc/mke2fs.c b/misc/mke2fs.c
> index d7cf257e..aa9590d8 100644
> --- a/misc/mke2fs.c
> +++ b/misc/mke2fs.c
> @@ -2468,6 +2468,26 @@ profile_error:
>  		      exit (1);
>  	}
>  
> +	/*
> +	 * Encrypt feature requires blocksize to be the same as page size,
> +	 * otherwise file system won't mount
> +	 */
> +	if (ext2fs_has_feature_encrypt(&fs_param) &&
> +	   (blocksize != sys_page_size)) {
> +		if (!force) {
> +			com_err(program_name, 0,
> +				_("Encrypt feature is enabled, but block size "
> +				  "(%dB) does not match system page size "
> +				  "(%dB)"),
> +				blocksize, sys_page_size);
> +			proceed_question(proceed_delay);
> +		}
> +		fprintf(stderr,_("Warning: Encrypt feature enabled, but block "
> +				 "size (%dB) does not match system page size "
> +				 "(%dB), forced to continue\n"),
> +			blocksize, sys_page_size);
> +	}
> +
>  	/* Don't allow user to set both metadata_csum and uninit_bg bits. */
>  	if (ext2fs_has_feature_metadata_csum(&fs_param) &&
>  	    ext2fs_has_feature_gdt_csum(&fs_param))
> -- 
> 2.21.0
> 

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH v2 2/2] tune2fs: Warn if page size != blocksize when enabling encrypt
  2019-08-22 12:17   ` [PATCH v2 " Lukas Czerner
@ 2019-10-03 13:48     ` Eric Sandeen
  0 siblings, 0 replies; 8+ messages in thread
From: Eric Sandeen @ 2019-10-03 13:48 UTC (permalink / raw)
  To: Lukas Czerner, linux-ext4

On 8/22/19 7:17 AM, Lukas Czerner wrote:
> 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"),

"continue"

With that fix,

Reviewed-by: Eric Sandeen <sandeen@redhat.com>

> +				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;
> 

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2019-10-03 13:48 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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   ` [PATCH v2 " Lukas Czerner
2019-10-03 13:48     ` 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

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).