From patchwork Thu Sep 20 15:12:11 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miklos Szeredi X-Patchwork-Id: 10607941 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2745D112B for ; Thu, 20 Sep 2018 15:12:28 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 170CC2DC17 for ; Thu, 20 Sep 2018 15:12:28 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 155B62DC26; Thu, 20 Sep 2018 15:12:28 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AC26A2DC34 for ; Thu, 20 Sep 2018 15:12:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1733251AbeITU4W (ORCPT ); Thu, 20 Sep 2018 16:56:22 -0400 Received: from mail-wm1-f67.google.com ([209.85.128.67]:55330 "EHLO mail-wm1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1733201AbeITU4V (ORCPT ); Thu, 20 Sep 2018 16:56:21 -0400 Received: by mail-wm1-f67.google.com with SMTP id f21-v6so10396264wmc.5 for ; Thu, 20 Sep 2018 08:12:24 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=THDz0P+2hLPCqDegCGQZClg3PBDMfTh1+DDdNthUPK8=; b=VjvXLCqvJmTYDyo+J50kuKDftwD8i1ZBXPFATEJHcyZJw0kARb/yh8EqKW5QnDP8Kz jniDLPT8s7QDmrlsVJCDBRpe59IYdADHRGAkGFLbIV9kmOmyeuFpFF/08tcFNNWFY+4l k4R9rDq4LQDMWB0R2QlrBEA5GjebF3c3e/1scaC5KRI/s+/XmIg37uOn0PLCmTbiLk0x 3YbZNsNSt9LAuHWUpJRQWui+IV3Oywzg0N05G342RzsgSTCO9QXgCvXRri9wHj9fcHYT r3wT/szBpCg4O/AZfihyTENiVdWEAtoLd4NPhwAj+Dpos75+FsX1a1tbLKmXEPp+lL2c W17Q== X-Gm-Message-State: ABuFfojmvCnDiZmWYN4h9z3uPr6zjgJoDMys6AHde1XnNJ03JFDPJkLz oeVqIe62Me/Cnkrcu9xgGNIW6A== X-Google-Smtp-Source: ACcGV63Mg8o3TM2GsrIXvR4H5/dIWJJS5rDgdAGMmH1h385n8FsTCtzFOCexf7d5i4sqAzp9pvyURw== X-Received: by 2002:a1c:68f:: with SMTP id 137-v6mr3348417wmg.82.1537456343911; Thu, 20 Sep 2018 08:12:23 -0700 (PDT) Received: from veci.piliscsaba.redhat.com (catv-212-96-48-140.catv.broadband.hu. [212.96.48.140]) by smtp.gmail.com with ESMTPSA id p89-v6sm55286201wrc.97.2018.09.20.08.12.22 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 20 Sep 2018 08:12:23 -0700 (PDT) From: Miklos Szeredi To: David Howells Cc: Al Viro , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 3/6] mount: fix regression in setting "subtype" from legacy API Date: Thu, 20 Sep 2018 17:12:11 +0200 Message-Id: <20180920151214.15484-4-mszeredi@redhat.com> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180920151214.15484-1-mszeredi@redhat.com> References: <20180920151214.15484-1-mszeredi@redhat.com> Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Subtype was initilized at the wrong place from the wrong source (fstype->fs_type->name, which does not ever contain a subtype). Set subtype from do_new_mount(), where it actually does something. Verified with fuse. Signed-off-by: Miklos Szeredi --- fs/fs_context.c | 34 ---------------------------------- fs/namespace.c | 21 +++++++++++++++++++++ 2 files changed, 21 insertions(+), 34 deletions(-) diff --git a/fs/fs_context.c b/fs/fs_context.c index ceaf42559016..c0ecbb1ecdfe 100644 --- a/fs/fs_context.c +++ b/fs/fs_context.c @@ -684,27 +684,6 @@ static int legacy_validate(struct fs_context *fc) ctx->secdata); } -/* - * Determine the superblock subtype. - */ -static int legacy_set_subtype(struct fs_context *fc) -{ - const char *subtype = strchr(fc->fs_type->name, '.'); - - if (subtype) { - subtype++; - if (!subtype[0]) - return -EINVAL; - } else { - subtype = ""; - } - - fc->subtype = kstrdup(subtype, GFP_KERNEL); - if (!fc->subtype) - return -ENOMEM; - return 0; -} - /* * Get a mountable root with the legacy mount command. */ @@ -713,7 +692,6 @@ static int legacy_get_tree(struct fs_context *fc) struct legacy_fs_context *ctx = fc->fs_private; struct super_block *sb; struct dentry *root; - int ret; root = fc->fs_type->mount(fc->fs_type, fc->sb_flags, fc->source, ctx->legacy_data, @@ -724,20 +702,8 @@ static int legacy_get_tree(struct fs_context *fc) sb = root->d_sb; BUG_ON(!sb); - if ((fc->fs_type->fs_flags & FS_HAS_SUBTYPE) && - !fc->subtype) { - ret = legacy_set_subtype(fc); - if (ret < 0) - goto err_sb; - } - fc->root = root; return 0; - -err_sb: - dput(root); - deactivate_locked_super(sb); - return ret; } /* diff --git a/fs/namespace.c b/fs/namespace.c index 865b6f2c5e7d..7671c1f6fc22 100644 --- a/fs/namespace.c +++ b/fs/namespace.c @@ -2617,6 +2617,7 @@ static int do_new_mount(struct path *mountpoint, const char *fstype, { struct file_system_type *fs_type; struct fs_context *fc; + const char *subtype = NULL; int err; if (!fstype) @@ -2627,6 +2628,19 @@ static int do_new_mount(struct path *mountpoint, const char *fstype, if (!fs_type) goto out; + if (fs_type->fs_flags & FS_HAS_SUBTYPE) { + subtype = strchr(fstype, '.'); + if (subtype) { + subtype++; + if (!subtype[0]) { + put_filesystem(fs_type); + return -EINVAL; + } + } else { + subtype = ""; + } + } + fc = vfs_new_fs_context(fs_type, NULL, sb_flags, sb_flags, FS_CONTEXT_FOR_USER_MOUNT); put_filesystem(fs_type); @@ -2635,6 +2649,13 @@ static int do_new_mount(struct path *mountpoint, const char *fstype, goto out; } + if (subtype) { + fc->subtype = kstrdup(subtype, GFP_KERNEL); + err = -ENOMEM; + if (!fc->subtype) + goto out; + } + if (name) { err = vfs_parse_fs_string(fc, "source", name, strlen(name)); if (err < 0)