Received: by 2002:ac0:950c:0:0:0:0:0 with SMTP id f12csp2955405imc; Wed, 13 Mar 2019 05:33:19 -0700 (PDT) X-Google-Smtp-Source: APXvYqyDqivwFulBGXViYMijnkFbDjkb9dM5lVFGutVgaj13564zIdNZ1cJcMv8Ol74Utc0JmH1s X-Received: by 2002:a17:902:421:: with SMTP id 30mr44492583ple.142.1552480399173; Wed, 13 Mar 2019 05:33:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1552480399; cv=none; d=google.com; s=arc-20160816; b=hLN+c4DdAsaJDJ9j8nHu5eHp5GJAwm/bmdhnkAxMfs6OwcZtCe6HSgxqRkN6tR3BgK ptJpcNg7Ic6U/uPhy71zvll+FrOJk2BEeVp22/3Nv1BjoYA/0ckKev4F6C1P7p08+fHF mS4P6wp/GMnjWiazL5jXxnkV19CHhUoaZH6p7XBiG43/TGf+a6tDUOK83iCbpamB8tXV C76YPfzi2VX7PePR2tdBN7eMqajKAIT+CKCETGkiW1iV2/FPZKVyXs6Q3HC0yn+hbX1D 0PaQdNP6fxaP6NWUn8ubJaMZsnN8xrTUdpsQrm2OABrMuBmSvoCIHfK1hwSKDuDh170c 7EuA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=eQEzAKqQI/8TT+AhDCfE3qjc9ww2XMIpGDRnJHQpQ84=; b=GaOs61EMFWljNqUrugeP558LfFjWEgjMZNcNHvPAikE0/tK60Y+ymXazMKJ0d7mmcz 6gEs8Qp1eauEBGw/34/Txx0GnZyT5m+eiw+YOA/7gvLSAHJJT/fOCudSRzhcowPVDMKe McWx4MRwo+g3VRjIv2Zh3/BQyQp5EIjLhDYES5r3/NvzEY0/QL+FLsVrDlI5rpvQBKjq gSJJ1KydPAM7VFCVaCKYC6bwwBKUCOCcmBhJHUxi2TjwYSZj04klv95zuqCOnlfznL/5 1LeNGKaVHznnEemZ1BNLny4ZSfM6dgYu74nflxDrj+jUkaKdR6KObZnkKZOuhPrSgz4y LZYw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id gn14si10764616plb.171.2019.03.13.05.33.03; Wed, 13 Mar 2019 05:33:19 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726337AbfCMMbW (ORCPT + 99 others); Wed, 13 Mar 2019 08:31:22 -0400 Received: from lithops.sigma-star.at ([195.201.40.130]:41724 "EHLO lithops.sigma-star.at" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725893AbfCMMbW (ORCPT ); Wed, 13 Mar 2019 08:31:22 -0400 Received: from localhost (localhost [127.0.0.1]) by lithops.sigma-star.at (Postfix) with ESMTP id 71025609187E; Wed, 13 Mar 2019 13:31:19 +0100 (CET) Received: from lithops.sigma-star.at ([127.0.0.1]) by localhost (lithops.sigma-star.at [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id 8NsQbv6QpKFp; Wed, 13 Mar 2019 13:31:18 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by lithops.sigma-star.at (Postfix) with ESMTP id DD2A4609186C; Wed, 13 Mar 2019 13:31:18 +0100 (CET) Received: from lithops.sigma-star.at ([127.0.0.1]) by localhost (lithops.sigma-star.at [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id IU7AkRYfsYUw; Wed, 13 Mar 2019 13:31:18 +0100 (CET) Received: from blindfold.localnet (unknown [82.150.214.1]) by lithops.sigma-star.at (Postfix) with ESMTPSA id 86017608A389; Wed, 13 Mar 2019 13:31:18 +0100 (CET) From: Richard Weinberger To: linux-fsdevel@vger.kernel.org Cc: linux-fscrypt@vger.kernel.org, linux-unionfs@vger.kernel.org, linux-kernel@vger.kernel.org Subject: overlayfs vs. fscrypt Date: Wed, 13 Mar 2019 13:31:17 +0100 Message-ID: <4603533.ZIfxmiEf7K@blindfold> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi! overlayfs and fscrypt are not friends. Currently it is not possible to use a fscrypt encrypted directory as upper directory with overlayfs. The reason for that is, fscrypt implements ->d_revalidate(). From fscrypt's point of view having ->d_revalidate() makes sense because it wants to hide/show encrypted filenames if someone loads or unlinks a key. On the other hand, overlayfs makes sure that the upper directory cannot change beneath it. Therefore it checks whether the upper directory is a remote filesystem by checking for ->d_revalidate() and refuses to mount if so. In my little embedded Linux world it is common to use both UBIFS and overlayfs. Now with UBIFS being encrypted using fscrypt, overlayfs is a problem. My current hack is not using fscrypt_d_ops in UBIFS. This works because on a typical embedded target you setup your crypto keys exactly once, right before you mount overlayfs in an initramfs. But I'm sure this problem will hit sooner or later users of ext4 and f2fs too. Therefore I'd like to discuss possible solutions. So far I see two options: 1. Get rid of ->d_revalidate() in fscrypt. Maybe we find a way to return a dentry via ->lookup() which is not cached at all and therefore no ->d_revalidate() is needed. If unreadable and encrypted filename lookups are slow, so what? AFAIU this approach is impossible in the current dcache design since it is not allowed to have more than one dentry to the same file. 2. Teach overlayfs to deal with a upper that has ->d_revalidate(). Given the complexity of overlayfs I'm not sure how feasible this is. But I'm no overlayfs expert, maybe I miss something. What else could we do? Thanks, //richard