From patchwork Sat Jan 12 00:00:24 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Kent X-Patchwork-Id: 10760805 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 920431390 for ; Sat, 12 Jan 2019 00:09:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 752A429DFB for ; Sat, 12 Jan 2019 00:09:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 694A629E10; Sat, 12 Jan 2019 00:09:52 +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 5D1F529DFB for ; Sat, 12 Jan 2019 00:09:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726282AbfALAJq (ORCPT ); Fri, 11 Jan 2019 19:09:46 -0500 Received: from icp-osb-irony-out3.external.iinet.net.au ([203.59.1.153]:46786 "EHLO icp-osb-irony-out3.external.iinet.net.au" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726193AbfALAJp (ORCPT ); Fri, 11 Jan 2019 19:09:45 -0500 X-Greylist: delayed 555 seconds by postgrey-1.27 at vger.kernel.org; Fri, 11 Jan 2019 19:09:45 EST X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A2ABAADXLDlc//yp0HYNVhoBAQEBAQIBAQEBBwIBAQEBgVEFAQEBAQsBgmmBKYQBiBqMPwEBBoEQg2uFaY5LgXsohEwDAoJNNAkNAQMBAQEBAQECgQmFWScEUigBBwUCJgJJFhODI4FpAwiuAHF8MxqHcQSCJoELgXOJWHiBB4FEhWSBRYNAglcCj3dJNpEFCYcaiwELAoFXiEgDD4c/nCmCDk0uCoMnCYpRhg9liAqCTQEB X-IPAS-Result: A2ABAADXLDlc//yp0HYNVhoBAQEBAQIBAQEBBwIBAQEBgVEFAQEBAQsBgmmBKYQBiBqMPwEBBoEQg2uFaY5LgXsohEwDAoJNNAkNAQMBAQEBAQECgQmFWScEUigBBwUCJgJJFhODI4FpAwiuAHF8MxqHcQSCJoELgXOJWHiBB4FEhWSBRYNAglcCj3dJNpEFCYcaiwELAoFXiEgDD4c/nCmCDk0uCoMnCYpRhg9liAqCTQEB X-IronPort-AV: E=Sophos;i="5.56,467,1539619200"; d="scan'208";a="155670348" Received: from unknown (HELO [192.168.1.228]) ([118.208.169.252]) by icp-osb-irony-out3.iinet.net.au with ESMTP; 12 Jan 2019 08:00:27 +0800 Subject: [PATCH 1/3] autofs: drop dentry reference only when it is never used From: Ian Kent To: Andrew Morton Cc: autofs mailing list , linux-fsdevel , Kernel Mailing List , Pan Bian Date: Sat, 12 Jan 2019 08:00:24 +0800 Message-ID: <154725122396.11260.16053424107144453867.stgit@pluto-themaw-net> User-Agent: StGit/unknown-version MIME-Version: 1.0 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: Pan Bian The function autofs_expire_run calls dput(dentry) to drop the reference count of dentry. However, dentry is read via autofs_dentry_ino(dentry) after that. This may result in a use-free-bug. The patch drops the reference count of dentry only when it is never used. Signed-off-by: Pan Bian Acked-by: Ian Kent --- fs/autofs/expire.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/fs/autofs/expire.c b/fs/autofs/expire.c index d441244b79df..28d9c2b1b3bb 100644 --- a/fs/autofs/expire.c +++ b/fs/autofs/expire.c @@ -596,7 +596,6 @@ int autofs_expire_run(struct super_block *sb, pkt.len = dentry->d_name.len; memcpy(pkt.name, dentry->d_name.name, pkt.len); pkt.name[pkt.len] = '\0'; - dput(dentry); if (copy_to_user(pkt_p, &pkt, sizeof(struct autofs_packet_expire))) ret = -EFAULT; @@ -609,6 +608,8 @@ int autofs_expire_run(struct super_block *sb, complete_all(&ino->expire_complete); spin_unlock(&sbi->fs_lock); + dput(dentry); + return ret; } From patchwork Sat Jan 12 00:00:33 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Kent X-Patchwork-Id: 10760807 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 E82B191E for ; Sat, 12 Jan 2019 00:09:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D61CB29DE3 for ; Sat, 12 Jan 2019 00:09:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CAB3129E05; Sat, 12 Jan 2019 00:09:57 +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 827E929DE3 for ; Sat, 12 Jan 2019 00:09:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726484AbfALAJw (ORCPT ); Fri, 11 Jan 2019 19:09:52 -0500 Received: from icp-osb-irony-out3.external.iinet.net.au ([203.59.1.153]:46786 "EHLO icp-osb-irony-out3.external.iinet.net.au" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726193AbfALAJv (ORCPT ); Fri, 11 Jan 2019 19:09:51 -0500 X-Greylist: delayed 555 seconds by postgrey-1.27 at vger.kernel.org; Fri, 11 Jan 2019 19:09:45 EST X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A2ANAADXLDlc//yp0HYNVhsBAQEBAwEBAQcDAQEBgVMEAQEBCwGEEoQBlFkBB4R7hWmJRIUHgXuEdAMCAoJLNgcNAQMBAQEBAQEChmACAQMjBFIQGAEMAiYCAkcQBhOFF64AcXwzGoobgQuBc4lYeIEHgRGEUwGDCINAglcCkEA2kQUJkhsLAoofA4dOLYJnmRwGggFNLgqDJ4InDAuOK2WICoJNAQE X-IPAS-Result: A2ANAADXLDlc//yp0HYNVhsBAQEBAwEBAQcDAQEBgVMEAQEBCwGEEoQBlFkBB4R7hWmJRIUHgXuEdAMCAoJLNgcNAQMBAQEBAQEChmACAQMjBFIQGAEMAiYCAkcQBhOFF64AcXwzGoobgQuBc4lYeIEHgRGEUwGDCINAglcCkEA2kQUJkhsLAoofA4dOLYJnmRwGggFNLgqDJ4InDAuOK2WICoJNAQE X-IronPort-AV: E=Sophos;i="5.56,467,1539619200"; d="scan'208";a="155670383" Received: from unknown (HELO [192.168.1.228]) ([118.208.169.252]) by icp-osb-irony-out3.iinet.net.au with ESMTP; 12 Jan 2019 08:00:34 +0800 Subject: [PATCH 2/3] autofs - fix error return in autofs_fill_super() From: Ian Kent To: Andrew Morton Cc: autofs mailing list , linux-fsdevel , Kernel Mailing List , Pan Bian Date: Sat, 12 Jan 2019 08:00:33 +0800 Message-ID: <154725123240.11260.796773942606871359.stgit@pluto-themaw-net> In-Reply-To: <154725122396.11260.16053424107144453867.stgit@pluto-themaw-net> References: <154725122396.11260.16053424107144453867.stgit@pluto-themaw-net> User-Agent: StGit/unknown-version MIME-Version: 1.0 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 In autofs_fill_super() on error of get inode/make root dentry the return should be ENOMEM as this is the only failure case of the called functions. Signed-off-by: Ian Kent --- fs/autofs/inode.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/fs/autofs/inode.c b/fs/autofs/inode.c index 0e8ea2d9a2bb..078992eee299 100644 --- a/fs/autofs/inode.c +++ b/fs/autofs/inode.c @@ -266,8 +266,10 @@ int autofs_fill_super(struct super_block *s, void *data, int silent) } root_inode = autofs_get_inode(s, S_IFDIR | 0755); root = d_make_root(root_inode); - if (!root) + if (!root) { + ret = -ENOMEM; goto fail_ino; + } pipe = NULL; root->d_fsdata = ino; From patchwork Sat Jan 12 00:00:40 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Kent X-Patchwork-Id: 10760809 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 D01D21390 for ; Sat, 12 Jan 2019 00:10:04 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B88D529DE3 for ; Sat, 12 Jan 2019 00:10:04 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A65A929E10; Sat, 12 Jan 2019 00:10:04 +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 36C6729DE3 for ; Sat, 12 Jan 2019 00:10:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726516AbfALAJ7 (ORCPT ); Fri, 11 Jan 2019 19:09:59 -0500 Received: from icp-osb-irony-out3.external.iinet.net.au ([203.59.1.153]:46786 "EHLO icp-osb-irony-out3.external.iinet.net.au" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726193AbfALAJ6 (ORCPT ); Fri, 11 Jan 2019 19:09:58 -0500 X-Greylist: delayed 555 seconds by postgrey-1.27 at vger.kernel.org; Fri, 11 Jan 2019 19:09:45 EST X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A2ASAADXLDlc//yp0HYNVhwBAQEEAQEHBAEBgVEHAQELAYQShAGIGow/AQEGgRCDa4VpjkuBe4R0AwICgks0CQ0BAwEBAQEBAQKGYAIBAyMEUhAYAQwCJgICRxAGE4UXrgBxfDMaihuBC4FziVh4gQeBETOKaYJXApBANpEFCZIbCwKKHwOHTpwpgg5NLgqDJ5BpZYpXAQE X-IPAS-Result: A2ASAADXLDlc//yp0HYNVhwBAQEEAQEHBAEBgVEHAQELAYQShAGIGow/AQEGgRCDa4VpjkuBe4R0AwICgks0CQ0BAwEBAQEBAQKGYAIBAyMEUhAYAQwCJgICRxAGE4UXrgBxfDMaihuBC4FziVh4gQeBETOKaYJXApBANpEFCZIbCwKKHwOHTpwpgg5NLgqDJ5BpZYpXAQE X-IronPort-AV: E=Sophos;i="5.56,467,1539619200"; d="scan'208";a="155670411" Received: from unknown (HELO [192.168.1.228]) ([118.208.169.252]) by icp-osb-irony-out3.iinet.net.au with ESMTP; 12 Jan 2019 08:00:41 +0800 Subject: [PATCH 3/3] autofs: add ignore mount option From: Ian Kent To: Andrew Morton Cc: autofs mailing list , linux-fsdevel , Kernel Mailing List , Pan Bian Date: Sat, 12 Jan 2019 08:00:40 +0800 Message-ID: <154725123970.11260.6113771566924907275.stgit@pluto-themaw-net> In-Reply-To: <154725122396.11260.16053424107144453867.stgit@pluto-themaw-net> References: <154725122396.11260.16053424107144453867.stgit@pluto-themaw-net> User-Agent: StGit/unknown-version MIME-Version: 1.0 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 Add an autofs file system mount option that can be used to provide a generic indicator to applications that the mount entry should be ignored when displaying mount information. Signed-off-by: Ian Kent --- fs/autofs/autofs_i.h | 1 + fs/autofs/inode.c | 9 ++++++++- include/uapi/linux/auto_fs.h | 2 +- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/fs/autofs/autofs_i.h b/fs/autofs/autofs_i.h index 3e59f0ed777b..b735f2b1e462 100644 --- a/fs/autofs/autofs_i.h +++ b/fs/autofs/autofs_i.h @@ -105,6 +105,7 @@ struct autofs_wait_queue { #define AUTOFS_SBI_CATATONIC 0x0001 #define AUTOFS_SBI_STRICTEXPIRE 0x0002 +#define AUTOFS_SBI_IGNORE 0x0004 struct autofs_sb_info { u32 magic; diff --git a/fs/autofs/inode.c b/fs/autofs/inode.c index 078992eee299..8647ecaa89fc 100644 --- a/fs/autofs/inode.c +++ b/fs/autofs/inode.c @@ -89,6 +89,8 @@ static int autofs_show_options(struct seq_file *m, struct dentry *root) seq_printf(m, ",indirect"); if (sbi->flags & AUTOFS_SBI_STRICTEXPIRE) seq_printf(m, ",strictexpire"); + if (sbi->flags & AUTOFS_SBI_IGNORE) + seq_printf(m, ",ignore"); #ifdef CONFIG_CHECKPOINT_RESTORE if (sbi->pipe) seq_printf(m, ",pipe_ino=%ld", file_inode(sbi->pipe)->i_ino); @@ -111,7 +113,8 @@ static const struct super_operations autofs_sops = { }; enum {Opt_err, Opt_fd, Opt_uid, Opt_gid, Opt_pgrp, Opt_minproto, Opt_maxproto, - Opt_indirect, Opt_direct, Opt_offset, Opt_strictexpire}; + Opt_indirect, Opt_direct, Opt_offset, Opt_strictexpire, + Opt_ignore}; static const match_table_t tokens = { {Opt_fd, "fd=%u"}, @@ -124,6 +127,7 @@ static const match_table_t tokens = { {Opt_direct, "direct"}, {Opt_offset, "offset"}, {Opt_strictexpire, "strictexpire"}, + {Opt_ignore, "ignore"}, {Opt_err, NULL} }; @@ -206,6 +210,9 @@ static int parse_options(char *options, case Opt_strictexpire: sbi->flags |= AUTOFS_SBI_STRICTEXPIRE; break; + case Opt_ignore: + sbi->flags |= AUTOFS_SBI_IGNORE; + break; default: return 1; } diff --git a/include/uapi/linux/auto_fs.h b/include/uapi/linux/auto_fs.h index 082119630b49..1f7925afad2d 100644 --- a/include/uapi/linux/auto_fs.h +++ b/include/uapi/linux/auto_fs.h @@ -23,7 +23,7 @@ #define AUTOFS_MIN_PROTO_VERSION 3 #define AUTOFS_MAX_PROTO_VERSION 5 -#define AUTOFS_PROTO_SUBVERSION 4 +#define AUTOFS_PROTO_SUBVERSION 5 /* * The wait_queue_token (autofs_wqt_t) is part of a structure which is passed