Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp3181222ybl; Mon, 20 Jan 2020 17:50:33 -0800 (PST) X-Google-Smtp-Source: APXvYqwbXkyjFw1c2K8N4a+QIw7rtNTiqxoN70m7jDQg9yTA+wMcgxONHQ1g4S2hfMIjJUmlIMSk X-Received: by 2002:a9d:5c10:: with SMTP id o16mr1896438otk.286.1579571433284; Mon, 20 Jan 2020 17:50:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1579571433; cv=none; d=google.com; s=arc-20160816; b=cZ3SN4xUMUA7zpzfC824OVQlhtVzNRNl52ZP1cuR559mb+Rqhace14A9nmAmiCK0+U SElUV6cqKvCjsSOu1zTOErUKELdwPkKFJP47eUTS5iCAoJ2MROFOw8cbdC2g7g3gxKY4 nx34LhFRtydMY8U2Q2vuJjlHpd23rAOESaTT9PBx4xLRPgeDQ5Gg6Q2f6JIOnwX9wqk9 Vd1wodPQejlb+pwHGHwyWLYzkucLnvMsO5TazGQJP0QWgkLsmJhzfRLBBlHua6lL3cmM aJrRXN4FtNjUufGU9VOsHGeu3vYa2o2Q6/QvAj0ExSlwahajkAG9TwCXtBAlMfh7XeLn u4mQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=GZjJm4eYFyoL4yGY2KgheVv23EHxN5vykGqls+3gUbk=; b=wlA/PxcYT27VMnPXNQXuXNQTvvGzdyH5NK+cIB2boCINvuwqa5apGPqSfJGlW9gBUU Sm8sUxcVIWXyiXxFPCAWxfFe2KqANFWBCEUlyVwBG95aM+z2BGuDhlAkjLNW/IgxLLaw KPH/KDodrDkOYRJsWpxNCi5JaUxNJM+LRQE9DKqgohRLuDlUsKkakwov/GSKrZHCv7g5 rPoX6cIv9VkM6qFrBI6tZDlxhHJTIRSkFMj09fuznevmTR9HuaD6HTRJOssV3Eu645W9 yUc9MzvfOtCBRx2h0aqdjdoBBjIbGOexWmlmceSeLO0DC4E+67iWOlHLru8xYJPAp5oD YwLA== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s3si19305429oic.108.2020.01.20.17.50.20; Mon, 20 Jan 2020 17:50:33 -0800 (PST) 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728898AbgAUBt2 (ORCPT + 99 others); Mon, 20 Jan 2020 20:49:28 -0500 Received: from zeniv.linux.org.uk ([195.92.253.2]:57968 "EHLO ZenIV.linux.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728512AbgAUBt1 (ORCPT ); Mon, 20 Jan 2020 20:49:27 -0500 Received: from viro by ZenIV.linux.org.uk with local (Exim 4.92.3 #3 (Red Hat Linux)) id 1itifU-00CNBW-Pd; Tue, 21 Jan 2020 01:49:25 +0000 Date: Tue, 21 Jan 2020 01:49:24 +0000 From: Al Viro To: Namjae Jeon Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, gregkh@linuxfoundation.org, valdis.kletnieks@vt.edu, hch@lst.de, sj1557.seo@samsung.com, pali.rohar@gmail.com, arnd@arndb.de, namjae.jeon@samsung.com Subject: Re: [PATCH v12 02/13] exfat: add super block operations Message-ID: <20200121014924.GI8904@ZenIV.linux.org.uk> References: <20200120124428.17863-1-linkinjeon@gmail.com> <20200120124428.17863-3-linkinjeon@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200120124428.17863-3-linkinjeon@gmail.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jan 20, 2020 at 09:44:17PM +0900, Namjae Jeon wrote: > +static void exfat_put_super(struct super_block *sb) > +{ > + struct exfat_sb_info *sbi = EXFAT_SB(sb); > + > + mutex_lock(&sbi->s_lock); > + if (test_and_clear_bit(EXFAT_SB_DIRTY, &sbi->s_state)) > + sync_blockdev(sb->s_bdev); > + exfat_set_vol_flags(sb, VOL_CLEAN); > + exfat_free_upcase_table(sb); > + exfat_free_bitmap(sb); > + mutex_unlock(&sbi->s_lock); > + > + if (sbi->nls_io) { > + unload_nls(sbi->nls_io); > + sbi->nls_io = NULL; > + } > + exfat_free_iocharset(sbi); > + sb->s_fs_info = NULL; > + kfree(sbi); > +} You need to RCU-delay freeing sbi and zeroing ->nls_io. *Everything* used by ->d_compare() and ->d_hash() needs that treatment. RCU-mode pathwalk can stray into a filesystem that has already been lazy-umounted and is just one close() away from shutdown. It's OK, as long as you make sure that all structures used in methods that could be called in RCU mode (->d_compare(), ->d_hash(), rcu-case ->d_revalidate(), rcu-case ->permission()) have destruction RCU-delayed. Look at what VFAT is doing; that's precisely the reason for that delayed_free() thing in there. > +static void exfat_destroy_inode(struct inode *inode) > +{ > + kmem_cache_free(exfat_inode_cachep, EXFAT_I(inode)); > +} No. Again, that MUST be RCU-delayed; either put an explicit call_rcu() here, or leave as-is, but make that ->free_inode(). > +static void __exit exit_exfat_fs(void) > +{ > + kmem_cache_destroy(exfat_inode_cachep); > + unregister_filesystem(&exfat_fs_type); ... and add rcu_barrier() here. > + exfat_cache_shutdown();