Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp2130539imm; Thu, 20 Sep 2018 08:13:30 -0700 (PDT) X-Google-Smtp-Source: ANB0VdYDVCxIsTeLcLOOvnR7hkes44YP9AcLGmL25KHOWO8pTaEtochpKzuUG0UttjhSCGSSZu5d X-Received: by 2002:a17:902:b10b:: with SMTP id q11-v6mr5019826plr.90.1537456410086; Thu, 20 Sep 2018 08:13:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537456410; cv=none; d=google.com; s=arc-20160816; b=zA6cQguWu4b62K8Br0a0faZG1BO6eW3MI58graOg+ZESMRqSXVc0/QsEUss9Xq2x3t x/xgYYForHrjhHfuoZbUxFl1JUUwSjMinrjcnT7c2WmMJt+/5O7erwvbmtTqCCVFr1nG 83qhS3UIkmB8NrN74HXtC1YV2eASYQbQ0TQQdfYV1Qzfm8wddBdOYk+fzy1FLUunRs75 JiQ0iUxWRqPqir/GOI7V9LKRyma2l765XLAMiu4EgAY1/DNoNnW47Ab37yj0g7V6tDbk 185xO/98c7IyQ/h76inzRvkq8s4UYXfsRzxefxFe1n+Eu3KYqLQ3Fymrea4koONa7BMM F6xQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=THDz0P+2hLPCqDegCGQZClg3PBDMfTh1+DDdNthUPK8=; b=qqpIkvlj/kJoUbJxzsNEuUUMWJ2UUoMvX7r7yj+joM8HB2SxaYxOLtyQ4STMTw+d+/ O5gimD1WvIiry45AkHoQYJPPld5MwOsUSbB7lmWQLWxe+O8Xhgs/+8zNK0k4bdTQ6obY t4rvSPPTxfm8WumuIQ2YWmhfsc3HetjEibfmvftzTednAzvTjZotPo6UDKrB21wPLbt/ 0NaB8PwGoKqRlIyxlBR5yTGLdDddHXwhWmOVEZHl5jnpU7I24P1M0FgP16TdSb48iPRA U3wZSrdJC4jfAvwqe1m3lnAoTnYy/cjySAe4AxcM9cQLS54YaXOKg7HbM7bZ5ND2x2jW P+aw== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k13-v6si23608059pgg.346.2018.09.20.08.13.03; Thu, 20 Sep 2018 08:13:30 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1733230AbeITU4V (ORCPT + 99 others); Thu, 20 Sep 2018 16:56:21 -0400 Received: from mail-wm1-f65.google.com ([209.85.128.65]:51917 "EHLO mail-wm1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387659AbeITU4V (ORCPT ); Thu, 20 Sep 2018 16:56:21 -0400 Received: by mail-wm1-f65.google.com with SMTP id y2-v6so10428663wma.1 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=MX3KP9lVop73CiXCpF3VR/pFsHrNucXsCePHpKF5OOEq6XMTYzwaOBgEftJ8a6aqGm TdFE1NOOC47P7hu/9jHLc+f2G4KOBU9cU7BywvL6WNw8aadjfHifC6xgVD9ZBlKLR4HC MSkokWZHlByb9S5A5KLpGbb/q0UbyZC1tYWvGvTgvPiXDNbu/hOYn1N3kjj4otUeRLt0 NcGr69YwEMYnYj+e3kBKMIc6dUGFseCfFAvWtUN0FRR5xRJANewJZTNAW3Y51ziU6sGY +ETBnAF5CmBnKBJcsvBWPLCYOC2SYfpZUF0o+1Dv0BJQFtqxnSMZYiaPVB8BbyHivgxJ jeww== X-Gm-Message-State: ABuFfoiIq8RP6hyplZw0/15xfxbM5dZ1OJI8T6Gv80hyIM2M06gL11n3 z1s3lyjMg33pdh84Tw1FaHiyIg== 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-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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) -- 2.14.3