EcryptFS development
 help / color / mirror / Atom feed
From: Michael Halcrow <mhalcrow@google.com>
To: tyhicks@canonical.com
Cc: dmitryc@google.com, ecryptfs@vger.kernel.org,
	Michael Halcrow <mhalcrow@google.com>
Subject: [PATCH] eCryptfs: Allocate sufficient buffer space for encrypted filename decoding
Date: Fri, 21 Nov 2014 09:02:03 -0800	[thread overview]
Message-ID: <1416589323-4762-1-git-send-email-mhalcrow@google.com> (raw)

Dmitry Chernenkov used KASAN to discover that eCryptfs writes past the
end of the allocated buffer during encrypted filename decoding. This
fix corrects the issue by ensuring that there is sufficient buffer
space allocated.

Signed-off-by: Michael Halcrow <mhalcrow@google.com>
---
 fs/ecryptfs/crypto.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/ecryptfs/crypto.c b/fs/ecryptfs/crypto.c
index 2f6735d..53d4f2e 100644
--- a/fs/ecryptfs/crypto.c
+++ b/fs/ecryptfs/crypto.c
@@ -1871,7 +1871,7 @@ static size_t ecryptfs_max_decoded_size(size_t encoded_size)
 	 * the caller with the maximum amount of allocated
 	 * space that @dst will need to point to in a
 	 * subsequent call. */
-	return ((encoded_size + 1) * 3) / 4;
+	return (((encoded_size + 1) * 3) / 4) + 1;
 }
 
 /**
-- 
2.1.0.rc2.206.gedb03e5

             reply	other threads:[~2014-11-21 17:02 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-11-21 17:02 Michael Halcrow [this message]
2014-11-26 17:11 ` [PATCH] eCryptfs: Allocate sufficient buffer space for encrypted filename decoding Michael Halcrow
2014-11-26 17:23   ` Tyler Hicks

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1416589323-4762-1-git-send-email-mhalcrow@google.com \
    --to=mhalcrow@google.com \
    --cc=dmitryc@google.com \
    --cc=ecryptfs@vger.kernel.org \
    --cc=tyhicks@canonical.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox