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


Groups > linux.kernel > #1471260

[PATCH] fscrypto: fix to null-terminate encrypted filename in fname_encrypt

From Chao Yu <chao@kernel.org>
Newsgroups linux.kernel
Subject [PATCH] fscrypto: fix to null-terminate encrypted filename in fname_encrypt
Date 2016-08-28 03:20 +0200
Message-ID <saWVr-3uU-5@gated-at.bofh.it> (permalink)
Organization linux.* mail to news gateway

Show all headers | View raw


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

Back to linux.kernel | Previous | Next — Next in thread | Find similar | Unroll thread


Thread

[PATCH] fscrypto: fix to null-terminate encrypted filename in fname_encrypt Chao Yu <chao@kernel.org> - 2016-08-28 03:20 +0200
  Re: [PATCH] fscrypto: fix to null-terminate encrypted filename in  fname_encrypt Theodore Ts'o <tytso@mit.edu> - 2016-08-28 07:50 +0200
    Re: [PATCH] fscrypto: fix to null-terminate encrypted filename in  fname_encrypt Chao Yu <chao@kernel.org> - 2016-08-28 08:20 +0200
      Re: [f2fs-dev] [PATCH] fscrypto: fix to null-terminate encrypted  filename in fname_encrypt Chao Yu <chao@kernel.org> - 2016-08-29 17:00 +0200
        Re: [f2fs-dev] [PATCH] fscrypto: fix to null-terminate encrypted  filename in fname_encrypt Jaegeuk Kim <jaegeuk@kernel.org> - 2016-08-29 20:00 +0200
        Re: [f2fs-dev] [PATCH] fscrypto: fix to null-terminate encrypted  filename in fname_encrypt Theodore Ts'o <tytso@mit.edu> - 2016-08-29 21:10 +0200
          Re: [f2fs-dev] [PATCH] fscrypto: fix to null-terminate encrypted  filename in fname_encrypt Chao Yu <yuchao0@huawei.com> - 2016-08-30 18:20 +0200

csiph-web