Skip to contentSkip to conversation

fix an endianness bug in ext4_encrypted_zeroout()

PATCH In review Al Viro 2 participants 2 messages Nov 26, 2015 ext4 file system

lore
Share & tools
lore

Al Viro

author
#0 lore raw

PATCH 1/1 fix an endianness bug in ext4_encrypted_zeroout()

ex->ee_block is not host-endian (note that accesses of other fields of *ex right next to that line go through the helpers that do proper conversion from little-endian to host-endian; it might make sense to add similar for ->ee_block to avoid reintroducing that kind of bugs...)

---

fs/ext4/crypto.c +1 -1
index af06830..1a08350 100644
@@ -389,7 +389,7 @@ int ext4_encrypted_zeroout(struct inode *inode, struct ext4_extent *ex)
 	struct ext4_crypto_ctx	*ctx;
 	struct page		*ciphertext_page = NULL;
 	struct bio		*bio;
-	ext4_lblk_t		lblk = ex->ee_block;
+	ext4_lblk_t		lblk = le32_to_cpu(ex->ee_block);
 	ext4_fsblk_t		pblk = ext4_ext_pblock(ex);
 	unsigned int		len = ext4_ext_get_actual_len(ex);
 	int			ret, err = 0;
maintainer
#1 lore raw
Quoted 8 lines · Al Viro

ex->ee_block is not host-endian (note that accesses of other fields of *ex right next to that line go through the helpers that do proper conversion from little-endian to host-endian; it might make sense to add similar for ->ee_block to avoid reintroducing that kind of bugs...)

Thanks for catching this! Applied.

- Ted