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


Groups > linux.kernel > #1471275

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

Path csiph.com!weretis.net!feeder4.news.weretis.net!newsfeed.CARNet.hr!news.spin.it!bofh.it!news.nic.it!robomod
From Theodore Ts'o <tytso@mit.edu>
Newsgroups linux.kernel
Subject Re: [PATCH] fscrypto: fix to null-terminate encrypted filename in fname_encrypt
Date Sun, 28 Aug 2016 07:50:01 +0200
Message-ID <sb18J-64x-5@gated-at.bofh.it> (permalink)
References <saWVr-3uU-5@gated-at.bofh.it>
X-Original-To Chao Yu <chao@kernel.org>
Dkim-Signature v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=thunk.org; s=ef5046eb; h=In-Reply-To:Content-Type:MIME-Version:References:Message-ID:Subject:Cc:To:From:Date; bh=TZ6WMnF6eX0hC0NMcLaldKBrn50Aiq6IwzhHGEg5Nhw=; b=ukOnz8M5XInk79OcXqOa5AVNtfWY4gO/oYPsbGpImm0s9Ui3hpYg6cnu9ioNOo/797cv/l9c9Ei3BSmMp8P3h3kGi0wyfGru40ufCzSc2LCTyp1icAJ1MbznZxfZM03NSu79Tlg+QfCR5mzN6G9EumbpaVGmDQ/Mxae4RkM3VC4=;
Mail-Followup-To Theodore Ts'o <tytso@mit.edu>, Chao Yu <chao@kernel.org>, jaegeuk@kernel.org, linux-f2fs-devel@lists.sourceforge.net, linux-ext4@vger.kernel.org, linux-kernel@vger.kernel.org, Chao Yu <yuchao0@huawei.com>
MIME-Version 1.0
Content-Type text/plain; charset=us-ascii
Content-Disposition inline
User-Agent Mutt/1.6.2-neo (2016-07-23)
X-Sa-Exim-Connect-IP <locally generated>
X-Sa-Exim-Mail-From tytso@thunk.org
X-Sa-Exim-Scanned No (on imap.thunk.org); SAEximRunCond expanded to false
Sender robomod@news.nic.it
List-ID <linux-kernel.vger.kernel.org>
X-Mailing-List linux-kernel@vger.kernel.org
Approved robomod@news.nic.it
Lines 36
Organization linux.* mail to news gateway
X-Original-Cc jaegeuk@kernel.org, linux-f2fs-devel@lists.sourceforge.net, linux-ext4@vger.kernel.org, linux-kernel@vger.kernel.org, Chao Yu <yuchao0@huawei.com>
X-Original-Date Sun, 28 Aug 2016 01:13:30 -0400
X-Original-Message-ID <20160828051330.7kyhhvvxitghshi7@thunk.org>
X-Original-References <1472346808-3213-1-git-send-email-chao@kernel.org>
X-Original-Sender linux-kernel-owner@vger.kernel.org
Xref csiph.com linux.kernel:1471275

Show key headers only | View raw


On Sun, Aug 28, 2016 at 09:13:28AM +0800, Chao Yu wrote:
> 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

The problem is not in fname_encrypt(), but rather that
security_inode_init_security() should be given the _unencrypted_
filename.

In ext4 security_inode_init_security() is called with the qstr from
the dentry, not the encrypted qstr --- in fact we call
security_inode_init_security before we call fname_encrypt.

SELinux needs the unencrypted filename in order to decide which
SELinux rules / labels should apply.

					- Ted

Back to linux.kernel | Previous | Next — Previous in thread | 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