From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id C848AC433EF for ; Mon, 7 Feb 2022 21:47:11 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 56A146B0071; Mon, 7 Feb 2022 16:47:11 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 4F1616B0075; Mon, 7 Feb 2022 16:47:11 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3941F6B0078; Mon, 7 Feb 2022 16:47:11 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0097.hostedemail.com [216.40.44.97]) by kanga.kvack.org (Postfix) with ESMTP id 2A4CD6B0071 for ; Mon, 7 Feb 2022 16:47:11 -0500 (EST) Received: from smtpin07.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id E2047181DF75B for ; Mon, 7 Feb 2022 21:47:10 +0000 (UTC) X-FDA: 79117319820.07.49BE446 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf09.hostedemail.com (Postfix) with ESMTP id 1A88A14000A; Mon, 7 Feb 2022 21:47:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; 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=WTLHsRuDo0Kmv8T0AeQW2bl2SYgMY9Rc1wnxTFKAxD8=; b=x9wSvaCIjxMdzhOVgZc4nT/gyv RjR4GoPq0LCzkRJmGgpdswZmkCBaFiV10tfDG74bxgZ6WgsIR0kLIJgP/sUaRNhsQ+kVMZNvHMhsM FR7Eb3r7P0zIi8cu46ZcOXWWRfYcnL2fgZt/TC+KC8KVnQQ4kZzSllTO9He835HE69PF62+MzOi+m FDscSzVw34q69OEZlDld6qvYkKLCigAccYzPWQ6XPfYuMhvlVzy3K5JU8oa2sR8gGQY988obVqPI8 RvKFTwufkBVa7BTgL36vKisl/p8q0iYp05GEircLU5DT0Xu6rT3KID6p0iKox07Az0gZJ0VYXmnuK POYLGxyA==; Received: from mcgrof by bombadil.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1nHBqT-00BnlU-8E; Mon, 07 Feb 2022 21:46:49 +0000 Date: Mon, 7 Feb 2022 13:46:49 -0800 From: Luis Chamberlain To: Domenico Andreoli , Tong Zhang , "Eric W. Biederman" Cc: airlied@linux.ie, akpm@linux-foundation.org, amir73il@gmail.com, andriy.shevchenko@linux.intel.com, arnd@arndb.de, bcrl@kvack.org, benh@kernel.crashing.org, clemens@ladisch.de, crope@iki.fi, dgilbert@interlog.com, gregkh@linuxfoundation.org, jack@suse.cz, jani.nikula@intel.com, jani.nikula@linux.intel.com, jejb@linux.ibm.com, jlbec@evilplan.org, john.ogness@linutronix.de, joonas.lahtinen@linux.intel.com, joseph.qi@linux.alibaba.com, julia.lawall@inria.fr, keescook@chromium.org, kernel@tuxforce.de, linux-mm@kvack.org, mark@fasheh.com, martin.petersen@oracle.com, mm-commits@vger.kernel.org, nixiaoming@huawei.com, penguin-kernel@i-love.sakura.ne.jp, peterz@infradead.org, phil@philpotter.co.uk, pjt@google.com, pmladek@suse.com, rafael@kernel.org, rodrigo.vivi@intel.com, rostedt@goodmis.org, senozhatsky@chromium.org, sre@kernel.org, steve@sk2.org, surenb@google.com, torvalds@linux-foundation.org, tytso@mit.edu, viro@zeniv.linux.org.uk, wangqing@vivo.com, yzaikin@google.com, linux-kernel@vger.kernel.org Subject: Re: [PATCH] Fix regression due to "fs: move binfmt_misc sysctl to its own file" Message-ID: References: <20220121221021.60533b009c357d660791476e@linux-foundation.org> <20220122061228.nmuo75sDn%akpm@linux-foundation.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Rspamd-Queue-Id: 1A88A14000A X-Rspam-User: nil Authentication-Results: imf09.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=x9wSvaCI; dmarc=fail reason="No valid SPF, DKIM not aligned (relaxed)" header.from=kernel.org (policy=none); spf=none (imf09.hostedemail.com: domain of mcgrof@infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=mcgrof@infradead.org X-Stat-Signature: 76tbxg4u5r3f6kjwbcz1m8yeo7y8m5y7 X-Rspamd-Server: rspam08 X-HE-Tag: 1644270429-433530 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Mon, Feb 07, 2022 at 02:27:28PM +0100, Domenico Andreoli wrote: > Commit 3ba442d5331f did not go unnoticed, binfmt-support stopped to > work on my Debian system since v5.17-rc2 (did not check with -rc1). > > The existance of /proc/sys/fs/binfmt_misc is a precondition for > attempting to mount the binfmt_misc fs, which in turn triggers the > autoload of the binfmt_misc module. Without it, no module is loaded > and no binfmt is available at boot. > > Building as built-in or manually loading the module and mounting the fs > works fine, it's therefore only a matter of interaction with user-space. > > I could try to improve the Debian systemd configuration but I can't > say anything about the other distributions. > > In the meanwhile this patch restores a working system right after boot. > > Fixes: 3ba442d5331f ("fs: move binfmt_misc sysctl to its own file") > Signed-off-by: Domenico Andreoli > Cc: Al Viro > Cc: Amir Goldstein > Cc: Andrew Morton > Cc: Andy Shevchenko > Cc: Antti Palosaari > Cc: Arnd Bergmann > Cc: Benjamin Herrenschmidt > Cc: Benjamin LaHaise > Cc: Clemens Ladisch > Cc: David Airlie > Cc: Douglas Gilbert > Cc: Eric Biederman > Cc: Greg Kroah-Hartman > Cc: Iurii Zaikin > Cc: James E.J. Bottomley > Cc: Jan Kara > Cc: Jani Nikula > Cc: Jani Nikula > Cc: Joel Becker > Cc: John Ogness > Cc: Joonas Lahtinen > Cc: Joseph Qi > Cc: Julia Lawall > Cc: Kees Cook > Cc: Lukas Middendorf > Cc: Luis Chamberlain > Cc: Mark Fasheh > Cc: Martin K. Petersen > Cc: Paul Turner > Cc: Peter Zijlstra > Cc: Petr Mladek > Cc: Phillip Potter > Cc: Qing Wang > Cc: "Rafael J. Wysocki" > Cc: Rodrigo Vivi > Cc: Sebastian Reichel > Cc: Sergey Senozhatsky > Cc: Stephen Kitt > Cc: Steven Rostedt (VMware) > Cc: Suren Baghdasaryan > Cc: Tetsuo Handa > Cc: "Theodore Ts'o" > Cc: Xiaoming Ni > > --- > fs/binfmt_misc.c | 6 +----- > kernel/sysctl.c | 13 +++++++++++++ > 2 files changed, 14 insertions(+), 5 deletions(-) > > Index: b/fs/binfmt_misc.c > =================================================================== > --- a/fs/binfmt_misc.c > +++ b/fs/binfmt_misc.c > @@ -817,20 +817,16 @@ static struct file_system_type bm_fs_typ > }; > MODULE_ALIAS_FS("binfmt_misc"); > > -static struct ctl_table_header *binfmt_misc_header; > - > static int __init init_misc_binfmt(void) > { > int err = register_filesystem(&bm_fs_type); > if (!err) > insert_binfmt(&misc_format); > - binfmt_misc_header = register_sysctl_mount_point("fs/binfmt_misc"); > - return 0; > + return err; > } OK I think the issue here should have been that declaring this on fs/binfmt_misc.c creates the chicken and the egg issue, and so we need to do this on built-in code. Instead of your patch can you try this instead, it just always creates the sysctl mount always now so long as proc sysctl is enabled. It does not do the unregistration as we always want the path present as it used to be before as well. diff --git a/fs/binfmt_misc.c b/fs/binfmt_misc.c index c07f35719ee3..4b8f1b11a7c8 100644 --- a/fs/binfmt_misc.c +++ b/fs/binfmt_misc.c @@ -817,20 +817,16 @@ static struct file_system_type bm_fs_type = { }; MODULE_ALIAS_FS("binfmt_misc"); -static struct ctl_table_header *binfmt_misc_header; - static int __init init_misc_binfmt(void) { int err = register_filesystem(&bm_fs_type); if (!err) insert_binfmt(&misc_format); - binfmt_misc_header = register_sysctl_mount_point("fs/binfmt_misc"); return 0; } static void __exit exit_misc_binfmt(void) { - unregister_sysctl_table(binfmt_misc_header); unregister_binfmt(&misc_format); unregister_filesystem(&bm_fs_type); } diff --git a/fs/file_table.c b/fs/file_table.c index 57edef16dce4..4f4739c9405c 100644 --- a/fs/file_table.c +++ b/fs/file_table.c @@ -119,6 +119,7 @@ static struct ctl_table fs_stat_sysctls[] = { static int __init init_fs_stat_sysctls(void) { register_sysctl_init("fs", fs_stat_sysctls); + register_sysctl_mount_point("fs/binfmt_misc"); return 0; } fs_initcall(init_fs_stat_sysctls);