From patchwork Thu Sep 20 15:12:09 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miklos Szeredi X-Patchwork-Id: 10607939 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 D6E421390 for ; Thu, 20 Sep 2018 15:12:25 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C6EF42DC00 for ; Thu, 20 Sep 2018 15:12:25 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C51D22DC69; Thu, 20 Sep 2018 15:12:25 +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 704D62DC00 for ; Thu, 20 Sep 2018 15:12:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1733195AbeITU4S (ORCPT ); Thu, 20 Sep 2018 16:56:18 -0400 Received: from mail-wr1-f65.google.com ([209.85.221.65]:44140 "EHLO mail-wr1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732393AbeITU4S (ORCPT ); Thu, 20 Sep 2018 16:56:18 -0400 Received: by mail-wr1-f65.google.com with SMTP id v16-v6so9773736wro.11 for ; Thu, 20 Sep 2018 08:12:21 -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=WtmReosd4GA07GtJdxNb9bOVWt1Zeu6Sxj30CYjenFo=; b=GWHda+W4U9lNJ6+tNakb97i04x8TWt8ofAW/HyTnn1jesJwv09yQmNfE1M0eI9Gd8s 9ov7lNLHm+bfMatBL6+ofvFk/LWVfYdycGBYFz+T8yP6vClS1T1lAGM4G5VE2lff1vu0 xmRqXa8FdV2pdJ+8X53UnajVJLD3brLmjkvXpH3xYvBFzSIaAWgYdCeuK6NaS3l+OV0E ek+4G4CGf76B8xavOMbdGzVEENYRlVmC+fo+fRyRMYQY39MqMsUQsEe4P8T8vAheONIS FBJOnrJuExUqhYIVrXBffZh6PqxPKX9wkigSF9AeBfzeVyhbZcg+gMknJKc4pSdSkb4b /E+w== X-Gm-Message-State: APzg51DC4qQFXHKI8r+8xjz87/9az4Hwd4o0BVj3T3iTiqGD9AsEQ0zf K5RIxL3Qt0aSq0+wT6YnexiKFA== X-Google-Smtp-Source: ANB0VdbOQNl4gXK+wKNb02yVlcxj9w8JLKEhPgrcq/K7pk1MYzv++Cx+ILmegRfdCJ+matlCv9HOgA== X-Received: by 2002:adf:8385:: with SMTP id 5-v6mr20455436wre.13.1537456341176; Thu, 20 Sep 2018 08:12:21 -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.20 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 20 Sep 2018 08:12:20 -0700 (PDT) From: Miklos Szeredi To: David Howells Cc: Al Viro , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/6] selinux: fold superblock_doinit() into only caller Date: Thu, 20 Sep 2018 17:12:09 +0200 Message-Id: <20180920151214.15484-2-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 ...and remove the unused option parsing part as well. Signed-off-by: Miklos Szeredi --- security/selinux/hooks.c | 37 +++++++++---------------------------- 1 file changed, 9 insertions(+), 28 deletions(-) diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c index 99c2c40c5d7a..1069acea2682 100644 --- a/security/selinux/hooks.c +++ b/security/selinux/hooks.c @@ -1199,33 +1199,6 @@ static int selinux_parse_opts_str(char *options, kfree(rootcontext); return rc; } -/* - * string mount options parsing and call set the sbsec - */ -static int superblock_doinit(struct super_block *sb, void *data) -{ - int rc = 0; - char *options = data; - struct security_mnt_opts opts; - - security_init_mnt_opts(&opts); - - if (!data) - goto out; - - BUG_ON(sb->s_type->fs_flags & FS_BINARY_MOUNTDATA); - - rc = selinux_parse_opts_str(options, &opts); - if (rc) - goto out_err; - -out: - rc = selinux_set_mnt_opts(sb, &opts, 0, NULL); - -out_err: - security_free_mnt_opts(&opts); - return rc; -} static void selinux_write_opts(struct seq_file *m, struct security_mnt_opts *opts) @@ -7370,7 +7343,15 @@ static __init int selinux_init(void) static void delayed_superblock_init(struct super_block *sb, void *unused) { - superblock_doinit(sb, NULL); +{ + int rc; + struct security_mnt_opts opts; + + security_init_mnt_opts(&opts); + rc = selinux_set_mnt_opts(sb, &opts, 0, NULL); + security_free_mnt_opts(&opts); + + return rc; } void selinux_complete_init(void) From patchwork Thu Sep 20 15:12:10 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miklos Szeredi X-Patchwork-Id: 10607949 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 5BCCC112B for ; Thu, 20 Sep 2018 15:12:50 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4D326289D8 for ; Thu, 20 Sep 2018 15:12:50 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4BC8D2DC43; Thu, 20 Sep 2018 15:12:50 +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 009CF289D8 for ; Thu, 20 Sep 2018 15:12:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387757AbeITU4U (ORCPT ); Thu, 20 Sep 2018 16:56:20 -0400 Received: from mail-wr1-f65.google.com ([209.85.221.65]:43499 "EHLO mail-wr1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732393AbeITU4T (ORCPT ); Thu, 20 Sep 2018 16:56:19 -0400 Received: by mail-wr1-f65.google.com with SMTP id k5-v6so9770216wre.10 for ; Thu, 20 Sep 2018 08:12:23 -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=1noejrIq0y1SALjSjxufjZflcUxpMLy32j0L3bEsGuM=; b=Bx2GGUhVqFIGCBzScuZOTmyNfGg+SEq+JnwwUY5pLE8kE8GWoo0BjO6sYTCZ5zpUcr s+KHY8wJAK1+p/BP/CUBK0WhIN8R+VbOClb8wi3tdP8NzeWfOojsotKptv0czPFm/DNV u6hCpMyOz8rZzppWH3x2iLD4nBOfR6pkR3L6NFmpwuKBjAPFTYaBE7mdXdZFv8FKt7S6 k0GLC7IVR9Sq+X9uJUQNtBEAWbUN4oCfFLudwJhvlBbCsx5aQlthlUBALnmHS5KnyM5D 9a1fmCiG669ze8sHiin+pLTHKobYZ5+6EcoQ9Kp4OFPi5lcHTjEx2dfXq7RJ2QICyBl9 1HZQ== X-Gm-Message-State: ABuFfogXfsMWtRcOiqTytKo/VyVBPRBGgN/hhmiszEPRyB5dYxENVq5t 9w/YiFUWw8CB7n0d7B66kKN7hw== X-Google-Smtp-Source: ACcGV621PbIi5/hsdxOfuRVMoo+XMyRk8rWjyobAaqfwxQQzcmZ4WPv+2Lf0pZxrLzC7fXna6i0wHg== X-Received: by 2002:a5d:4143:: with SMTP id c3-v6mr4474134wrq.61.1537456342725; Thu, 20 Sep 2018 08:12:22 -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.21 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 20 Sep 2018 08:12:21 -0700 (PDT) From: Miklos Szeredi To: David Howells Cc: Al Viro , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/6] vfs_submount: use SB_SUBMOUNT instead of MS_SUBMOUNT Date: Thu, 20 Sep 2018 17:12:10 +0200 Message-Id: <20180920151214.15484-3-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 The latter is for the legacy userspace API only and should not be used internally. Signed-off-by: Miklos Szeredi --- fs/namespace.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/namespace.c b/fs/namespace.c index a28b713164bf..865b6f2c5e7d 100644 --- a/fs/namespace.c +++ b/fs/namespace.c @@ -3297,7 +3297,7 @@ vfs_submount(const struct dentry *mountpoint, struct file_system_type *type, if (mountpoint->d_sb->s_user_ns != &init_user_ns) return ERR_PTR(-EPERM); - return vfs_kern_mount(type, MS_SUBMOUNT, name, data, data_size); + return vfs_kern_mount(type, SB_SUBMOUNT, name, data, data_size); } EXPORT_SYMBOL_GPL(vfs_submount); 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) From patchwork Thu Sep 20 15:12:12 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miklos Szeredi X-Patchwork-Id: 10607945 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 AFBCC112B for ; Thu, 20 Sep 2018 15:12:44 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A04162DC4A for ; Thu, 20 Sep 2018 15:12:44 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9E6412DC6E; Thu, 20 Sep 2018 15:12:44 +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 3FA962DC57 for ; Thu, 20 Sep 2018 15:12:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1733254AbeITU4W (ORCPT ); Thu, 20 Sep 2018 16:56:22 -0400 Received: from mail-wr1-f68.google.com ([209.85.221.68]:35427 "EHLO mail-wr1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731135AbeITU4W (ORCPT ); Thu, 20 Sep 2018 16:56:22 -0400 Received: by mail-wr1-f68.google.com with SMTP id j26-v6so9797283wre.2 for ; Thu, 20 Sep 2018 08:12:25 -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=T/YPwrXVykLx5hkpqsiA0MJqO4coa4bJc+RtjykLZQc=; b=oJClxKKiAPzT9naeGCshhWrEtyMyFkXjOHtP5ZGZAcLlS8pXAm+P+AfQUsI7+ZCXFC yT6lefDMFo77YSKnULrKo0UEqJVlDv4mZxSyh1fxSRoeu/Pl4h4bcDe6I3JoNmjLgIn8 hZ95goDnBVP8XzEjvkQ5ipJrF+v0ubdxKVh0IgVnWC/pAJ87vn9IEQc5kX+etE6iScLb ZGdk0FF9+m9SFYJU+LH3kvZ2hOzlmlC8hJNU+8wo7JfED0u1IboDT4C2L72ATuI7kNts iWNEpxD1gXGW+3gTRsAx0nTaDd/T2vtpkcma8pIC0YLbO7C/sYPFUB/QWZ7qH7+vlgWP X3Ig== X-Gm-Message-State: APzg51C4nyOlsMAkFn/jBHkBHv7Ku1HptDSo463IRoBIbeUGuEJoBn1C 2DHxaaQ7hMV7oE+sNINMoJcy6w== X-Google-Smtp-Source: ANB0VdaQVigOZt82X6lLMv0ssWlVBmVNEpsMS63HE3GQMp2f5FCgwmIyZe3q2hR9fbCsf4D1oVEpWg== X-Received: by 2002:a5d:5450:: with SMTP id w16-v6mr35387051wrv.4.1537456345235; Thu, 20 Sep 2018 08:12:25 -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.23 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 20 Sep 2018 08:12:24 -0700 (PDT) From: Miklos Szeredi To: David Howells Cc: Al Viro , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 4/6] fsconfig: parse "subtype" param for old internal API Date: Thu, 20 Sep 2018 17:12:12 +0200 Message-Id: <20180920151214.15484-5-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 This subtype thing is specific to "fuse" and "fuseblk" filesystems. When these are switched over to the new context API, the handling of this parameter can be moved from legacy_parse_param() into fuse. Signed-off-by: Miklos Szeredi --- fs/fs_context.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/fs/fs_context.c b/fs/fs_context.c index c0ecbb1ecdfe..0192456712d2 100644 --- a/fs/fs_context.c +++ b/fs/fs_context.c @@ -574,6 +574,16 @@ static int legacy_parse_param(struct fs_context *fc, struct fs_parameter *param) param->string = NULL; return 0; } + if ((fc->fs_type->fs_flags & FS_HAS_SUBTYPE) && + strcmp(param->key, "subtype") == 0) { + if (param->type != fs_value_is_string) + return invalf(fc, "VFS: Legacy: Non-string subtype"); + if (fc->subtype) + return invalf(fc, "VFS: Legacy: Multiple subtype"); + fc->subtype = param->string; + param->string= NULL; + return 0; + } if (ctx->param_type != LEGACY_FS_UNSET_PARAMS && ctx->param_type != LEGACY_FS_INDIVIDUAL_PARAMS) From patchwork Thu Sep 20 15:12:13 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miklos Szeredi X-Patchwork-Id: 10607947 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 CCF671390 for ; Thu, 20 Sep 2018 15:12:44 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BEBAC2DC4A for ; Thu, 20 Sep 2018 15:12:44 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BD09A2DC57; Thu, 20 Sep 2018 15:12:44 +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 0EC8A2DC52 for ; Thu, 20 Sep 2018 15:12:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1733296AbeITU4Z (ORCPT ); Thu, 20 Sep 2018 16:56:25 -0400 Received: from mail-wr1-f67.google.com ([209.85.221.67]:37625 "EHLO mail-wr1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1733288AbeITU4Z (ORCPT ); Thu, 20 Sep 2018 16:56:25 -0400 Received: by mail-wr1-f67.google.com with SMTP id u12-v6so9781580wrr.4 for ; Thu, 20 Sep 2018 08:12:28 -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=BggGwWKGXXokyu52K8wXFItmEMyNGicA2mykH7uClkQ=; b=MsSjlMowLkgxoNDeQ0JcnoDKpIrWWZd9mEbA0I29uwrCn1cgHwyrfbmGyyOwo7efeO kjpS8+QbbXHTxRUgzGm7OSocXJr0J0+ugi1Pme+firikxvH1n+wZk+a260zS42uqRKUV VobX9KtbW5LRL2g+IjX4lKy/0Ekf3rAsgpZvYKJBotzGlaGiUBvPQw5FH5Iy1zzFU4Ud 22FzWGDwsJV/unsnSEEL9w+XlWoH+Ump4Jnz9tGhYfSxO4Ep/3Usiqc1uaIhwcuyJCcu XCWZZFNCa/TszKuVlkoq8oCERbPQ7uWZcw+IyHM3rWxyn1fRewGcK1QWpROdmvSmSwXF 4Crg== X-Gm-Message-State: APzg51BVm4vVEYuUO3/RJ/v62NL+Y7WnkfTphVndyfATmo8qwhH8rX4X Arx16yszfjSFhcdkU1PxtjQ/Tw== X-Google-Smtp-Source: ANB0VdZWeack8Wqr8qRmg3+MsnuP6z7UD4KW/3EoHRPXM+Ijqd1f4QQBvUe2yQbv9ZttwN/AL7igYw== X-Received: by 2002:a5d:4849:: with SMTP id n9-v6mr14803189wrs.234.1537456347866; Thu, 20 Sep 2018 08:12:27 -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.26 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 20 Sep 2018 08:12:27 -0700 (PDT) From: Miklos Szeredi To: David Howells Cc: Al Viro , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 5/6] fsmount: do not use legacy MS_ flags Date: Thu, 20 Sep 2018 17:12:13 +0200 Message-Id: <20180920151214.15484-6-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 What happens if we introduce new flags for fsmount(2) and are already out of flags for mount(2)? I see a big mess that way. So let's instead start a clean new set, to be used in the new API. The MS_RELATIME flag was accepted but ignored. Simply leave this out of the new set, since "relatime" is the default. The MNT_ prefix is already used by libmount, and we don't want any confusion arising from that. MOUNT_ feels a bit too long, so just go with the short and sweet M_ prefix. Signed-off-by: Miklos Szeredi --- fs/namespace.c | 28 +++++++++++++--------------- include/uapi/linux/mount.h | 9 +++++++++ 2 files changed, 22 insertions(+), 15 deletions(-) diff --git a/fs/namespace.c b/fs/namespace.c index 7671c1f6fc22..027b99b993c0 100644 --- a/fs/namespace.c +++ b/fs/namespace.c @@ -3332,7 +3332,7 @@ EXPORT_SYMBOL_GPL(kern_mount); * Create a kernel mount representation for a new, prepared superblock * (specified by fs_fd) and attach to an open_tree-like file descriptor. */ -SYSCALL_DEFINE3(fsmount, int, fs_fd, unsigned int, flags, unsigned int, ms_flags) +SYSCALL_DEFINE3(fsmount, int, fs_fd, unsigned int, flags, unsigned int, m_flags) { struct fs_context *fc; struct file *file; @@ -3347,30 +3347,28 @@ SYSCALL_DEFINE3(fsmount, int, fs_fd, unsigned int, flags, unsigned int, ms_flags if ((flags & ~(FSMOUNT_CLOEXEC)) != 0) return -EINVAL; - if (ms_flags & ~(MS_RDONLY | MS_NOSUID | MS_NODEV | MS_NOEXEC | - MS_NOATIME | MS_NODIRATIME | MS_RELATIME | - MS_STRICTATIME)) + if (m_flags & ~(M_RDONLY | M_NOSUID | M_NODEV | M_NOEXEC | + M_NOATIME | M_STRICTATIME | M_NODIRATIME)) return -EINVAL; - if (ms_flags & MS_RDONLY) + if ((m_flags & M_STRICTATIME) && (m_flags & M_NOATIME)) + return -EINVAL; + + if (m_flags & M_RDONLY) mnt_flags |= MNT_READONLY; - if (ms_flags & MS_NOSUID) + if (m_flags & M_NOSUID) mnt_flags |= MNT_NOSUID; - if (ms_flags & MS_NODEV) + if (m_flags & M_NODEV) mnt_flags |= MNT_NODEV; - if (ms_flags & MS_NOEXEC) + if (m_flags & M_NOEXEC) mnt_flags |= MNT_NOEXEC; - if (ms_flags & MS_NODIRATIME) + if (m_flags & M_NODIRATIME) mnt_flags |= MNT_NODIRATIME; - if (ms_flags & MS_STRICTATIME) { - if (ms_flags & MS_NOATIME) - return -EINVAL; - } else if (ms_flags & MS_NOATIME) { + if (m_flags & M_NOATIME) mnt_flags |= MNT_NOATIME; - } else { + else if (!(m_flags & M_STRICTATIME)) mnt_flags |= MNT_RELATIME; - } f = fdget(fs_fd); if (!f.file) diff --git a/include/uapi/linux/mount.h b/include/uapi/linux/mount.h index 3634e065836c..fce3513fc242 100644 --- a/include/uapi/linux/mount.h +++ b/include/uapi/linux/mount.h @@ -1,6 +1,15 @@ #ifndef _UAPI_LINUX_MOUNT_H #define _UAPI_LINUX_MOUNT_H +/* Mount flags passed to fsmount(2) */ +#define M_RDONLY 0x01 +#define M_NOSUID 0x02 +#define M_NODEV 0x04 +#define M_NOEXEC 0x08 +#define M_NOATIME 0x10 +#define M_STRICTATIME 0x20 +#define M_NODIRATIME 0x40 + /* * These are the fs-independent mount-flags: up to 32 flags are supported * From patchwork Thu Sep 20 15:12:14 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miklos Szeredi X-Patchwork-Id: 10607943 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 40AFC112B for ; Thu, 20 Sep 2018 15:12:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3127C2DC43 for ; Thu, 20 Sep 2018 15:12:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2F5622DC00; Thu, 20 Sep 2018 15:12:38 +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 B87702DBD9 for ; Thu, 20 Sep 2018 15:12:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387800AbeITU41 (ORCPT ); Thu, 20 Sep 2018 16:56:27 -0400 Received: from mail-wm1-f67.google.com ([209.85.128.67]:36833 "EHLO mail-wm1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1733291AbeITU40 (ORCPT ); Thu, 20 Sep 2018 16:56:26 -0400 Received: by mail-wm1-f67.google.com with SMTP id j192-v6so11543025wmj.1 for ; Thu, 20 Sep 2018 08:12:30 -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=IVfCHCWltHby4LkZUP1IHTTHkaGRqyiEBRTXLSOUhA8=; b=UWnLz1CW6KM1yCBuM6lQWKLzD6mQPp/siGZHi/pKsr/rcwgYZ1yEtyjwCDrD0H76Zo SuJ9ZoVijkSFyYbxll3tbh4zptE0wiIi2dL0Hb/xvLIFDCbBhrFDYB382yRL5c4hidDi TP5R9n19RAYCP9LBqaOvDKDluB+CRtY7ZcmxXUWpko8khcPgTkcAOGSEZJHinTczxXkV /VkkVljX44lgQCk257X/5nAPIhKRIm87YqTVN3Le7GcfF1VlAMf+L5Rsp9OKz/bPlCUJ LUvwbf64PZO62baS6vm2CTYozTFyXKGpu1prhgtfWH1dC1vod018GViV/EW4AYRC6RLF ozeQ== X-Gm-Message-State: APzg51ABe/R5hkzZ12iJBvHcfFjrmrNIrg2lcFfQ2xoA++O6rszeEcpl 2F9mtq1sC/aK0oLS+BHgI8896w== X-Google-Smtp-Source: ANB0Vdb2/c1Ewj7xGqP8c3nCRRDeZ1eNh93H9kCtIc1ziv7EtEqfdB7uMEx/sFTu+zJQOOW6uWR72A== X-Received: by 2002:a1c:bc87:: with SMTP id m129-v6mr3043187wmf.158.1537456349445; Thu, 20 Sep 2018 08:12:29 -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.27 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 20 Sep 2018 08:12:28 -0700 (PDT) From: Miklos Szeredi To: David Howells Cc: Al Viro , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 6/6] fsconfig: rename FSCONFIG_CMD_CREATE to FSCONFIG_CMD_OBTAIN Date: Thu, 20 Sep 2018 17:12:14 +0200 Message-Id: <20180920151214.15484-7-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 The old name strongly implies that a new superblock will be created from the fs_context. This is not true: filesystems are free to retuse an existing superblock and return that (for good reason). To avoid confusion, rename this command to something more appropriate. Signed-off-by: Miklos Szeredi --- fs/fsopen.c | 6 +++--- include/uapi/linux/fs.h | 2 +- samples/vfs/test-fsmount.c | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/fs/fsopen.c b/fs/fsopen.c index 9ead9220e2cb..bf1ff70b1fe2 100644 --- a/fs/fsopen.c +++ b/fs/fsopen.c @@ -311,7 +311,7 @@ static int vfs_fsconfig_action(struct fs_context *fc, enum fsconfig_command cmd) int ret = -EINVAL; switch (cmd) { - case FSCONFIG_CMD_CREATE: + case FSCONFIG_CMD_OBTAIN: if (fc->phase != FS_CONTEXT_CREATE_PARAMS) return -EBUSY; fc->phase = FS_CONTEXT_CREATING; @@ -434,7 +434,7 @@ SYSCALL_DEFINE5(fsconfig, if (!_key || _value || aux < 0) return -EINVAL; break; - case FSCONFIG_CMD_CREATE: + case FSCONFIG_CMD_OBTAIN: case FSCONFIG_CMD_RECONFIGURE: if (_key || _value || aux) return -EINVAL; @@ -523,7 +523,7 @@ SYSCALL_DEFINE5(fsconfig, ret = mutex_lock_interruptible(&fc->uapi_mutex); if (ret == 0) { switch (cmd) { - case FSCONFIG_CMD_CREATE: + case FSCONFIG_CMD_OBTAIN: case FSCONFIG_CMD_RECONFIGURE: ret = vfs_fsconfig_action(fc, cmd); break; diff --git a/include/uapi/linux/fs.h b/include/uapi/linux/fs.h index 7f01503a9e9b..169642bb2656 100644 --- a/include/uapi/linux/fs.h +++ b/include/uapi/linux/fs.h @@ -366,7 +366,7 @@ enum fsconfig_command { FSCONFIG_SET_PATH = 3, /* Set parameter, supplying an object by path */ FSCONFIG_SET_PATH_EMPTY = 4, /* Set parameter, supplying an object by (empty) path */ FSCONFIG_SET_FD = 5, /* Set parameter, supplying an object by fd */ - FSCONFIG_CMD_CREATE = 6, /* Invoke superblock creation */ + FSCONFIG_CMD_OBTAIN = 6, /* Obtain new or existing superblock */ FSCONFIG_CMD_RECONFIGURE = 7, /* Invoke superblock reconfiguration */ }; diff --git a/samples/vfs/test-fsmount.c b/samples/vfs/test-fsmount.c index 74124025ade0..a161dc530a91 100644 --- a/samples/vfs/test-fsmount.c +++ b/samples/vfs/test-fsmount.c @@ -101,7 +101,7 @@ int main(int argc, char *argv[]) } E_fsconfig(fsfd, FSCONFIG_SET_STRING, "source", "#grand.central.org:root.cell.", 0); - E_fsconfig(fsfd, FSCONFIG_CMD_CREATE, NULL, NULL, 0); + E_fsconfig(fsfd, FSCONFIG_CMD_OBTAIN, NULL, NULL, 0); mfd = fsmount(fsfd, 0, MS_RDONLY); if (mfd < 0)