linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ext4: disable retry logic in ext4_set_encrypted_filename
@ 2016-01-02 19:50 Arnd Bergmann
  2016-01-03  3:54 ` Theodore Ts'o
  0 siblings, 1 reply; 2+ messages in thread
From: Arnd Bergmann @ 2016-01-02 19:50 UTC (permalink / raw)
  To: Theodore Ts'o; +Cc: Andreas Dilger, linux-ext4, linux-kernel

gcc correctly warns that the ctx variable in ext4_set_encrypted_filename
has gone out of scope in ext4_set_encrypted_filename if we enter the
retry path and a 'goto' into the previous code block can not guarantee
to get the contents back:

fs/ext4/namei.c: In function 'ext4_set_encrypted_filename':
fs/ext4/namei.c:4035:10: warning: 'ctx' may be used uninitialized in this function [-Wmaybe-uninitialized]
   retval = ext4_xattr_set_handle(handle, inode,

I tried moving the variable declaration to the start of the function,
but that does not shut up the warning, as it's apparently too hard
for the compiler to follow the control flow and determine that it's
correct (or for me reading the code, for that matter).

This adds a hack to avoid the undefined behavior at the cost of
losing the chance to retry on a spurious -ENOSPC error. We probably
need a better solution.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Fixes: 374431bae296 ("ext4 crypto: add ioctls to allow backup of encryption metadata")
---
The warning appeared with next-20121231, which is the latest next release,
nevermind if it has already been fixed in the meantime.

diff --git a/fs/ext4/namei.c b/fs/ext4/namei.c
index c03f310200d6..fd2bd090bdfa 100644
--- a/fs/ext4/namei.c
+++ b/fs/ext4/namei.c
@@ -4113,7 +4113,7 @@ out:
 	}
 	if (handle)
 		ext4_journal_stop(handle);
-	if (do_retry) {
+	if (do_retry /* FIXME: ctx is invalid */ && 0) {
 		do_retry = 0;
 		goto retry;
 	}


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

* Re: [PATCH] ext4: disable retry logic in ext4_set_encrypted_filename
  2016-01-02 19:50 [PATCH] ext4: disable retry logic in ext4_set_encrypted_filename Arnd Bergmann
@ 2016-01-03  3:54 ` Theodore Ts'o
  0 siblings, 0 replies; 2+ messages in thread
From: Theodore Ts'o @ 2016-01-03  3:54 UTC (permalink / raw)
  To: Arnd Bergmann; +Cc: Andreas Dilger, linux-ext4, linux-kernel

On Sat, Jan 02, 2016 at 08:50:11PM +0100, Arnd Bergmann wrote:
> gcc correctly warns that the ctx variable in ext4_set_encrypted_filename
> has gone out of scope in ext4_set_encrypted_filename if we enter the
> retry path and a 'goto' into the previous code block can not guarantee
> to get the contents back:
> 
> fs/ext4/namei.c: In function 'ext4_set_encrypted_filename':
> fs/ext4/namei.c:4035:10: warning: 'ctx' may be used uninitialized in this function [-Wmaybe-uninitialized]
>    retval = ext4_xattr_set_handle(handle, inode,

Sorry, this was a known bug that I fixed about a week ago, but I
hadn't pushed out an update to the ext4 dev branch because I hadn't
had a chance to finish testing the project quota changes.  I've just
pushed out an update.

					- Ted

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

end of thread, other threads:[~2016-01-03  4:50 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-01-02 19:50 [PATCH] ext4: disable retry logic in ext4_set_encrypted_filename Arnd Bergmann
2016-01-03  3:54 ` Theodore Ts'o

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