[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <578A5D84.2050207@oracle.com>
Date: Sat, 16 Jul 2016 18:15:00 +0200
From: Vegard Nossum <vegard.nossum@...cle.com>
To: "Theodore Ts'o" <tytso@....edu>
Cc: linux-ext4@...r.kernel.org, Michael Halcrow <mhalcrow@...gle.com>,
Ildar Muslukhov <ildarm@...gle.com>,
Jaegeuk Kim <jaegeuk@...nel.org>
Subject: Re: kernel BUG at fs/ext4/inode.c:3709! (Re: open bugs found by
fuzzing)
On 07/15/2016 09:49 PM, Theodore Ts'o wrote:
> The problem is fixing this is messy. The problem is if we just set
> i_size without zeroing out the bytes between i_size and the end of the
> page, we're asking for trouble. For example, you could think that
> it's enough to have ext4_readpage() care of doing the zeroing after
> the block is read from disk and then decrypted, but what if the user
> does a sparse write beyond i_size?
>
> So either we allow truncate(2) to be non-atomic with respect to
> crashes for encrypted files, or alternatively we would have to set a
> flag in the inode indicating that the bytes between i_size and the end
> of the page must be zeroed before the file can be modified in any way,
> or before an attempted O_DIRECT read of the last block, and then when
> we read the inode from diks into the inode cache, if the bit is set
> and we have the encryption key (which we would need if we want to
> modify the file), we could take zeroing the tail end of the file then.
Can we delay the truncation/cleanup of that inode until the correct key
gets loaded? It's not like anybody could open (or otherwise operate on
the data of) that inode anyway until they key is present, right?
Something like the attached (very hacky) patch seems to allow my fuzzed
filesystem to mount without error and keeps the inode in question on the
on-disk orphan list:
+ mount (...)
EXT4-fs (loop0): 1 encrypted truncate delayed
EXT4-fs (loop0): recovery complete
EXT4-fs (loop0): mounted filesystem with ordered data mode. Opts:
errors=remount-ro
You'd of course have to check whether the inode needs the
cleanup/truncate if it's ever accessed and return an error or something.
Maybe in ext4_iget()/ext4_lookup()?
It's probably a stupid idea for a number of reasons, but I'd be happy to
learn exactly why :-)
Vegard
View attachment "ext4-encrypted-orphans.patch" of type "text/x-patch" (2266 bytes)
Powered by blists - more mailing lists