From patchwork Tue Aug 21 09:55:05 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 10571303 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 B947C921 for ; Tue, 21 Aug 2018 09:55:13 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A613C29CF5 for ; Tue, 21 Aug 2018 09:55:13 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9A53129D40; Tue, 21 Aug 2018 09:55:13 +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 4609029CF5 for ; Tue, 21 Aug 2018 09:55:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727051AbeHUNOg (ORCPT ); Tue, 21 Aug 2018 09:14:36 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:32818 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726755AbeHUNOg (ORCPT ); Tue, 21 Aug 2018 09:14:36 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id DAB47401EF05; Tue, 21 Aug 2018 09:55:06 +0000 (UTC) Received: from warthog.procyon.org.uk (ovpn-123-147.rdu2.redhat.com [10.10.123.147]) by smtp.corp.redhat.com (Postfix) with ESMTP id 52A8C112D163; Tue, 21 Aug 2018 09:55:06 +0000 (UTC) Organization: Red Hat UK Ltd. Registered Address: Red Hat UK Ltd, Amberley Place, 107-111 Peascod Street, Windsor, Berkshire, SI4 1TE, United Kingdom. Registered in England and Wales under Company Registration No. 3798903 Subject: [PATCH 1/6] vfs: Fix vfs_dup_fs_context() From: David Howells To: viro@zeniv.linux.org.uk Cc: dhowells@redhat.com, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Date: Tue, 21 Aug 2018 10:55:05 +0100 Message-ID: <153484530575.1183.124318951692100857.stgit@warthog.procyon.org.uk> In-Reply-To: <153484529922.1183.17405985592221413059.stgit@warthog.procyon.org.uk> References: <153484529922.1183.17405985592221413059.stgit@warthog.procyon.org.uk> User-Agent: StGit/unknown-version MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Tue, 21 Aug 2018 09:55:06 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Tue, 21 Aug 2018 09:55:06 +0000 (UTC) for IP:'10.11.54.3' DOMAIN:'int-mx03.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'dhowells@redhat.com' RCPT:'' 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 vfs_dup_fs_context() allocates the wrong type of structure and as a result ends up with one that's too small. This isn't a problem at this time as nothing uses vfs_dup_fs_context() yet (until nfs and btrfs conversions come along). Fixes: ad3e21240b41 ("vfs: Implement a filesystem superblock creation/configuration context") Signed-off-by: David Howells --- fs/fs_context.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/fs_context.c b/fs/fs_context.c index a6597a2fbf2b..14921b2c1e42 100644 --- a/fs/fs_context.c +++ b/fs/fs_context.c @@ -348,7 +348,7 @@ struct fs_context *vfs_dup_fs_context(struct fs_context *src_fc) if (!src_fc->ops->dup) return ERR_PTR(-EOPNOTSUPP); - fc = kmemdup(src_fc, sizeof(struct legacy_fs_context), GFP_KERNEL); + fc = kmemdup(src_fc, sizeof(struct fs_context), GFP_KERNEL); if (!fc) return ERR_PTR(-ENOMEM); From patchwork Tue Aug 21 09:55:12 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 10571305 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 9A92E921 for ; Tue, 21 Aug 2018 09:55:21 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 87BC829CF5 for ; Tue, 21 Aug 2018 09:55:21 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7BF9029D40; Tue, 21 Aug 2018 09:55:21 +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 1F82029CF5 for ; Tue, 21 Aug 2018 09:55:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727084AbeHUNOm (ORCPT ); Tue, 21 Aug 2018 09:14:42 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:34810 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726755AbeHUNOm (ORCPT ); Tue, 21 Aug 2018 09:14:42 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 13E25402178A; Tue, 21 Aug 2018 09:55:13 +0000 (UTC) Received: from warthog.procyon.org.uk (ovpn-123-147.rdu2.redhat.com [10.10.123.147]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8289D10CD63A; Tue, 21 Aug 2018 09:55:12 +0000 (UTC) Organization: Red Hat UK Ltd. Registered Address: Red Hat UK Ltd, Amberley Place, 107-111 Peascod Street, Windsor, Berkshire, SI4 1TE, United Kingdom. Registered in England and Wales under Company Registration No. 3798903 Subject: [PATCH 2/6] vfs: Fix fs_context logging when there's no log From: David Howells To: viro@zeniv.linux.org.uk Cc: dhowells@redhat.com, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Date: Tue, 21 Aug 2018 10:55:12 +0100 Message-ID: <153484531201.1183.24087901695718354.stgit@warthog.procyon.org.uk> In-Reply-To: <153484529922.1183.17405985592221413059.stgit@warthog.procyon.org.uk> References: <153484529922.1183.17405985592221413059.stgit@warthog.procyon.org.uk> User-Agent: StGit/unknown-version MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.7]); Tue, 21 Aug 2018 09:55:13 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.7]); Tue, 21 Aug 2018 09:55:13 +0000 (UTC) for IP:'10.11.54.3' DOMAIN:'int-mx03.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'dhowells@redhat.com' RCPT:'' 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 If an fs_context-based mount is called from mount(2) or some other place that doesn't set up the logging-through-fd, then under some circumstances an oops will occur due to the log being unconditionally accessed in logfc(). Fix this by checking whether there is a log structure before attempting to access it Fixes: 06b830edff9f ("vfs: Implement logging through fs_context") Signed-off-by: David Howells --- fs/fs_context.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/fs_context.c b/fs/fs_context.c index 14921b2c1e42..053b8d0f11ea 100644 --- a/fs/fs_context.c +++ b/fs/fs_context.c @@ -416,7 +416,7 @@ void logfc(struct fs_context *fc, const char *fmt, ...) if ((unsigned long)p >= (unsigned long)__start_rodata && (unsigned long)p < (unsigned long)__end_rodata) goto const_string; - if (within_module_core((unsigned long)p, log->owner)) + if (log && within_module_core((unsigned long)p, log->owner)) goto const_string; q = kstrdup(p, GFP_KERNEL); goto copied_string; From patchwork Tue Aug 21 09:55:18 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 10571309 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 8BF42139B for ; Tue, 21 Aug 2018 09:55:26 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 791F829CF5 for ; Tue, 21 Aug 2018 09:55:26 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6D3BC29D40; Tue, 21 Aug 2018 09:55:26 +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 21BD529CF5 for ; Tue, 21 Aug 2018 09:55:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727152AbeHUNOt (ORCPT ); Tue, 21 Aug 2018 09:14:49 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:42708 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726755AbeHUNOs (ORCPT ); Tue, 21 Aug 2018 09:14:48 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 455D17D84D; Tue, 21 Aug 2018 09:55:19 +0000 (UTC) Received: from warthog.procyon.org.uk (ovpn-123-147.rdu2.redhat.com [10.10.123.147]) by smtp.corp.redhat.com (Postfix) with ESMTP id B5857112D163; Tue, 21 Aug 2018 09:55:18 +0000 (UTC) Organization: Red Hat UK Ltd. Registered Address: Red Hat UK Ltd, Amberley Place, 107-111 Peascod Street, Windsor, Berkshire, SI4 1TE, United Kingdom. Registered in England and Wales under Company Registration No. 3798903 Subject: [PATCH 3/6] afs: Move the source fs parameter to the first position From: David Howells To: viro@zeniv.linux.org.uk Cc: dhowells@redhat.com, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Date: Tue, 21 Aug 2018 10:55:18 +0100 Message-ID: <153484531821.1183.17951530333694057258.stgit@warthog.procyon.org.uk> In-Reply-To: <153484529922.1183.17405985592221413059.stgit@warthog.procyon.org.uk> References: <153484529922.1183.17405985592221413059.stgit@warthog.procyon.org.uk> User-Agent: StGit/unknown-version MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Tue, 21 Aug 2018 09:55:19 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Tue, 21 Aug 2018 09:55:19 +0000 (UTC) for IP:'10.11.54.3' DOMAIN:'int-mx03.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'dhowells@redhat.com' RCPT:'' 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 Move the source fs parameter to the first position in the parameter list, numerically speaking. Note that it isn't moved in the key string table as that's a sorted list. Signed-off-by: David Howells --- fs/afs/super.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/fs/afs/super.c b/fs/afs/super.c index 7c97836e7937..15c5eb9412bb 100644 --- a/fs/afs/super.c +++ b/fs/afs/super.c @@ -68,16 +68,16 @@ static struct kmem_cache *afs_inode_cachep; static atomic_t afs_count_active_inodes; enum afs_param { + Opt_source, Opt_autocell, Opt_dyn, - Opt_source, nr__afs_params }; static const struct fs_parameter_spec afs_param_specs[nr__afs_params] = { + [Opt_source] = { fs_param_is_string }, [Opt_autocell] = { fs_param_takes_no_value }, [Opt_dyn] = { fs_param_takes_no_value }, - [Opt_source] = { fs_param_is_string }, }; static const struct constant_table afs_param_keys[] = { @@ -900,14 +900,6 @@ static int afs_get_fsinfo(struct dentry *dentry, struct fsinfo_kparams *params) if (params->Mth) return -ENODATA; switch (params->Nth) { - case Opt_autocell: - if (as->autocell) - str = "autocell"; - goto string; - case Opt_dyn: - if (dyn_root) - str = "dyn"; - goto string; case Opt_source: if (dyn_root) return 0; @@ -918,6 +910,14 @@ static int afs_get_fsinfo(struct dentry *dentry, struct fsinfo_kparams *params) volume->type == AFSVL_RWVOL ? "" : volume->type == AFSVL_ROVOL ? ".readonly" : ".backup"); + case Opt_autocell: + if (as->autocell) + str = "autocell"; + goto string; + case Opt_dyn: + if (dyn_root) + str = "dyn"; + goto string; default: return -ENODATA; } From patchwork Tue Aug 21 09:55:24 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 10571311 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 09517139B for ; Tue, 21 Aug 2018 09:55:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EAA1F29CF5 for ; Tue, 21 Aug 2018 09:55:33 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DF04029D40; Tue, 21 Aug 2018 09:55:33 +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 3798A29CF5 for ; Tue, 21 Aug 2018 09:55:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727189AbeHUNO4 (ORCPT ); Tue, 21 Aug 2018 09:14:56 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:32822 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726755AbeHUNOz (ORCPT ); Tue, 21 Aug 2018 09:14:55 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 98DFB40216FA; Tue, 21 Aug 2018 09:55:25 +0000 (UTC) Received: from warthog.procyon.org.uk (ovpn-123-147.rdu2.redhat.com [10.10.123.147]) by smtp.corp.redhat.com (Postfix) with ESMTP id EC4DF2157F49; Tue, 21 Aug 2018 09:55:24 +0000 (UTC) Organization: Red Hat UK Ltd. Registered Address: Red Hat UK Ltd, Amberley Place, 107-111 Peascod Street, Windsor, Berkshire, SI4 1TE, United Kingdom. Registered in England and Wales under Company Registration No. 3798903 Subject: [PATCH 4/6] vfs: Pass path info fsinfo and rename get_fsinfo sb op to fsinfo From: David Howells To: viro@zeniv.linux.org.uk Cc: dhowells@redhat.com, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Date: Tue, 21 Aug 2018 10:55:24 +0100 Message-ID: <153484532442.1183.7584783993663542714.stgit@warthog.procyon.org.uk> In-Reply-To: <153484529922.1183.17405985592221413059.stgit@warthog.procyon.org.uk> References: <153484529922.1183.17405985592221413059.stgit@warthog.procyon.org.uk> User-Agent: StGit/unknown-version MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Tue, 21 Aug 2018 09:55:25 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Tue, 21 Aug 2018 09:55:25 +0000 (UTC) for IP:'10.11.54.6' DOMAIN:'int-mx06.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'dhowells@redhat.com' RCPT:'' 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 Pass the path, not just the dentry, into the superblock get_fsinfo operation because s->s_root isn't useful on NFS for retrocalculating the source name, but rather mnt->mnt_root must be used. Further, rename the ->get_fsinfo() superblock op to ->fsinfo() for consistency. Signed-off-by: David Howells --- fs/afs/super.c | 9 +++++---- fs/hugetlbfs/inode.c | 7 ++++--- fs/kernfs/mount.c | 8 ++++---- fs/statfs.c | 15 ++++++++------- include/linux/fs.h | 4 ++-- include/linux/fsinfo.h | 2 +- 6 files changed, 24 insertions(+), 21 deletions(-) diff --git a/fs/afs/super.c b/fs/afs/super.c index 15c5eb9412bb..0afff582eb99 100644 --- a/fs/afs/super.c +++ b/fs/afs/super.c @@ -35,7 +35,7 @@ static void afs_kill_super(struct super_block *sb); static struct inode *afs_alloc_inode(struct super_block *sb); static void afs_destroy_inode(struct inode *inode); static int afs_statfs(struct dentry *dentry, struct kstatfs *buf); -static int afs_get_fsinfo(struct dentry *dentry, struct fsinfo_kparams *params); +static int afs_fsinfo(struct path *path, struct fsinfo_kparams *params); static int afs_show_devname(struct seq_file *m, struct dentry *root); static int afs_show_options(struct seq_file *m, struct dentry *root); static int afs_init_fs_context(struct fs_context *fc, struct dentry *reference); @@ -55,7 +55,7 @@ int afs_net_id; static const struct super_operations afs_super_ops = { .statfs = afs_statfs, - .get_fsinfo = afs_get_fsinfo, + .fsinfo = afs_fsinfo, .alloc_inode = afs_alloc_inode, .drop_inode = afs_drop_inode, .destroy_inode = afs_destroy_inode, @@ -778,12 +778,13 @@ static int afs_statfs(struct dentry *dentry, struct kstatfs *buf) /* * Get filesystem information. */ -static int afs_get_fsinfo(struct dentry *dentry, struct fsinfo_kparams *params) +static int afs_fsinfo(struct path *path, struct fsinfo_kparams *params) { struct fsinfo_timestamp_info *tsinfo; struct fsinfo_server_address *addr; struct fsinfo_capabilities *caps; struct fsinfo_supports *sup; + struct dentry *dentry = path->dentry; struct afs_server_list *slist; struct afs_super_info *as = AFS_FS_S(dentry->d_sb); struct afs_addr_list *alist; @@ -923,7 +924,7 @@ static int afs_get_fsinfo(struct dentry *dentry, struct fsinfo_kparams *params) } default: - return generic_fsinfo(dentry, params); + return generic_fsinfo(path, params); } string: diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c index e2378c8ce7e0..e4f7619e9541 100644 --- a/fs/hugetlbfs/inode.c +++ b/fs/hugetlbfs/inode.c @@ -949,8 +949,9 @@ static int hugetlbfs_show_options(struct seq_file *m, struct dentry *root) return 0; } -static int hugetlbfs_get_fsinfo(struct dentry *dentry, struct fsinfo_kparams *params) +static int hugetlbfs_fsinfo(struct path *path, struct fsinfo_kparams *params) { + struct dentry *dentry = path->dentry; struct hugetlbfs_sb_info *sbinfo = HUGETLBFS_SB(dentry->d_sb); struct hugepage_subpool *spool = sbinfo->spool; unsigned long hpage_size = huge_page_size(sbinfo->hstate); @@ -1008,7 +1009,7 @@ static int hugetlbfs_get_fsinfo(struct dentry *dentry, struct fsinfo_kparams *pa return -ENODATA; } default: - return generic_fsinfo(dentry, params); + return generic_fsinfo(path, params); } } @@ -1171,7 +1172,7 @@ static const struct super_operations hugetlbfs_ops = { .statfs = hugetlbfs_statfs, .put_super = hugetlbfs_put_super, .show_options = hugetlbfs_show_options, - .get_fsinfo = hugetlbfs_get_fsinfo, + .fsinfo = hugetlbfs_fsinfo, }; /* diff --git a/fs/kernfs/mount.c b/fs/kernfs/mount.c index b568e6c5e063..6194ad7a817c 100644 --- a/fs/kernfs/mount.c +++ b/fs/kernfs/mount.c @@ -56,9 +56,9 @@ static int kernfs_sop_show_path(struct seq_file *sf, struct dentry *dentry) return 0; } -static int kernfs_sop_get_fsinfo(struct dentry *dentry, struct fsinfo_kparams *params) +static int kernfs_sop_fsinfo(struct path *path, struct fsinfo_kparams *params) { - struct kernfs_root *root = kernfs_root(kernfs_dentry_node(dentry)); + struct kernfs_root *root = kernfs_root(kernfs_dentry_node(path->dentry)); struct kernfs_syscall_ops *scops = root->syscall_ops; int ret; @@ -67,7 +67,7 @@ static int kernfs_sop_get_fsinfo(struct dentry *dentry, struct fsinfo_kparams *p if (ret != -EAGAIN) return ret; } - return generic_fsinfo(dentry, params); + return generic_fsinfo(path, params); } const struct super_operations kernfs_sops = { @@ -78,7 +78,7 @@ const struct super_operations kernfs_sops = { .reconfigure = kernfs_sop_reconfigure, .show_options = kernfs_sop_show_options, .show_path = kernfs_sop_show_path, - .get_fsinfo = kernfs_sop_get_fsinfo, + .fsinfo = kernfs_sop_fsinfo, }; /* diff --git a/fs/statfs.c b/fs/statfs.c index 6bb95808ee66..95fdfd9a79d1 100644 --- a/fs/statfs.c +++ b/fs/statfs.c @@ -627,8 +627,9 @@ static int fsinfo_generic_param_enum(struct file_system_type *f, /* * Implement some queries generically from stuff in the superblock. */ -int generic_fsinfo(struct dentry *dentry, struct fsinfo_kparams *params) +int generic_fsinfo(struct path *path, struct fsinfo_kparams *params) { + struct dentry *dentry = path->dentry; struct file_system_type *f = dentry->d_sb->s_type; #define _gen(X, Y) FSINFO_ATTR_##X: return fsinfo_generic_##Y(dentry, params->buffer) @@ -659,10 +660,10 @@ EXPORT_SYMBOL(generic_fsinfo); * Retrieve the filesystem info. We make some stuff up if the operation is not * supported. */ -int vfs_fsinfo(const struct path *path, struct fsinfo_kparams *params) +int vfs_fsinfo(struct path *path, struct fsinfo_kparams *params) { struct dentry *dentry = path->dentry; - int (*get_fsinfo)(struct dentry *, struct fsinfo_kparams *); + int (*fsinfo)(struct path *, struct fsinfo_kparams *); int ret; if (params->request == FSINFO_ATTR_FSINFO) { @@ -673,18 +674,18 @@ int vfs_fsinfo(const struct path *path, struct fsinfo_kparams *params) return sizeof(*info); } - get_fsinfo = dentry->d_sb->s_op->get_fsinfo; - if (!get_fsinfo) { + fsinfo = dentry->d_sb->s_op->fsinfo; + if (!fsinfo) { if (!dentry->d_sb->s_op->statfs) return -EOPNOTSUPP; - get_fsinfo = generic_fsinfo; + fsinfo = generic_fsinfo; } ret = security_sb_statfs(dentry); if (ret) return ret; - ret = get_fsinfo(dentry, params); + ret = fsinfo(path, params); if (ret < 0) return ret; diff --git a/include/linux/fs.h b/include/linux/fs.h index 053d53861995..b9b5ba36033c 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -1851,7 +1851,7 @@ struct super_operations { int (*thaw_super) (struct super_block *); int (*unfreeze_fs) (struct super_block *); int (*statfs) (struct dentry *, struct kstatfs *); - int (*get_fsinfo) (struct dentry *, struct fsinfo_kparams *); + int (*fsinfo) (struct path *, struct fsinfo_kparams *); int (*remount_fs) (struct super_block *, int *, char *, size_t); int (*reconfigure) (struct super_block *, struct fs_context *); void (*umount_begin) (struct super_block *); @@ -2229,7 +2229,7 @@ extern int iterate_mounts(int (*)(struct vfsmount *, void *), void *, extern int vfs_statfs(const struct path *, struct kstatfs *); extern int user_statfs(const char __user *, struct kstatfs *); extern int fd_statfs(int, struct kstatfs *); -extern int vfs_fsinfo(const struct path *, struct fsinfo_kparams *); +extern int vfs_fsinfo(struct path *, struct fsinfo_kparams *); extern int freeze_super(struct super_block *super); extern int thaw_super(struct super_block *super); extern bool our_mnt(struct vfsmount *mnt); diff --git a/include/linux/fsinfo.h b/include/linux/fsinfo.h index f2d25b898d48..e488701c5c04 100644 --- a/include/linux/fsinfo.h +++ b/include/linux/fsinfo.h @@ -24,7 +24,7 @@ struct fsinfo_kparams { size_t buf_size; /* Size of the buffer */ }; -extern int generic_fsinfo(struct dentry *, struct fsinfo_kparams *); +extern int generic_fsinfo(struct path *, struct fsinfo_kparams *); static inline void fsinfo_set_cap(struct fsinfo_capabilities *c, enum fsinfo_capability cap) From patchwork Tue Aug 21 09:55:30 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 10571313 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 5496A139B for ; Tue, 21 Aug 2018 09:55:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 40B6229CF5 for ; Tue, 21 Aug 2018 09:55:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 350AD29D40; Tue, 21 Aug 2018 09:55:40 +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 D768D29CF5 for ; Tue, 21 Aug 2018 09:55:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726981AbeHUNPB (ORCPT ); Tue, 21 Aug 2018 09:15:01 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:60048 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726798AbeHUNPA (ORCPT ); Tue, 21 Aug 2018 09:15:00 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C7E65EC006; Tue, 21 Aug 2018 09:55:31 +0000 (UTC) Received: from warthog.procyon.org.uk (ovpn-123-147.rdu2.redhat.com [10.10.123.147]) by smtp.corp.redhat.com (Postfix) with ESMTP id 447172026D64; Tue, 21 Aug 2018 09:55:31 +0000 (UTC) Organization: Red Hat UK Ltd. Registered Address: Red Hat UK Ltd, Amberley Place, 107-111 Peascod Street, Windsor, Berkshire, SI4 1TE, United Kingdom. Registered in England and Wales under Company Registration No. 3798903 Subject: [PATCH 5/6] vfs: Adjust fsinfo sample output From: David Howells To: viro@zeniv.linux.org.uk Cc: dhowells@redhat.com, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Date: Tue, 21 Aug 2018 10:55:30 +0100 Message-ID: <153484533075.1183.12355648565791228863.stgit@warthog.procyon.org.uk> In-Reply-To: <153484529922.1183.17405985592221413059.stgit@warthog.procyon.org.uk> References: <153484529922.1183.17405985592221413059.stgit@warthog.procyon.org.uk> User-Agent: StGit/unknown-version MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.1]); Tue, 21 Aug 2018 09:55:31 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.1]); Tue, 21 Aug 2018 09:55:31 +0000 (UTC) for IP:'10.11.54.4' DOMAIN:'int-mx04.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'dhowells@redhat.com' RCPT:'' 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 Adjust the output of the test-fsinfo sample program to: (1) Print server addresses if of AF_INET or AF_INET6 family. (2) Not print parameter descriptions (the test-fs-query sample program can be used for that). (3) Only print non-blank parameter values so that parameters that just encode defaults don't clutter up the output. Signed-off-by: David Howells --- samples/statx/test-fsinfo.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/samples/statx/test-fsinfo.c b/samples/statx/test-fsinfo.c index 21714ef7ef5b..c08978acf08b 100644 --- a/samples/statx/test-fsinfo.c +++ b/samples/statx/test-fsinfo.c @@ -26,6 +26,7 @@ #include #include #include +#include static bool debug = 0; @@ -304,6 +305,24 @@ static void dump_attr_VOLUME_UUID(union reply *r, int size) static void dump_attr_SERVER_ADDRESS(union reply *r, int size) { struct fsinfo_server_address *f = &r->srv_addr; + struct sockaddr_in6 *sin6; + struct sockaddr_in *sin; + char buf[1024]; + + switch (f->address.ss_family) { + case AF_INET: + sin = (struct sockaddr_in *)&f->address; + if (!inet_ntop(AF_INET, &sin->sin_addr, buf, sizeof(buf))) + break; + printf("IPv4: %s\n", buf); + return; + case AF_INET6: + sin6 = (struct sockaddr_in6 *)&f->address; + if (!inet_ntop(AF_INET6, &sin6->sin6_addr, buf, sizeof(buf))) + break; + printf("IPv6: %s\n", buf); + return; + } printf("family=%u\n", f->address.ss_family); } @@ -426,6 +445,17 @@ static int try_one(const char *file, struct fsinfo_params *params, bool raw) return 0; } + switch (params->request) { + case FSINFO_ATTR_PARAM_DESCRIPTION: + case FSINFO_ATTR_PARAM_SPECIFICATION: + case FSINFO_ATTR_PARAM_NAME: + case FSINFO_ATTR_PARAM_ENUM: + return 0; + case FSINFO_ATTR_PARAMETER: + if (ret == 0) + return 0; + } + switch (about & 0xc000) { case 0x0000: printf("\e[33m%s\e[m: ", From patchwork Tue Aug 21 09:55:37 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 10571315 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 14A27139B for ; Tue, 21 Aug 2018 09:55:47 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0180729D40 for ; Tue, 21 Aug 2018 09:55:47 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EA27529D4C; Tue, 21 Aug 2018 09:55:46 +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 9359929D40 for ; Tue, 21 Aug 2018 09:55:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727076AbeHUNPI (ORCPT ); Tue, 21 Aug 2018 09:15:08 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:34818 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726755AbeHUNPH (ORCPT ); Tue, 21 Aug 2018 09:15:07 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 21DD74075180; Tue, 21 Aug 2018 09:55:38 +0000 (UTC) Received: from warthog.procyon.org.uk (ovpn-123-147.rdu2.redhat.com [10.10.123.147]) by smtp.corp.redhat.com (Postfix) with ESMTP id 740562157F49; Tue, 21 Aug 2018 09:55:37 +0000 (UTC) Organization: Red Hat UK Ltd. Registered Address: Red Hat UK Ltd, Amberley Place, 107-111 Peascod Street, Windsor, Berkshire, SI4 1TE, United Kingdom. Registered in England and Wales under Company Registration No. 3798903 Subject: [PATCH 6/6] proc: Set correct userns for new proc super created by a new pid_namespace From: David Howells To: viro@zeniv.linux.org.uk Cc: Andrei Vagin , dhowells@redhat.com, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Date: Tue, 21 Aug 2018 10:55:37 +0100 Message-ID: <153484533695.1183.7796797839895873922.stgit@warthog.procyon.org.uk> In-Reply-To: <153484529922.1183.17405985592221413059.stgit@warthog.procyon.org.uk> References: <153484529922.1183.17405985592221413059.stgit@warthog.procyon.org.uk> User-Agent: StGit/unknown-version MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.7]); Tue, 21 Aug 2018 09:55:38 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.7]); Tue, 21 Aug 2018 09:55:38 +0000 (UTC) for IP:'10.11.54.6' DOMAIN:'int-mx06.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'dhowells@redhat.com' RCPT:'' 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 From: Andrei Vagin Fix the setting up a new proc superblock for a new pid_namespace such that the user_ns for that proc superblock needs to be taken from the new pid_namespace and not the active process. Signed-off-by: Andrei Vagin Signed-off-by: David Howells --- fs/proc/root.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/fs/proc/root.c b/fs/proc/root.c index 1d6e5bfa30cc..1419b48a89ab 100644 --- a/fs/proc/root.c +++ b/fs/proc/root.c @@ -315,6 +315,11 @@ int pid_ns_prepare_proc(struct pid_namespace *ns) if (IS_ERR(fc)) return PTR_ERR(fc); + if (fc->user_ns != ns->user_ns) { + put_user_ns(fc->user_ns); + fc->user_ns = get_user_ns(ns->user_ns); + } + ctx = fc->fs_private; if (ctx->pid_ns != ns) { put_pid_ns(ctx->pid_ns);