Whamcloud - gitweb
LU-13717 sec: filename encryption - symlink support 94/43394/19
authorSebastien Buisson <sbuisson@ddn.com>
Tue, 31 Aug 2021 15:30:48 +0000 (17:30 +0200)
committerOleg Drokin <green@whamcloud.com>
Wed, 22 Sep 2021 04:14:47 +0000 (04:14 +0000)
commite735298935b64541fc561bd9e978cd7af48c503e
tree4c7be835f6e3ce46ccbfb6a63892b57db7e280a1
parentdf2c0c19b1b8075a21b583b06aaf11f215f59c22
LU-13717 sec: filename encryption - symlink support

On client side, call the appropriate llcrypt primitives from llite,
to proceed with symlink encryption before sending requests to servers
and symlink decryption upon request receipt.
The tricky part is that llcrypt needs an inode to encrypt the target
name. But by the time we prepare the symlink creation request to be
sent to the server with the target name (in ll_new_node), we do not
have an inode yet (it will be obtained only after we get the server
reply). So we create a fake inode and associate the right encryption
context to it, so that the symlink gets encrypted properly.

In order to report the correct size for an encrypted symlink (which is
ought to be the length of the symlink target), we need to read the
symlink target and decrypt or decode it in ->getattr(). This has a
performance hit, but given that the symlink target is cached in
->i_link (when the key is available), the symlink will not have to be
read and decrypted again later when it is actually followed,
readlink() is called, or lstat() is called again.
This part of the patch is adapted from kernel commit
d18760560593e5af921f51a8c9b64b6109d634c2
"fscrypt: add fscrypt_symlink_getattr() for computing st_size"

With encrypted file names, a symlink target is binary. So make sure
server side can handle that, by switching sp_symname to a
struct lu_name in struct md_op_spec.

Signed-off-by: Sebastien Buisson <sbuisson@ddn.com>
Change-Id: Ic6892fca8926a35001697c54aaf05d15563b139d
Reviewed-on: https://review.whamcloud.com/43394
Tested-by: jenkins <devops@whamcloud.com>
Reviewed-by: Patrick Farrell <pfarrell@whamcloud.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/include/md_object.h
lustre/llite/namei.c
lustre/llite/symlink.c
lustre/mdd/mdd_dir.c
lustre/mdt/mdt_lib.c
lustre/tests/sanity-sec.sh