Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp4901879rwb; Wed, 17 Aug 2022 07:53:37 -0700 (PDT) X-Google-Smtp-Source: AA6agR5bcm3uTS5Gdz/yP4UPjxiKrD+EVV6jQcgpucj2sXjXvthfwZwp/lj5oDsuA7Hw2Ms8+dmO X-Received: by 2002:a05:6402:5203:b0:43d:444b:9f99 with SMTP id s3-20020a056402520300b0043d444b9f99mr24062801edd.343.1660748007138; Wed, 17 Aug 2022 07:53:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660748007; cv=none; d=google.com; s=arc-20160816; b=sPu3Ucq07HXggKifFQFeP6cdIvrvjKPE67OlZrALm+dJkkOls52QpY/sL2txkXtGa4 BsgbajKjX01brVqUFoiPNqSukCsWIlp5FtIoxu7SsI/Mhjg6ySTg/IprHolMMoiyC4V3 y6nol6AxFwMP9rlOgcHhQdfO5kDGmPbrdJcqNKNhWTTjMYUkdmHVKDdv0jbriKcHvVNm fUlfCSbZt5AXEzZ7NbXD9VnSkmqgjnh0SgW48OWEibiLiqVdC5egVLSA4m4NrzJ8FNDS 59iy6TZdP0e0vQ4+1lpCR1xAAxWdHeVXepE6m/CKjTau8HxCPf8HDznngS5M4lE2MFX+ +dPQ== 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 :dkim-signature; bh=Ci/l+oJ2hlAsRJOTtN5Ym+rTxP3jH6w4L9DWyAnNO5s=; b=yvERaPQ6X3DtO1X62PjE6FNiaOFWd+18DN5aJf1buG+YBV0QzD3fpzWl9ylf4n0nb2 yxi4rM8nNo33cx4vrs02SkFa3XaC5YXeLoZxzScLbOa0z5e0fl3ZhHFJxS1VnBhbVI77 rEn02j0NaUL76R5lYw51Iz60/QXPPwzouPag1/KjBxiPPyQIPCr+0t7r3QD7pqSSCD3k o00DBmMndUAllPsPTxvhZDLuBIuKM/Ka6sqPMtnvI69wQlhoYt8cV0XO8YSKu2BEgnAW 31EUmkckOIeamzKQB9/ZyQrXqWpuIUt4ZuVY598rEJWBraS4376Gooa+zeSI5DAZYFgs /46A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.org.uk header.s=zeniv-20220401 header.b=kqvrMuMq; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=zeniv.linux.org.uk Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id au16-20020a170907093000b007364913fc71si1350112ejc.384.2022.08.17.07.53.00; Wed, 17 Aug 2022 07:53:27 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.org.uk header.s=zeniv-20220401 header.b=kqvrMuMq; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=zeniv.linux.org.uk Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236204AbiHQOc1 (ORCPT + 99 others); Wed, 17 Aug 2022 10:32:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57414 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237205AbiHQOcP (ORCPT ); Wed, 17 Aug 2022 10:32:15 -0400 Received: from zeniv.linux.org.uk (zeniv.linux.org.uk [IPv6:2a03:a000:7:0:5054:ff:fe1c:15ff]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F2EF89676C for ; Wed, 17 Aug 2022 07:32:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=linux.org.uk; s=zeniv-20220401; h=Sender:In-Reply-To:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=Ci/l+oJ2hlAsRJOTtN5Ym+rTxP3jH6w4L9DWyAnNO5s=; b=kqvrMuMqEGhoSnMRwHTyieN5hi oNJwGcdEvn2+JXgNxDvz9G8nqXYsxtOciMl6t1za+cI5jFHl6CDAhquxE+b752NZcO5NKfwHQDIcb B9Z6x7LMD2ZCxIGNZcZsfZzA+d/Zyb2aNeqSL0/8MY0CxgIkEqa1toTz6ZdLaYv5rJJ2WUyQx15UB ZPBjljHiSQ5Vjly+ZdCQkktTE7EvHzjO4gpR3x+/+WAHHv5biqeduAWAvzh7vim2Kz1vvo+B5mfjY 3TG1y+WvEB0QQ4/gl6GCUWHQqzqOUiTEkxI8OIqbdKklo+KUo5xFF/vE3E6TBZMZvftReFol6Glyp GiV10RhQ==; Received: from viro by zeniv.linux.org.uk with local (Exim 4.95 #2 (Red Hat Linux)) id 1oOK5T-005OCZ-5v; Wed, 17 Aug 2022 14:32:03 +0000 Date: Wed, 17 Aug 2022 15:32:03 +0100 From: Al Viro To: Christian Brauner Cc: Greg Kroah-Hartman , Dongliang Mu , Dongliang Mu , Arve =?iso-8859-1?B?SGr4bm5lduVn?= , Todd Kjos , Martijn Coenen , Joel Fernandes , Carlos Llamas , Suren Baghdasaryan , Kees Cook , syzkaller , linux-kernel Subject: Re: [PATCH] binderfs: rework superblock destruction Message-ID: References: <20220817130306.96978-1-brauner@kernel.org> <20220817140149.pfakskeyxkqcot54@wittgenstein> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Sender: Al Viro X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Aug 17, 2022 at 03:19:13PM +0100, Al Viro wrote: > On Wed, Aug 17, 2022 at 04:01:49PM +0200, Christian Brauner wrote: > > On Wed, Aug 17, 2022 at 02:59:02PM +0100, Al Viro wrote: > > > On Wed, Aug 17, 2022 at 03:03:06PM +0200, Christian Brauner wrote: > > > > > > > +static void binderfs_kill_super(struct super_block *sb) > > > > +{ > > > > + struct binderfs_info *info = sb->s_fs_info; > > > > + > > > > + if (info && info->ipc_ns) > > > > + put_ipc_ns(info->ipc_ns); > > > > + > > > > + kfree(info); > > > > + kill_litter_super(sb); > > > > +} > > > > > > Other way round, please - shut the superblock down, *then* > > > free the objects it'd been using. IOW, > > > > I wondered about that but a lot of places do it the other way around. > > So maybe the expected order should be documented somewhere. > > ??? > > "If you are holding internal references to dentries/inodes/etc., drop them > first; if you are going to free something that is used by filesystem > methods, don't do that before the filesystem is shut down" > > That's just common sense... Which filesystems are doing that "the other > way around"? Note that something like e.g. ramfs, where we have a dynamically allocated object ->s_fs_info is pointing to and gets freed early in their ->kill_sb() is somewhat misleading - it's used only for two things, one is the creation of root directory inode (obviously not going to happen at any point after mount) and another - ->show_options(). By the point we get around to killing a superblock, it would better *NOT* have mounts pointing to it that might show up in /proc/mounts and make us call ->show_options(). So there we really know that nothing during the shutdown will even look at that thing we'd just freed. Not that there'd ever been a point allocating it - all that object contains is one unsigned short, so we might as well just have stored (void *)root_mode in ->s_fs_info. Oh, well...