Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp1361507pxu; Fri, 27 Nov 2020 05:44:52 -0800 (PST) X-Google-Smtp-Source: ABdhPJzDMusjO+RNG4oF8l+tNnLbtW9tlU89GHmqghtkFf+IFjL1VWjhBBKRWgbTt1Nbw+iNicUt X-Received: by 2002:a17:906:52da:: with SMTP id w26mr7722666ejn.347.1606484691815; Fri, 27 Nov 2020 05:44:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606484691; cv=none; d=google.com; s=arc-20160816; b=GVFpIECF21d+MSDwx57y7TQENeHHBPGeont3T/jR+Vvy8wPBf8nRDXAmzQ6ZWfyngM aEEREmjUW8HvNwh8+MLCoMuXWBZoQzuBkajIi9jBpGkb1Fyd0KpEQD/74quMkL3dVxix FxHEdD0k8SOl/1lFIFMl7MYIaJMu8/4+aDLyZW06O0rAeTPyHq1BGGr7FKIQbODTqFuf klwf0kLIfLqmZrzqeGmzJba/zFj9egPFpeqd0BBFCmOHCnZcTw8Ljo0LBOvq5zsdN6GM rPPPj3vAahiYfCRM1ARykD6Jmq3QBtLAXb79pQ3/a//2+CEOPqu3jqQSqEhbxeaB0ES3 R/gw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=mHhjZBnN3z+3VsZkWuXYAabXbjj+P9rLGt94s7fOAdE=; b=vacdA+fptH3V9opG1kdAMeWjpdbeXL1MsBuhSsycZZrmVcE7n4NsRty6VngQMI+jtp CsymYFfGZCxQFXii8wSphkfN0073RL20MDNYpbcHnXPdjmC7g4bshvzgIauqE6PAl1DC Dw71IqAlwzCwyl1ooHxncmz5nLwbYVOkZS3I1RttEvz9UpnX0rJGnFmVPj8+64lMaI5O iboHED91LycAn7LxhkbmkqlZRH0jtQ3CV3vf2mU3mogncNsQ4Xz+2qBJ1GOTxFWvtmM+ HI2SvaYY9QKOycdsfvp7grFVjB1fKUNdnvvR+F46lNufNUWrKcAa6eSiyvik5FHcFhTk MyCw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@android.com header.s=20161025 header.b=ikght7tY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=android.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id gx25si5333491ejb.445.2020.11.27.05.44.28; Fri, 27 Nov 2020 05:44:51 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@android.com header.s=20161025 header.b=ikght7tY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=android.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730574AbgK0Nl3 (ORCPT + 99 others); Fri, 27 Nov 2020 08:41:29 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54060 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730511AbgK0Nl2 (ORCPT ); Fri, 27 Nov 2020 08:41:28 -0500 Received: from mail-wm1-x342.google.com (mail-wm1-x342.google.com [IPv6:2a00:1450:4864:20::342]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E053FC0613D1 for ; Fri, 27 Nov 2020 05:41:26 -0800 (PST) Received: by mail-wm1-x342.google.com with SMTP id 3so2837554wmg.4 for ; Fri, 27 Nov 2020 05:41:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=android.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=mHhjZBnN3z+3VsZkWuXYAabXbjj+P9rLGt94s7fOAdE=; b=ikght7tYkECfMn6+P7TQQwmVNKLHoNl6eXVnWD2C9Z9lbvCgExRuIhfhxtYfjLY6Nb pxmLCfgOdbfWNbleeDtMopz7SyVmgIBFu22cNo8/jG8tTXPDIS4Q/VK/clahboEMaSNy 7ndsMYxe/JDu9ogG7m2eHFBBIoFr2WL7psjYqoSWN54+sHjauRwknulfN4RBM4Qcn1yU X09CwYgIXQWRwqRV7jGrGu/SHDt5eoWJ2Y0eNksm66va949Z6PmMcxDMgCkXhvICIsBn +DWvC5kA3hRqXWUJnDXxqlI67DMHWYQzhXC3D5BrmqJNYWoDNHDMSmuMPa1pZS+vI3HC 7ZJg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=mHhjZBnN3z+3VsZkWuXYAabXbjj+P9rLGt94s7fOAdE=; b=BQDjhK+2A8FgemtEQu50ZvaSW17NekpReGAevcxjUqh8M2K0iAh8KClmeN2/k94Az9 rzHZsMX5W6WwgzElqLHS+3NBj0Zdu0gPkMZNKayjqBT+zSHhP8vzEttzcRCQGeD9gE7X bwRVW3rMZtIBi6JmgNWTpPLXs/QTYuzvqsFK+6Z83yd8SKoCWrI5a73OFUBazdOxe/lK 4JhMYH+u0R4kA1T0iUP6Ge0qxbJGdXTan6+SsUw5IeGEdSOynDBAhWyXWu43GI1c+s4k g2vTF0zvsSVvuOw0I1lGZM5CYF9R6BzcGikuaNB1WILXOlaEKX+1h2mruYK09i0JkTYv ODeA== X-Gm-Message-State: AOAM532AauepjDcDizKNGhBas8EfX1tCqQJBZpZXJLzZ1pfSX9mFpTOu itGRl8QA0NQeNT51KvRt9Yd6Ig== X-Received: by 2002:a05:600c:256:: with SMTP id 22mr9203669wmj.120.1606484485585; Fri, 27 Nov 2020 05:41:25 -0800 (PST) Received: from google.com ([2a00:79e0:d:210:7220:84ff:fe09:7d5c]) by smtp.gmail.com with ESMTPSA id v189sm14287638wmg.14.2020.11.27.05.41.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 27 Nov 2020 05:41:24 -0800 (PST) Date: Fri, 27 Nov 2020 13:41:23 +0000 From: Alessio Balsini To: Peng Tao Cc: Alessio Balsini , Miklos Szeredi , Akilesh Kailash , Amir Goldstein , Antonio SJ Musumeci , David Anderson , Giuseppe Scrivano , Jann Horn , Jens Axboe , Martijn Coenen , Palmer Dabbelt , Paul Lawrence , Stefano Duo , Zimuzo Ezeozue , fuse-devel@lists.sourceforge.net, kernel-team@android.com, "linux-fsdevel@vger.kernel.org" , Linux Kernel Mailing List Subject: Re: [PATCH V10 2/5] fuse: Passthrough initialization and release Message-ID: <20201127134123.GA569154@google.com> References: <20201026125016.1905945-1-balsini@android.com> <20201026125016.1905945-3-balsini@android.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Peng, Thanks for the heads up! On Thu, Nov 26, 2020 at 09:33:34PM +0800, Peng Tao wrote: > On Tue, Oct 27, 2020 at 12:19 AM Alessio Balsini wrote: > > [...] > > int fuse_passthrough_setup(struct fuse_conn *fc, struct fuse_file *ff, > > struct fuse_open_out *openarg) > > { > > - return -EINVAL; > > + struct inode *passthrough_inode; > > + struct super_block *passthrough_sb; > > + struct fuse_passthrough *passthrough; > > + int passthrough_fh = openarg->passthrough_fh; > > + > > + if (!fc->passthrough) > > + return -EPERM; > > + > > + /* Default case, passthrough is not requested */ > > + if (passthrough_fh <= 0) > > + return -EINVAL; > > + > > + spin_lock(&fc->passthrough_req_lock); > > + passthrough = idr_remove(&fc->passthrough_req, passthrough_fh); > > + spin_unlock(&fc->passthrough_req_lock); > > + > > + if (!passthrough) > > + return -EINVAL; > > + > > + passthrough_inode = file_inode(passthrough->filp); > > + passthrough_sb = passthrough_inode->i_sb; > > + if (passthrough_sb->s_stack_depth >= FILESYSTEM_MAX_STACK_DEPTH) { > Hi Alessio, > > passthrough_sb is the underlying filesystem superblock, right? It > seems to prevent fuse passthrough fs from stacking on another fully > stacked file system, instead of preventing other file systems from > stacking on this fuse passthrough file system. Am I misunderstanding > it? Correct, this checks the stacking depth on the lower filesystem. This is an intended behavior to avoid the stacking of multiple FUSE passthrough filesystems, and works because when a FUSE connection has the passthrough feature activated, the file system updates its s_stack_depth to FILESYSTEM_MAX_STACK_DEPTH in process_init_reply() (PATCH 1/5), avoiding further stacking. Do you see issues with that? What I'm now thinking is that fuse_passthrough_open would probably be a better place for this check, so that the ioctl() would fail and the user space daemon may decide to skip passthrough and use legacy FUSE access for that file (or, at least, be aware that something went wrong). A more aggressive approach would be instead to move the stacking depth check to fuse_fill_super_common, where we can update s_stack_depth to lower-fs depth+1 and fail if passthrough is active and s_stack_depth is greater than FILESYSTEM_MAX_STACK_DEPTH. What do you think? Thanks, Alessio