linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] fscrypto: fix to null-terminate encrypted filename in fname_encrypt
@ 2016-08-28  1:13 Chao Yu
  2016-08-28  5:13 ` Theodore Ts'o
  0 siblings, 1 reply; 7+ messages in thread
From: Chao Yu @ 2016-08-28  1:13 UTC (permalink / raw)
  To: tytso, jaegeuk; +Cc: linux-f2fs-devel, linux-ext4, linux-kernel, Chao Yu

From: Chao Yu <yuchao0@huawei.com>

This patch fixes to add null character at the end of encrypted filename
in fname_encrypt, in order to avoid incorrectly traversing random data
located after target filename. The call stack is as below:

- f2fs_add_link
 - __f2fs_add_link
  - fscrypt_setup_filename
   - fscrypt_fname_alloc_buffer		allocate buffer for @fname
   - fname_encrypt			didn't set null character for @fname
  - f2fs_add_regular_entry		init qstr with @fname
   - init_inode_metadata
    - f2fs_init_security
     - security_inode_init_security
      - selinux_inode_init_security
       - selinux_determine_inode_label
        - security_transition_sid
	 - security_compute_sid
	  - filename_compute_type
	   - hashtab_search
	    - filenametr_hash		traverse @fname as one which has null character

Signed-off-by: Chao Yu <yuchao0@huawei.com>
---
 fs/crypto/fname.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/fs/crypto/fname.c b/fs/crypto/fname.c
index 5d6d491..5c356c0 100644
--- a/fs/crypto/fname.c
+++ b/fs/crypto/fname.c
@@ -110,6 +110,7 @@ static int fname_encrypt(struct inode *inode,
 				"%s: Error (error code %d)\n", __func__, res);
 
 	oname->len = ciphertext_len;
+	oname->name[oname->len] = 0;
 	return res;
 }
 
-- 
2.7.2

^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2016-08-30 16:11 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-08-28  1:13 [PATCH] fscrypto: fix to null-terminate encrypted filename in fname_encrypt Chao Yu
2016-08-28  5:13 ` Theodore Ts'o
2016-08-28  6:16   ` Chao Yu
2016-08-29 14:55     ` [f2fs-dev] " Chao Yu
2016-08-29 17:51       ` Jaegeuk Kim
2016-08-29 19:08       ` Theodore Ts'o
2016-08-30 16:10         ` Chao Yu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).