From patchwork Mon Feb 7 13:27:28 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Domenico Andreoli X-Patchwork-Id: 12737219 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 71C65C433EF for ; Mon, 7 Feb 2022 13:27:34 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A2E916B0074; Mon, 7 Feb 2022 08:27:33 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 9B76A6B0075; Mon, 7 Feb 2022 08:27:33 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 808846B0078; Mon, 7 Feb 2022 08:27:33 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0059.hostedemail.com [216.40.44.59]) by kanga.kvack.org (Postfix) with ESMTP id 6BB756B0075 for ; Mon, 7 Feb 2022 08:27:33 -0500 (EST) Received: from smtpin12.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 19C08181F24B3 for ; Mon, 7 Feb 2022 13:27:33 +0000 (UTC) X-FDA: 79116060786.12.F54E803 Received: from mail-ej1-f49.google.com (mail-ej1-f49.google.com [209.85.218.49]) by imf03.hostedemail.com (Postfix) with ESMTP id 748AF20006; Mon, 7 Feb 2022 13:27:32 +0000 (UTC) Received: by mail-ej1-f49.google.com with SMTP id a8so42025615ejc.8; Mon, 07 Feb 2022 05:27:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=sender:date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=uodRgi0lSvjfu6z/loPgCdPJcwfTd50pHHEutx7a7FU=; b=GOkuyBYFBgK7TrBFV7AaPdglSjAc9h7eSRY4Vn43CJi87x2sGC2JrvOL79WmgPPF/a 8HQLM/ySYk9O1Y7qZdIa60UODXU0Smf1aUvLNN0PPcEWAvmZxk/x5FPmFeJzSaNPIvGi VjNVSR6bx3GwOlp3M3yFXx9pIdrE6g/XqeIe0bOSubz3pxs9FfFxNmR+v9GOmlO7vHTD wa4EzWuoIb9nmdNlbv5BPvJiGwK2NqqvMlalkuUDKBVjvPNsi8jc0PCs4BuZ10WcXDJ+ 50ZKZ/Om8/K7NkCv7WC9SdOCzoZERiYveT9d5FCIyKn4PA5EvLJadw9MgvhBZ1QLrcjD uIqw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:sender:date:from:to:cc:subject:message-id :references:mime-version:content-disposition:in-reply-to; bh=uodRgi0lSvjfu6z/loPgCdPJcwfTd50pHHEutx7a7FU=; b=tZx6NGl4hZSsV3/60Cmng5sI/zFwY35MOG/hljqwufgdt+6MFAwF+jFVgKOwdkgo3Z o76lxjjebDjPiR1x+EywgA5tB/YZZlAExnhLUzrPCcA9k5DxC/03pEfgHVr42es/u2ks IcHKE9aQ4oN6S53ZDbdhY58yd4bHYr2Dch9Nog2D4xEixyN4iglfyrCLDFP2xNAN7Pzb wSxLMocMCkgHeLFjrlFf7VPO51XiaCLz6ByPP6+682/RDP1A0Tll8wYxz3/OVz99BEr9 UpdfI4XnCYAZw0yvKyG2gfYTP6DlgvNpfZrJwbmqG0rgVtXoAskA2IZcBLXSCfdWdrZC YTQg== X-Gm-Message-State: AOAM533oKw4tmhAyOoCYhjCIsVKRYGVBYedBiBEBEmotbkrd8N3aZ1dD vURdvsDujkgoUJSI6luWnsA= X-Google-Smtp-Source: ABdhPJwO2cWoWb2zHzBal8Bo+vfe+9ev1QdE8F6uXO4YWA/GdnWjQziOhW/5NX3D8Y0V8NGNxSArvA== X-Received: by 2002:a17:906:f156:: with SMTP id gw22mr7510658ejb.321.1644240450800; Mon, 07 Feb 2022 05:27:30 -0800 (PST) Received: from dumbo (tor-exit-13.zbau.f3netze.de. [2a0b:f4c0:16c:13::1]) by smtp.gmail.com with ESMTPSA id a18sm5215946edu.31.2022.02.07.05.27.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Feb 2022 05:27:30 -0800 (PST) Received: from cavok by dumbo with local (Exim 4.94.2) (envelope-from ) id 1nH43E-0002H6-41; Mon, 07 Feb 2022 14:27:28 +0100 Date: Mon, 7 Feb 2022 14:27:28 +0100 From: Domenico Andreoli To: 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, ebiederm@xmission.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, mcgrof@kernel.org, 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 Cc: linux-kernel@vger.kernel.org Subject: [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-Disposition: inline In-Reply-To: <20220122061228.nmuo75sDn%akpm@linux-foundation.org> X-Rspam-User: nil X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: 748AF20006 X-Stat-Signature: kq5hs7hmt9yf94c39ha34bn46uc149td Authentication-Results: imf03.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=GOkuyBYF; spf=pass (imf03.hostedemail.com: domain of domenico.andreoli.it@gmail.com designates 209.85.218.49 as permitted sender) smtp.mailfrom=domenico.andreoli.it@gmail.com; dmarc=none X-HE-Tag: 1644240452-97807 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: 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; } static void __exit exit_misc_binfmt(void) { - unregister_sysctl_table(binfmt_misc_header); unregister_binfmt(&misc_format); unregister_filesystem(&bm_fs_type); } Index: b/kernel/sysctl.c =================================================================== --- a/kernel/sysctl.c +++ b/kernel/sysctl.c @@ -2806,6 +2806,17 @@ static struct ctl_table vm_table[] = { { } }; +static struct ctl_table fs_table[] = { +#if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE) + { + .procname = "binfmt_misc", + .mode = 0555, + .child = sysctl_mount_point, + }, +#endif + { } +}; + static struct ctl_table debug_table[] = { #ifdef CONFIG_SYSCTL_EXCEPTION_TRACE { @@ -2825,6 +2836,7 @@ static struct ctl_table dev_table[] = { DECLARE_SYSCTL_BASE(kernel, kern_table); DECLARE_SYSCTL_BASE(vm, vm_table); +DECLARE_SYSCTL_BASE(fs, fs_table); DECLARE_SYSCTL_BASE(debug, debug_table); DECLARE_SYSCTL_BASE(dev, dev_table); @@ -2832,6 +2844,7 @@ int __init sysctl_init_bases(void) { register_sysctl_base(kernel); register_sysctl_base(vm); + register_sysctl_base(fs); register_sysctl_base(debug); register_sysctl_base(dev);