From 7799953b34d1838b30e3d69fd36aa3288ac1e89d Mon Sep 17 00:00:00 2001 From: Richard Weinberger Date: Thu, 29 Sep 2016 22:20:19 +0200 Subject: ubifs: Implement encrypt/decrypt for all IO Signed-off-by: Richard Weinberger Signed-off-by: David Gstir Signed-off-by: Richard Weinberger --- fs/ubifs/file.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'fs/ubifs/file.c') diff --git a/fs/ubifs/file.c b/fs/ubifs/file.c index 60e789a9cac8..4c50f8feb0d5 100644 --- a/fs/ubifs/file.c +++ b/fs/ubifs/file.c @@ -78,6 +78,13 @@ static int read_block(struct inode *inode, void *addr, unsigned int block, goto dump; dlen = le32_to_cpu(dn->ch.len) - UBIFS_DATA_NODE_SZ; + + if (ubifs_crypt_is_encrypted(inode)) { + err = ubifs_decrypt(inode, dn, &dlen, block); + if (err) + goto dump; + } + out_len = UBIFS_BLOCK_SIZE; err = ubifs_decompress(c, &dn->data, dlen, addr, &out_len, le16_to_cpu(dn->compr_type)); @@ -650,6 +657,13 @@ static int populate_page(struct ubifs_info *c, struct page *page, dlen = le32_to_cpu(dn->ch.len) - UBIFS_DATA_NODE_SZ; out_len = UBIFS_BLOCK_SIZE; + + if (ubifs_crypt_is_encrypted(inode)) { + err = ubifs_decrypt(inode, dn, &dlen, page_block); + if (err) + goto out_err; + } + err = ubifs_decompress(c, &dn->data, dlen, addr, &out_len, le16_to_cpu(dn->compr_type)); if (err || len != out_len) -- cgit v1.2.3-59-g8ed1b