From 54dbef6963f146db5eb296e87c330072dc366a6c Mon Sep 17 00:00:00 2001 From: Theodore Ts'o Date: Fri, 30 Sep 2016 01:50:09 -0400 Subject: [PATCH] add patch use-standard-macros-to-compute-length-of-fname-ciphertext --- series | 1 + timestamps | 7 +-- ...rd-macros-to-compute-length-of-fname-ciphertext | 60 ++++++++++++++++++++++ 3 files changed, 65 insertions(+), 3 deletions(-) create mode 100644 use-standard-macros-to-compute-length-of-fname-ciphertext diff --git a/series b/series index fecd3e93..94591539 100644 --- a/series +++ b/series @@ -34,6 +34,7 @@ allow-dax-writeback-for-hole-punch optimize-dioread-locking release-bh-in-make_indexed_dir do-not-null-terminate-encrypted-symlink-data +use-standard-macros-to-compute-length-of-fname-ciphertext ########################################## # unstable patches diff --git a/timestamps b/timestamps index 6dd800fa..ecadf635 100755 --- a/timestamps +++ b/timestamps @@ -72,6 +72,7 @@ touch -d @1474635791 stable-boundary touch -d @1475211797 optimize-dioread-locking touch -d @1475213617 release-bh-in-make_indexed_dir touch -d @1475214257 do-not-null-terminate-encrypted-symlink-data -touch -d @1475214296 series -touch -d @1475214302 status -touch -d @1475214386 timestamps +touch -d @1475214378 use-standard-macros-to-compute-length-of-fname-ciphertext +touch -d @1475214409 series +touch -d @1475214414 status +touch -d @1475214601 timestamps diff --git a/use-standard-macros-to-compute-length-of-fname-ciphertext b/use-standard-macros-to-compute-length-of-fname-ciphertext new file mode 100644 index 00000000..1eafdecb --- /dev/null +++ b/use-standard-macros-to-compute-length-of-fname-ciphertext @@ -0,0 +1,60 @@ +fscrypto: use standard macros to compute length of fname ciphertext + +From: Eric Biggers + +Signed-off-by: Eric Biggers +Signed-off-by: Theodore Ts'o +--- + fs/crypto/fname.c | 17 +++++------------ + 1 file changed, 5 insertions(+), 12 deletions(-) + +diff --git a/fs/crypto/fname.c b/fs/crypto/fname.c +index 90697c7..9a28133 100644 +--- a/fs/crypto/fname.c ++++ b/fs/crypto/fname.c +@@ -14,11 +14,6 @@ + #include + #include + +-static u32 size_round_up(size_t size, size_t blksize) +-{ +- return ((size + blksize - 1) / blksize) * blksize; +-} +- + /** + * fname_crypt_complete() - completion callback for filename crypto + * @req: The asynchronous cipher request context +@@ -60,10 +55,9 @@ static int fname_encrypt(struct inode *inode, + if (iname->len <= 0 || iname->len > lim) + return -EIO; + +- ciphertext_len = (iname->len < FS_CRYPTO_BLOCK_SIZE) ? +- FS_CRYPTO_BLOCK_SIZE : iname->len; +- ciphertext_len = size_round_up(ciphertext_len, padding); +- ciphertext_len = (ciphertext_len > lim) ? lim : ciphertext_len; ++ ciphertext_len = max(iname->len, (u32)FS_CRYPTO_BLOCK_SIZE); ++ ciphertext_len = round_up(ciphertext_len, padding); ++ ciphertext_len = min(ciphertext_len, lim); + + if (ciphertext_len <= sizeof(buf)) { + workbuf = buf; +@@ -233,9 +227,8 @@ u32 fscrypt_fname_encrypted_size(struct inode *inode, u32 ilen) + + if (ci) + padding = 4 << (ci->ci_flags & FS_POLICY_FLAGS_PAD_MASK); +- if (ilen < FS_CRYPTO_BLOCK_SIZE) +- ilen = FS_CRYPTO_BLOCK_SIZE; +- return size_round_up(ilen, padding); ++ ilen = max(ilen, (u32)FS_CRYPTO_BLOCK_SIZE); ++ return round_up(ilen, padding); + } + EXPORT_SYMBOL(fscrypt_fname_encrypted_size); + +-- +2.8.0.rc3.226.g39d4020 + +-- +To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in +the body of a message to majordomo@vger.kernel.org +More majordomo info at http://vger.kernel.org/majordomo-info.html + -- 2.11.4.GIT