Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1534504 > unrolled thread

[PATCH 2/6] fscrypt: Release fscrypt context on in-place encryption

Started byRichard Weinberger <richard@nod.at>
First post2016-12-01 23:30 +0100
Last post2016-12-02 09:20 +0100
Articles 2 — 2 participants

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  [PATCH 2/6] fscrypt: Release fscrypt context on in-place encryption Richard Weinberger <richard@nod.at> - 2016-12-01 23:30 +0100
    Re: [PATCH 2/6] fscrypt: Release fscrypt context on in-place  encryption Eric Biggers <ebiggers@google.com> - 2016-12-02 09:20 +0100

#1534504 — [PATCH 2/6] fscrypt: Release fscrypt context on in-place encryption

FromRichard Weinberger <richard@nod.at>
Date2016-12-01 23:30 +0100
Subject[PATCH 2/6] fscrypt: Release fscrypt context on in-place encryption
Message-ID<sJI1z-3bb-21@gated-at.bofh.it>
From: David Gstir <david@sigma-star.at>

In case of in-place encryption ctx must be released right away.
Otherwise ctx is never freed.

Fixes: 1c7dcf69eea3 ("fscrypt: Add in-place encryption mode")
Signed-off-by: David Gstir <david@sigma-star.at>
Signed-off-by: Richard Weinberger <richard@nod.at>
---
 fs/crypto/crypto.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/fs/crypto/crypto.c b/fs/crypto/crypto.c
index 3c1124beae28..1b877fcec1c1 100644
--- a/fs/crypto/crypto.c
+++ b/fs/crypto/crypto.c
@@ -270,6 +270,8 @@ struct page *fscrypt_encrypt_page(const struct inode *inode,
 		SetPagePrivate(ciphertext_page);
 		set_page_private(ciphertext_page, (unsigned long)ctx);
 		lock_page(ciphertext_page);
+	} else {
+		fscrypt_release_ctx(ctx);
 	}
 	return ciphertext_page;
 
-- 
2.7.3

[toc] | [next] | [standalone]


#1534728 — Re: [PATCH 2/6] fscrypt: Release fscrypt context on in-place encryption

FromEric Biggers <ebiggers@google.com>
Date2016-12-02 09:20 +0100
SubjectRe: [PATCH 2/6] fscrypt: Release fscrypt context on in-place encryption
Message-ID<sJRex-16S-9@gated-at.bofh.it>
In reply to#1534504
On Thu, Dec 01, 2016 at 11:14:54PM +0100, Richard Weinberger wrote:
> From: David Gstir <david@sigma-star.at>
> 
> In case of in-place encryption ctx must be released right away.
> Otherwise ctx is never freed.
> 

I didn't notice this before, but the fscrypt_ctx isn't actually used at all in
the "own pages" crypto case.  So there's really no need to allocate one.  How
about we just handle the "own pages" case at the beginning of
fscrypt_encrypt_page():

	if (inode->i_sb->s_cop->flags & FS_CFLG_OWN_PAGES) {
		err = do_page_crypto(inode, FS_ENCRYPT, lblk_num, page, page,
				     len, offs, gfp_flags);
		if (err)
			return ERR_PTR(err);
		return page;
	}

	(and the rest essentially the same as it used to be)

Eric

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web