Skip to content
  1. Jan 22, 2022
    • Luis Chamberlain's avatar
      fs: move namespace sysctls and declare fs base directory · ab171b95
      Luis Chamberlain authored
      This moves the namespace sysctls to its own file as part of the
      kernel/sysctl.c spring cleaning
      
      Since we have now removed all sysctls for "fs", we now have to declare
      it on the filesystem code, we do that using the new helper, which
      reduces boiler plate code.
      
      We rename init_fs_shared_sysctls() to init_fs_sysctls() to reflect that
      now fs/sysctls.c is taking on the burden of being the first to register
      the base directory as well.
      
      Lastly, since init code will load in the order in which we link it we
      have to move the sysctl code to be linked in early, so that its early
      init routine runs prior to other fs code.  This way, other filesystem
      code can register their own sysctls using the helpers after this:
      
        * register_sysctl_init()
        * register_sysctl()
      
      Link: https://lkml.kernel.org/r/20211129211943.640266-3-mcgrof@kernel.org
      
      
      Signed-off-by: default avatarLuis Chamberlain <mcgrof@kernel.org>
      Cc: Al Viro <viro@zeniv.linux.org.uk>
      Cc: Anil S Keshavamurthy <anil.s.keshavamurthy@intel.com>
      Cc: Antti Palosaari <crope@iki.fi>
      Cc: Christian Brauner <christian.brauner@ubuntu.com>
      Cc: "David S. Miller" <davem@davemloft.net>
      Cc: Eric Biederman <ebiederm@xmission.com>
      Cc: Eric Biggers <ebiggers@google.com>
      Cc: Iurii Zaikin <yzaikin@google.com>
      Cc: Kees Cook <keescook@chromium.org>
      Cc: Lukas Middendorf <kernel@tuxforce.de>
      Cc: Masami Hiramatsu <mhiramat@kernel.org>
      Cc: "Naveen N. Rao" <naveen.n.rao@linux.ibm.com>
      Cc: Stephen Kitt <steve@sk2.org>
      Cc: Xiaoming Ni <nixiaoming@huawei.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      ab171b95
    • Luis Chamberlain's avatar
      sysctl: add and use base directory declarer and registration helper · 51cb8dfc
      Luis Chamberlain authored
      Patch series "sysctl: add and use base directory declarer and
      registration helper".
      
      In this patch series we start addressing base directories, and so we
      start with the "fs" sysctls.  The end goal is we end up completely
      moving all "fs" sysctl knobs out from kernel/sysctl.
      
      This patch (of 6):
      
      Add a set of helpers which can be used to declare and register base
      directory sysctls on their own.  We do this so we can later move each of
      the base sysctl directories like "fs", "kernel", etc, to their own
      respective files instead of shoving the declarations and registrations
      all on kernel/sysctl.c.  The lazy approach has caught up and with this,
      we just end up extending the list of base directories / sysctls on one
      file and this makes maintenance difficult due to merge conflicts from
      many developers.
      
      The declarations are used first by kernel/sysctl.c for registration its
      own base which over time we'll try to clean up.  It will be used in the
      next patch to demonstrate how to cleanly deal with base sysctl
      directories.
      
      [mcgrof@kernel.org: null-terminate the ctl_table arrays]
        Link: https://lkml.kernel.org/r/YafJY3rXDYnjK/gs@bombadil.infradead.org
      
      Link: https://lkml.kernel.org/r/20211129211943.640266-1-mcgrof@kernel.org
      Link: https://lkml.kernel.org/r/20211129211943.640266-2-mcgrof@kernel.org
      
      
      Signed-off-by: default avatarLuis Chamberlain <mcgrof@kernel.org>
      Cc: Al Viro <viro@zeniv.linux.org.uk>
      Cc: Kees Cook <keescook@chromium.org>
      Cc: Iurii Zaikin <yzaikin@google.com>
      Cc: Xiaoming Ni <nixiaoming@huawei.com>
      Cc: Eric Biederman <ebiederm@xmission.com>
      Cc: Stephen Kitt <steve@sk2.org>
      Cc: Lukas Middendorf <kernel@tuxforce.de>
      Cc: Antti Palosaari <crope@iki.fi>
      Cc: Christian Brauner <christian.brauner@ubuntu.com>
      Cc: Eric Biggers <ebiggers@google.com>
      Cc: "Naveen N. Rao" <naveen.n.rao@linux.ibm.com>
      Cc: "David S. Miller" <davem@davemloft.net>
      Cc: Masami Hiramatsu <mhiramat@kernel.org>
      Cc: Anil S Keshavamurthy <anil.s.keshavamurthy@intel.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      51cb8dfc
    • Luis Chamberlain's avatar
      fs: move pipe sysctls to is own file · 1998f193
      Luis Chamberlain authored
      kernel/sysctl.c is a kitchen sink where everyone leaves their dirty
      dishes, this makes it very difficult to maintain.
      
      To help with this maintenance let's start by moving sysctls to places
      where they actually belong.  The proc sysctl maintainers do not want to
      know what sysctl knobs you wish to add for your own piece of code, we
      just care about the core logic.
      
      So move the pipe sysctls to its own file.
      
      Link: https://lkml.kernel.org/r/20211129205548.605569-10-mcgrof@kernel.org
      
      
      Signed-off-by: default avatarLuis Chamberlain <mcgrof@kernel.org>
      Cc: Al Viro <viro@zeniv.linux.org.uk>
      Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
      Cc: Antti Palosaari <crope@iki.fi>
      Cc: Eric Biederman <ebiederm@xmission.com>
      Cc: Iurii Zaikin <yzaikin@google.com>
      Cc: "J. Bruce Fields" <bfields@fieldses.org>
      Cc: Jeff Layton <jlayton@kernel.org>
      Cc: Kees Cook <keescook@chromium.org>
      Cc: Lukas Middendorf <kernel@tuxforce.de>
      Cc: Stephen Kitt <steve@sk2.org>
      Cc: Xiaoming Ni <nixiaoming@huawei.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      1998f193
    • Luis Chamberlain's avatar
      fs: move fs/exec.c sysctls into its own file · 66ad3986
      Luis Chamberlain authored
      kernel/sysctl.c is a kitchen sink where everyone leaves their dirty
      dishes, this makes it very difficult to maintain.
      
      To help with this maintenance let's start by moving sysctls to places
      where they actually belong.  The proc sysctl maintainers do not want to
      know what sysctl knobs you wish to add for your own piece of code, we
      just care about the core logic.
      
      So move the fs/exec.c respective sysctls to its own file.
      
      Since checkpatch complains about style issues with the old code, this
      move also fixes a few of those minor style issues:
      
        * Use pr_warn() instead of prink(WARNING
        * New empty lines are wanted at the beginning of routines
      
      Link: https://lkml.kernel.org/r/20211129205548.605569-9-mcgrof@kernel.org
      
      
      Signed-off-by: default avatarLuis Chamberlain <mcgrof@kernel.org>
      Cc: Al Viro <viro@zeniv.linux.org.uk>
      Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
      Cc: Antti Palosaari <crope@iki.fi>
      Cc: Eric Biederman <ebiederm@xmission.com>
      Cc: Iurii Zaikin <yzaikin@google.com>
      Cc: "J. Bruce Fields" <bfields@fieldses.org>
      Cc: Jeff Layton <jlayton@kernel.org>
      Cc: Kees Cook <keescook@chromium.org>
      Cc: Lukas Middendorf <kernel@tuxforce.de>
      Cc: Stephen Kitt <steve@sk2.org>
      Cc: Xiaoming Ni <nixiaoming@huawei.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      66ad3986
    • Luis Chamberlain's avatar
      fs: move namei sysctls to its own file · 9c011be1
      Luis Chamberlain authored
      kernel/sysctl.c is a kitchen sink where everyone leaves their dirty
      dishes, this makes it very difficult to maintain.
      
      To help with this maintenance let's start by moving sysctls to places
      where they actually belong.  The proc sysctl maintainers do not want to
      know what sysctl knobs you wish to add for your own piece of code, we
      just care about the core logic.
      
      So move namei's own sysctl knobs to its own file.
      
      Other than the move we also avoid initializing two static variables to 0
      as this is not needed:
      
        * sysctl_protected_symlinks
        * sysctl_protected_hardlinks
      
      Link: https://lkml.kernel.org/r/20211129205548.605569-8-mcgrof@kernel.org
      
      
      Signed-off-by: default avatarLuis Chamberlain <mcgrof@kernel.org>
      Cc: Al Viro <viro@zeniv.linux.org.uk>
      Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
      Cc: Antti Palosaari <crope@iki.fi>
      Cc: Eric Biederman <ebiederm@xmission.com>
      Cc: Iurii Zaikin <yzaikin@google.com>
      Cc: "J. Bruce Fields" <bfields@fieldses.org>
      Cc: Jeff Layton <jlayton@kernel.org>
      Cc: Kees Cook <keescook@chromium.org>
      Cc: Lukas Middendorf <kernel@tuxforce.de>
      Cc: Stephen Kitt <steve@sk2.org>
      Cc: Xiaoming Ni <nixiaoming@huawei.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      9c011be1
    • Luis Chamberlain's avatar
      fs: move locking sysctls where they are used · dd81faa8
      Luis Chamberlain authored
      kernel/sysctl.c is a kitchen sink where everyone leaves their dirty
      dishes, this makes it very difficult to maintain.
      
      To help with this maintenance let's start by moving sysctls to places
      where they actually belong.  The proc sysctl maintainers do not want to
      know what sysctl knobs you wish to add for your own piece of code, we
      just care about the core logic.
      
      The locking fs sysctls are only used on fs/locks.c, so move them there.
      
      Link: https://lkml.kernel.org/r/20211129205548.605569-7-mcgrof@kernel.org
      
      
      Signed-off-by: default avatarLuis Chamberlain <mcgrof@kernel.org>
      Cc: Al Viro <viro@zeniv.linux.org.uk>
      Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
      Cc: Antti Palosaari <crope@iki.fi>
      Cc: Eric Biederman <ebiederm@xmission.com>
      Cc: Iurii Zaikin <yzaikin@google.com>
      Cc: "J. Bruce Fields" <bfields@fieldses.org>
      Cc: Jeff Layton <jlayton@kernel.org>
      Cc: Kees Cook <keescook@chromium.org>
      Cc: Lukas Middendorf <kernel@tuxforce.de>
      Cc: Stephen Kitt <steve@sk2.org>
      Cc: Xiaoming Ni <nixiaoming@huawei.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      dd81faa8
    • Luis Chamberlain's avatar
      fs: move shared sysctls to fs/sysctls.c · d1d8ac9e
      Luis Chamberlain authored
      To help with this maintenance let's start by moving sysctls to places
      where they actually belong.  The proc sysctl maintainers do not want to
      know what sysctl knobs you wish to add for your own piece of code, we
      just care about the core logic.
      
      To help with this maintenance let's start by moving sysctls to places
      where they actually belong.  The proc sysctl maintainers do not want to
      know what sysctl knobs you wish to add for your own piece of code, we
      just care about the core logic.
      
      So move sysctls which are shared between filesystems into a common file
      outside of kernel/sysctl.c.
      
      Link: https://lkml.kernel.org/r/20211129205548.605569-6-mcgrof@kernel.org
      
      
      Signed-off-by: default avatarLuis Chamberlain <mcgrof@kernel.org>
      Cc: Al Viro <viro@zeniv.linux.org.uk>
      Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
      Cc: Antti Palosaari <crope@iki.fi>
      Cc: Eric Biederman <ebiederm@xmission.com>
      Cc: Iurii Zaikin <yzaikin@google.com>
      Cc: "J. Bruce Fields" <bfields@fieldses.org>
      Cc: Jeff Layton <jlayton@kernel.org>
      Cc: Kees Cook <keescook@chromium.org>
      Cc: Lukas Middendorf <kernel@tuxforce.de>
      Cc: Stephen Kitt <steve@sk2.org>
      Cc: Xiaoming Ni <nixiaoming@huawei.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      d1d8ac9e
    • Luis Chamberlain's avatar
      sysctl: move maxolduid as a sysctl specific const · 54771613
      Luis Chamberlain authored
      The maxolduid value is only shared for sysctl purposes for use on a max
      range.  Just stuff this into our shared const array.
      
      [akpm@linux-foundation.org: fix sysctl_vals[], per Mickaël]
      
      Link: https://lkml.kernel.org/r/20211129205548.605569-5-mcgrof@kernel.org
      
      
      Signed-off-by: default avatarLuis Chamberlain <mcgrof@kernel.org>
      Signed-off-by: default avatarMickaël Salaün <mic@digikod.net>
      Cc: Al Viro <viro@zeniv.linux.org.uk>
      Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
      Cc: Antti Palosaari <crope@iki.fi>
      Cc: Eric Biederman <ebiederm@xmission.com>
      Cc: Iurii Zaikin <yzaikin@google.com>
      Cc: "J. Bruce Fields" <bfields@fieldses.org>
      Cc: Jeff Layton <jlayton@kernel.org>
      Cc: Kees Cook <keescook@chromium.org>
      Cc: Lukas Middendorf <kernel@tuxforce.de>
      Cc: Stephen Kitt <steve@sk2.org>
      Cc: Xiaoming Ni <nixiaoming@huawei.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      54771613
    • Luis Chamberlain's avatar
      fs: move dcache sysctls to its own file · c8c0c239
      Luis Chamberlain authored
      kernel/sysctl.c is a kitchen sink where everyone leaves their dirty
      dishes, this makes it very difficult to maintain.
      
      To help with this maintenance let's start by moving sysctls to places
      where they actually belong.  The proc sysctl maintainers do not want to
      know what sysctl knobs you wish to add for your own piece of code, we
      just care about the core logic.
      
      So move the dcache sysctl clutter out of kernel/sysctl.c.  This is a
      small one-off entry, perhaps later we can simplify this representation,
      but for now we use the helpers we have.  We won't know how we can
      simplify this further untl we're fully done with the cleanup.
      
      [arnd@arndb.de: avoid unused-function warning]
        Link: https://lkml.kernel.org/r/20211203190123.874239-2-arnd@kernel.org
      
      Link: https://lkml.kernel.org/r/20211129205548.605569-4-mcgrof@kernel.org
      
      
      Signed-off-by: default avatarLuis Chamberlain <mcgrof@kernel.org>
      Signed-off-by: default avatarArnd Bergmann <arnd@arndb.de>
      Cc: Al Viro <viro@zeniv.linux.org.uk>
      Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
      Cc: Antti Palosaari <crope@iki.fi>
      Cc: Eric Biederman <ebiederm@xmission.com>
      Cc: Iurii Zaikin <yzaikin@google.com>
      Cc: "J. Bruce Fields" <bfields@fieldses.org>
      Cc: Jeff Layton <jlayton@kernel.org>
      Cc: Kees Cook <keescook@chromium.org>
      Cc: Lukas Middendorf <kernel@tuxforce.de>
      Cc: Stephen Kitt <steve@sk2.org>
      Cc: Xiaoming Ni <nixiaoming@huawei.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      c8c0c239
    • Luis Chamberlain's avatar
      fs: move fs stat sysctls to file_table.c · 204d5a24
      Luis Chamberlain authored
      kernel/sysctl.c is a kitchen sink where everyone leaves their dirty
      dishes, this makes it very difficult to maintain.
      
      To help with this maintenance let's start by moving sysctls to places
      where they actually belong.  The proc sysctl maintainers do not want to
      know what sysctl knobs you wish to add for your own piece of code, we
      just care about the core logic.
      
      We can create the sysctl dynamically on early init for fs stat to help
      with this clutter.  This dusts off the fs stat syctls knobs and puts
      them into where they are declared.
      
      Link: https://lkml.kernel.org/r/20211129205548.605569-3-mcgrof@kernel.org
      
      
      Signed-off-by: default avatarLuis Chamberlain <mcgrof@kernel.org>
      Cc: Al Viro <viro@zeniv.linux.org.uk>
      Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
      Cc: Antti Palosaari <crope@iki.fi>
      Cc: Eric Biederman <ebiederm@xmission.com>
      Cc: Iurii Zaikin <yzaikin@google.com>
      Cc: "J. Bruce Fields" <bfields@fieldses.org>
      Cc: Jeff Layton <jlayton@kernel.org>
      Cc: Kees Cook <keescook@chromium.org>
      Cc: Lukas Middendorf <kernel@tuxforce.de>
      Cc: Stephen Kitt <steve@sk2.org>
      Cc: Xiaoming Ni <nixiaoming@huawei.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      204d5a24
    • Luis Chamberlain's avatar
      fs: move inode sysctls to its own file · 1d67fe58
      Luis Chamberlain authored
      Patch series "sysctl: 4th set of kernel/sysctl cleanups".
      
      This is slimming down the fs uses of kernel/sysctl.c to the point that
      the next step is to just get rid of the fs base directory for it and
      move that elsehwere, so that next patch series starts dealing with that
      to demo how we can end up cleaning up a full base directory from
      kernel/sysctl.c, one at a time.
      
      This patch (of 9):
      
      kernel/sysctl.c is a kitchen sink where everyone leaves their dirty
      dishes, this makes it very difficult to maintain.
      
      To help with this maintenance let's start by moving sysctls to places
      where they actually belong.  The proc sysctl maintainers do not want to
      know what sysctl knobs you wish to add for your own piece of code, we
      just care about the core logic.
      
      So move the inode sysctls to its own file.  Since we are no longer using
      this outside of fs/ remove the extern declaration of its respective proc
      helper.
      
      We use early_initcall() as it is the earliest we can use.
      
      [arnd@arndb.de: avoid unused-variable warning]
        Link: https://lkml.kernel.org/r/20211203190123.874239-1-arnd@kernel.org
      
      Link: https://lkml.kernel.org/r/20211129205548.605569-1-mcgrof@kernel.org
      Link: https://lkml.kernel.org/r/20211129205548.605569-2-mcgrof@kernel.org
      
      
      Signed-off-by: default avatarLuis Chamberlain <mcgrof@kernel.org>
      Signed-off-by: default avatarArnd Bergmann <arnd@arndb.de>
      Cc: Al Viro <viro@zeniv.linux.org.uk>
      Cc: Kees Cook <keescook@chromium.org>
      Cc: Iurii Zaikin <yzaikin@google.com>
      Cc: Xiaoming Ni <nixiaoming@huawei.com>
      Cc: Eric Biederman <ebiederm@xmission.com>
      Cc: Stephen Kitt <steve@sk2.org>
      Cc: Lukas Middendorf <kernel@tuxforce.de>
      Cc: Antti Palosaari <crope@iki.fi>
      Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
      Cc: Jeff Layton <jlayton@kernel.org>
      Cc: "J. Bruce Fields" <bfields@fieldses.org>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      1d67fe58
    • Luis Chamberlain's avatar
      sysctl: share unsigned long const values · b1f2aff8
      Luis Chamberlain authored
      Provide a way to share unsigned long values.  This will allow others to
      not have to re-invent these values.
      
      Link: https://lkml.kernel.org/r/20211124231435.1445213-9-mcgrof@kernel.org
      
      
      Signed-off-by: default avatarLuis Chamberlain <mcgrof@kernel.org>
      Cc: Al Viro <viro@zeniv.linux.org.uk>
      Cc: Amir Goldstein <amir73il@gmail.com>
      Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
      Cc: Antti Palosaari <crope@iki.fi>
      Cc: Arnd Bergmann <arnd@arndb.de>
      Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
      Cc: Benjamin LaHaise <bcrl@kvack.org>
      Cc: Clemens Ladisch <clemens@ladisch.de>
      Cc: David Airlie <airlied@linux.ie>
      Cc: Douglas Gilbert <dgilbert@interlog.com>
      Cc: Eric Biederman <ebiederm@xmission.com>
      Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
      Cc: Iurii Zaikin <yzaikin@google.com>
      Cc: James E.J. Bottomley <jejb@linux.ibm.com>
      Cc: Jani Nikula <jani.nikula@intel.com>
      Cc: Jani Nikula <jani.nikula@linux.intel.com>
      Cc: Jan Kara <jack@suse.cz>
      Cc: Joel Becker <jlbec@evilplan.org>
      Cc: John Ogness <john.ogness@linutronix.de>
      Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
      Cc: Joseph Qi <joseph.qi@linux.alibaba.com>
      Cc: Julia Lawall <julia.lawall@inria.fr>
      Cc: Kees Cook <keescook@chromium.org>
      Cc: Lukas Middendorf <kernel@tuxforce.de>
      Cc: Mark Fasheh <mark@fasheh.com>
      Cc: Martin K. Petersen <martin.petersen@oracle.com>
      Cc: Paul Turner <pjt@google.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Petr Mladek <pmladek@suse.com>
      Cc: Phillip Potter <phil@philpotter.co.uk>
      Cc: Qing Wang <wangqing@vivo.com>
      Cc: "Rafael J. Wysocki" <rafael@kernel.org>
      Cc: Rodrigo Vivi <rodrigo.vivi@intel.com>
      Cc: Sebastian Reichel <sre@kernel.org>
      Cc: Sergey Senozhatsky <senozhatsky@chromium.org>
      Cc: Stephen Kitt <steve@sk2.org>
      Cc: Steven Rostedt (VMware) <rostedt@goodmis.org>
      Cc: Suren Baghdasaryan <surenb@google.com>
      Cc: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
      Cc: "Theodore Ts'o" <tytso@mit.edu>
      Cc: Xiaoming Ni <nixiaoming@huawei.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      b1f2aff8
    • Xiaoming Ni's avatar
      stackleak: move stack_erasing sysctl to stackleak.c · 0df8bdd5
      Xiaoming Ni authored
      kernel/sysctl.c is a kitchen sink where everyone leaves their dirty
      dishes, this makes it very difficult to maintain.
      
      To help with this maintenance let's start by moving sysctls to places
      where they actually belong.  The proc sysctl maintainers do not want to
      know what sysctl knobs you wish to add for your own piece of code, we
      just care about the core logic.
      
      So move the stack_erasing sysctl from kernel/sysctl.c to
      kernel/stackleak.c and use register_sysctl() to register the sysctl
      interface.
      
      [mcgrof@kernel.org: commit log update]
      
      Link: https://lkml.kernel.org/r/20211124231435.1445213-8-mcgrof@kernel.org
      
      
      Signed-off-by: default avatarXiaoming Ni <nixiaoming@huawei.com>
      Signed-off-by: default avatarLuis Chamberlain <mcgrof@kernel.org>
      Cc: Al Viro <viro@zeniv.linux.org.uk>
      Cc: Amir Goldstein <amir73il@gmail.com>
      Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
      Cc: Antti Palosaari <crope@iki.fi>
      Cc: Arnd Bergmann <arnd@arndb.de>
      Cc: Benjamin Herrenschmidt <benh@kernel.crashi...
      0df8bdd5
    • Xiaoming Ni's avatar
      scsi/sg: move sg-big-buff sysctl to scsi/sg.c · 26d1c80f
      Xiaoming Ni authored
      kernel/sysctl.c is a kitchen sink where everyone leaves their dirty
      dishes, this makes it very difficult to maintain.
      
      To help with this maintenance let's start by moving sysctls to places
      where they actually belong.  The proc sysctl maintainers do not want to
      know what sysctl knobs you wish to add for your own piece of code, we
      just care about the core logic.
      
      So move the sg-big-buff sysctl from kernel/sysctl.c to drivers/scsi/sg.c
      and use register_sysctl() to register the sysctl interface.
      
      [mcgrof@kernel.org: commit log update]
      
      Link: https://lkml.kernel.org/r/20211124231435.1445213-7-mcgrof@kernel.org
      
      
      Signed-off-by: default avatarXiaoming Ni <nixiaoming@huawei.com>
      Signed-off-by: default avatarLuis Chamberlain <mcgrof@kernel.org>
      Cc: Al Viro <viro@zeniv.linux.org.uk>
      Cc: Amir Goldstein <amir73il@gmail.com>
      Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
      Cc: Antti Palosaari <crope@iki.fi>
      Cc: Arnd Bergmann <arnd@arndb.de>
      Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
      Cc: Benjamin LaHaise <bcrl@kvack.org>
      Cc: Clemens Ladisch <clemens@ladisch.de>
      Cc: David Airlie <airlied@linux.ie>
      Cc: Douglas Gilbert <dgilbert@interlog.com>
      Cc: Eric Biederman <ebiederm@xmission.com>
      Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
      Cc: Iurii Zaikin <yzaikin@google.com>
      Cc: James E.J. Bottomley <jejb@linux.ibm.com>
      Cc: Jani Nikula <jani.nikula@intel.com>
      Cc: Jani Nikula <jani.nikula@linux.intel.com>
      Cc: Jan Kara <jack@suse.cz>
      Cc: Joel Becker <jlbec@evilplan.org>
      Cc: John Ogness <john.ogness@linutronix.de>
      Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
      Cc: Joseph Qi <joseph.qi@linux.alibaba.com>
      Cc: Julia Lawall <julia.lawall@inria.fr>
      Cc: Kees Cook <keescook@chromium.org>
      Cc: Lukas Middendorf <kernel@tuxforce.de>
      Cc: Mark Fasheh <mark@fasheh.com>
      Cc: Martin K. Petersen <martin.petersen@oracle.com>
      Cc: Paul Turner <pjt@google.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Petr Mladek <pmladek@suse.com>
      Cc: Phillip Potter <phil@philpotter.co.uk>
      Cc: Qing Wang <wangqing@vivo.com>
      Cc: "Rafael J. Wysocki" <rafael@kernel.org>
      Cc: Rodrigo Vivi <rodrigo.vivi@intel.com>
      Cc: Sebastian Reichel <sre@kernel.org>
      Cc: Sergey Senozhatsky <senozhatsky@chromium.org>
      Cc: Stephen Kitt <steve@sk2.org>
      Cc: Steven Rostedt (VMware) <rostedt@goodmis.org>
      Cc: Suren Baghdasaryan <surenb@google.com>
      Cc: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
      Cc: "Theodore Ts'o" <tytso@mit.edu>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      26d1c80f
    • Xiaoming Ni's avatar
      printk: move printk sysctl to printk/sysctl.c · faaa357a
      Xiaoming Ni authored
      kernel/sysctl.c is a kitchen sink where everyone leaves their dirty
      dishes, this makes it very difficult to maintain.
      
      To help with this maintenance let's start by moving sysctls to places
      where they actually belong.  The proc sysctl maintainers do not want to
      know what sysctl knobs you wish to add for your own piece of code, we
      just care about the core logic.
      
      So move printk sysctl from kernel/sysctl.c to kernel/printk/sysctl.c.
      Use register_sysctl() to register the sysctl interface.
      
      [mcgrof@kernel.org: fixed compile issues when PRINTK is not set, commit log update]
      
      Link: https://lkml.kernel.org/r/20211124231435.1445213-6-mcgrof@kernel.org
      
      
      Signed-off-by: default avatarXiaoming Ni <nixiaoming@huawei.com>
      Signed-off-by: default avatarLuis Chamberlain <mcgrof@kernel.org>
      Cc: Al Viro <viro@zeniv.linux.org.uk>
      Cc: Amir Goldstein <amir73il@gmail.com>
      Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
      Cc: Antti Palosaari <crope@iki.fi>
      Cc: Arnd Bergmann <arnd@arndb.de>
      Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
      Cc: Benjamin LaHaise <bcrl@kvack.org>
      Cc: Clemens Ladisch <clemens@ladisch.de>
      Cc: David Airlie <airlied@linux.ie>
      Cc: Douglas Gilbert <dgilbert@interlog.com>
      Cc: Eric Biederman <ebiederm@xmission.com>
      Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
      Cc: Iurii Zaikin <yzaikin@google.com>
      Cc: James E.J. Bottomley <jejb@linux.ibm.com>
      Cc: Jani Nikula <jani.nikula@intel.com>
      Cc: Jani Nikula <jani.nikula@linux.intel.com>
      Cc: Jan Kara <jack@suse.cz>
      Cc: Joel Becker <jlbec@evilplan.org>
      Cc: John Ogness <john.ogness@linutronix.de>
      Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
      Cc: Joseph Qi <joseph.qi@linux.alibaba.com>
      Cc: Julia Lawall <julia.lawall@inria.fr>
      Cc: Kees Cook <keescook@chromium.org>
      Cc: Lukas Middendorf <kernel@tuxforce.de>
      Cc: Mark Fasheh <mark@fasheh.com>
      Cc: Martin K. Petersen <martin.petersen@oracle.com>
      Cc: Paul Turner <pjt@google.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Petr Mladek <pmladek@suse.com>
      Cc: Phillip Potter <phil@philpotter.co.uk>
      Cc: Qing Wang <wangqing@vivo.com>
      Cc: "Rafael J. Wysocki" <rafael@kernel.org>
      Cc: Rodrigo Vivi <rodrigo.vivi@intel.com>
      Cc: Sebastian Reichel <sre@kernel.org>
      Cc: Sergey Senozhatsky <senozhatsky@chromium.org>
      Cc: Stephen Kitt <steve@sk2.org>
      Cc: Steven Rostedt (VMware) <rostedt@goodmis.org>
      Cc: Suren Baghdasaryan <surenb@google.com>
      Cc: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
      Cc: "Theodore Ts'o" <tytso@mit.edu>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      faaa357a
    • Luis Chamberlain's avatar
      fs: move binfmt_misc sysctl to its own file · 3ba442d5
      Luis Chamberlain authored
      kernel/sysctl.c is a kitchen sink where everyone leaves their dirty
      dishes, this makes it very difficult to maintain.
      
      To help with this maintenance let's start by moving sysctls to places
      where they actually belong.  The proc sysctl maintainers do not want to
      know what sysctl knobs you wish to add for your own piece of code, we
      just care about the core logic.
      
      This moves the binfmt_misc sysctl to its own file to help remove clutter
      from kernel/sysctl.c.
      
      Link: https://lkml.kernel.org/r/20211124231435.1445213-5-mcgrof@kernel.org
      
      
      Signed-off-by: default avatarLuis Chamberlain <mcgrof@kernel.org>
      Cc: Al Viro <viro@zeniv.linux.org.uk>
      Cc: Amir Goldstein <amir73il@gmail.com>
      Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
      Cc: Antti Palosaari <crope@iki.fi>
      Cc: Arnd Bergmann <arnd@arndb.de>
      Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
      Cc: Benjamin LaHaise <bcrl@kvack.org>
      Cc: Clemens Ladisch <clemens@ladisch.de>
      Cc: David Airlie <airlied@linux.ie>
      Cc: Douglas Gilbert <dgilbert@interlog.com>
      Cc: Eric Biederman <ebiederm@xmission.com>
      Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
      Cc: Iurii Zaikin <yzaikin@google.com>
      Cc: James E.J. Bottomley <jejb@linux.ibm.com>
      Cc: Jani Nikula <jani.nikula@intel.com>
      Cc: Jani Nikula <jani.nikula@linux.intel.com>
      Cc: Jan Kara <jack@suse.cz>
      Cc: Joel Becker <jlbec@evilplan.org>
      Cc: John Ogness <john.ogness@linutronix.de>
      Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
      Cc: Joseph Qi <joseph.qi@linux.alibaba.com>
      Cc: Julia Lawall <julia.lawall@inria.fr>
      Cc: Kees Cook <keescook@chromium.org>
      Cc: Lukas Middendorf <kernel@tuxforce.de>
      Cc: Mark Fasheh <mark@fasheh.com>
      Cc: Martin K. Petersen <martin.petersen@oracle.com>
      Cc: Paul Turner <pjt@google.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Petr Mladek <pmladek@suse.com>
      Cc: Phillip Potter <phil@philpotter.co.uk>
      Cc: Qing Wang <wangqing@vivo.com>
      Cc: "Rafael J. Wysocki" <rafael@kernel.org>
      Cc: Rodrigo Vivi <rodrigo.vivi@intel.com>
      Cc: Sebastian Reichel <sre@kernel.org>
      Cc: Sergey Senozhatsky <senozhatsky@chromium.org>
      Cc: Stephen Kitt <steve@sk2.org>
      Cc: Steven Rostedt (VMware) <rostedt@goodmis.org>
      Cc: Suren Baghdasaryan <surenb@google.com>
      Cc: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
      Cc: "Theodore Ts'o" <tytso@mit.edu>
      Cc: Xiaoming Ni <nixiaoming@huawei.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      3ba442d5
    • Luis Chamberlain's avatar
      sysctl: add helper to register a sysctl mount point · ee9efac4
      Luis Chamberlain authored
      The way to create a subdirectory on top of sysctl_mount_point is a bit
      obscure, and *why* we do that even so more.  Provide a helper which
      makes it clear why we do this.
      
      [akpm@linux-foundation.org: export register_sysctl_mount_point() to
      modules]
      
      Link: https://lkml.kernel.org/r/20211124231435.1445213-4-mcgrof@kernel.org
      
      
      Signed-off-by: default avatarLuis Chamberlain <mcgrof@kernel.org>
      Suggested-by: default avatar"Eric W. Biederman" <ebiederm@xmission.com>
      Cc: Al Viro <viro@zeniv.linux.org.uk>
      Cc: Amir Goldstein <amir73il@gmail.com>
      Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
      Cc: Antti Palosaari <crope@iki.fi>
      Cc: Arnd Bergmann <arnd@arndb.de>
      Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
      Cc: Benjamin LaHaise <bcrl@kvack.org>
      Cc: Clemens Ladisch <clemens@ladisch.de>
      Cc: David Airlie <airlied@linux.ie>
      Cc: Douglas Gilbert <dgilbert@interlog.com>
      Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
      Cc: Iurii Zaikin <yzaikin@google.com>
      Cc: James E.J. Bottomley <jejb@linux.ibm.com>
      Cc: Jani Nikula <jani.nikula@intel.com>
      Cc: Jani Nikula <jani.nikula@linux.intel.com>
      Cc: Jan Kara <jack@suse.cz>
      Cc: Joel Becker <jlbec@evilplan.org>
      Cc: John Ogness <john.ogness@linutronix.de>
      Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
      Cc: Joseph Qi <joseph.qi@linux.alibaba.com>
      Cc: Julia Lawall <julia.lawall@inria.fr>
      Cc: Kees Cook <keescook@chromium.org>
      Cc: Lukas Middendorf <kernel@tuxforce.de>
      Cc: Mark Fasheh <mark@fasheh.com>
      Cc: Martin K. Petersen <martin.petersen@oracle.com>
      Cc: Paul Turner <pjt@google.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Petr Mladek <pmladek@suse.com>
      Cc: Phillip Potter <phil@philpotter.co.uk>
      Cc: Qing Wang <wangqing@vivo.com>
      Cc: "Rafael J. Wysocki" <rafael@kernel.org>
      Cc: Rodrigo Vivi <rodrigo.vivi@intel.com>
      Cc: Sebastian Reichel <sre@kernel.org>
      Cc: Sergey Senozhatsky <senozhatsky@chromium.org>
      Cc: Stephen Kitt <steve@sk2.org>
      Cc: Steven Rostedt (VMware) <rostedt@goodmis.org>
      Cc: Suren Baghdasaryan <surenb@google.com>
      Cc: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
      Cc: "Theodore Ts'o" <tytso@mit.edu>
      Cc: Xiaoming Ni <nixiaoming@huawei.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      ee9efac4
    • Xiaoming Ni's avatar
      random: move the random sysctl declarations to its own file · 5475e8f0
      Xiaoming Ni authored
      kernel/sysctl.c is a kitchen sink where everyone leaves their dirty
      dishes, this makes it very difficult to maintain.
      
      To help with this maintenance let's start by moving sysctls to places
      where they actually belong.  The proc sysctl maintainers do not want to
      know what sysctl knobs you wish to add for your own piece of code, we
      just care about the core logic.
      
      So move the random sysctls to their own file and use
      register_sysctl_init().
      
      [mcgrof@kernel.org: commit log update to justify the move]
      
      Link: https://lkml.kernel.org/r/20211124231435.1445213-3-mcgrof@kernel.org
      
      
      Signed-off-by: default avatarXiaoming Ni <nixiaoming@huawei.com>
      Signed-off-by: default avatarLuis Chamberlain <mcgrof@kernel.org>
      Cc: Al Viro <viro@zeniv.linux.org.uk>
      Cc: Amir Goldstein <amir73il@gmail.com>
      Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
      Cc: Antti Palosaari <crope@iki.fi>
      Cc: Arnd Bergmann <arnd@arndb.de>
      Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
      Cc: Benjamin LaHaise <bcrl@kvack.org>
      Cc: Clemens Ladisch <clemens@ladisch.de>
      Cc: David Airlie <airlied@linux.ie>
      Cc: Douglas Gilbert <dgilbert@interlog.com>
      Cc: Eric Biederman <ebiederm@xmission.com>
      Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
      Cc: Iurii Zaikin <yzaikin@google.com>
      Cc: James E.J. Bottomley <jejb@linux.ibm.com>
      Cc: Jani Nikula <jani.nikula@intel.com>
      Cc: Jani Nikula <jani.nikula@linux.intel.com>
      Cc: Jan Kara <jack@suse.cz>
      Cc: Joel Becker <jlbec@evilplan.org>
      Cc: John Ogness <john.ogness@linutronix.de>
      Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
      Cc: Joseph Qi <joseph.qi@linux.alibaba.com>
      Cc: Julia Lawall <julia.lawall@inria.fr>
      Cc: Kees Cook <keescook@chromium.org>
      Cc: Lukas Middendorf <kernel@tuxforce.de>
      Cc: Mark Fasheh <mark@fasheh.com>
      Cc: Martin K. Petersen <martin.petersen@oracle.com>
      Cc: Paul Turner <pjt@google.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Petr Mladek <pmladek@suse.com>
      Cc: Phillip Potter <phil@philpotter.co.uk>
      Cc: Qing Wang <wangqing@vivo.com>
      Cc: "Rafael J. Wysocki" <rafael@kernel.org>
      Cc: Rodrigo Vivi <rodrigo.vivi@intel.com>
      Cc: Sebastian Reichel <sre@kernel.org>
      Cc: Sergey Senozhatsky <senozhatsky@chromium.org>
      Cc: Stephen Kitt <steve@sk2.org>
      Cc: Steven Rostedt (VMware) <rostedt@goodmis.org>
      Cc: Suren Baghdasaryan <surenb@google.com>
      Cc: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
      Cc: "Theodore Ts'o" <tytso@mit.edu>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      5475e8f0
    • Xiaoming Ni's avatar
      firmware_loader: move firmware sysctl to its own files · 6aad36d4
      Xiaoming Ni authored
      Patch series "sysctl: 3rd set of kernel/sysctl cleanups", v2.
      
      This is the third set of patches to help address cleaning the kitchen
      seink in kernel/sysctl.c and to move sysctls away to where they are
      actually implemented / used.
      
      This patch (of 8):
      
      kernel/sysctl.c is a kitchen sink where everyone leaves their dirty
      dishes, this makes it very difficult to maintain.
      
      To help with this maintenance let's start by moving sysctls to places
      where they actually belong.  The proc sysctl maintainers do not want to
      know what sysctl knobs you wish to add for your own piece of code, we
      just care about the core logic.
      
      So move the firmware configuration sysctl table to the only place where
      it is used, and make it clear that if sysctls are disabled this is not
      used.
      
      [akpm@linux-foundation.org: export register_firmware_config_sysctl and unregister_firmware_config_sysctl to modules]
      [akpm@linux-foundation.org: use EXPORT_SYMBOL_NS_GPL instead]
      [sfr@canb.auug.org.au: fix that so it compiles]
        Link: https://lkml.kernel.org/r/20211201160626.401d828d@canb.auug.org.au
      [mcgrof@kernel.org: major commit log update to justify the move]
      
      Link: https://lkml.kernel.org/r/20211124231435.1445213-1-mcgrof@kernel.org
      Link: https://lkml.kernel.org/r/20211124231435.1445213-2-mcgrof@kernel.org
      
      
      Signed-off-by: default avatarXiaoming Ni <nixiaoming@huawei.com>
      Signed-off-by: default avatarLuis Chamberlain <mcgrof@kernel.org>
      Signed-off-by: default avatarStephen Rothwell <sfr@canb.auug.org.au>
      Cc: Kees Cook <keescook@chromium.org>
      Cc: Iurii Zaikin <yzaikin@google.com>
      Cc: Eric Biederman <ebiederm@xmission.com>
      Cc: Stephen Kitt <steve@sk2.org>
      Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
      Cc: "Rafael J. Wysocki" <rafael@kernel.org>
      Cc: "Theodore Ts'o" <tytso@mit.edu>
      Cc: Al Viro <viro@zeniv.linux.org.uk>
      Cc: Petr Mladek <pmladek@suse.com>
      Cc: Sergey Senozhatsky <senozhatsky@chromium.org>
      Cc: Steven Rostedt (VMware) <rostedt@goodmis.org>
      Cc: John Ogness <john.ogness@linutronix.de>
      Cc: Douglas Gilbert <dgilbert@interlog.com>
      Cc: James E.J. Bottomley <jejb@linux.ibm.com>
      Cc: Martin K. Petersen <martin.petersen@oracle.com>
      Cc: Lukas Middendorf <kernel@tuxforce.de>
      Cc: Antti Palosaari <crope@iki.fi>
      Cc: Amir Goldstein <amir73il@gmail.com>
      Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
      Cc: Arnd Bergmann <arnd@arndb.de>
      Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
      Cc: Benjamin LaHaise <bcrl@kvack.org>
      Cc: Clemens Ladisch <clemens@ladisch.de>
      Cc: David Airlie <airlied@linux.ie>
      Cc: Jani Nikula <jani.nikula@intel.com>
      Cc: Jani Nikula <jani.nikula@linux.intel.com>
      Cc: Jan Kara <jack@suse.cz>
      Cc: Joel Becker <jlbec@evilplan.org>
      Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
      Cc: Joseph Qi <joseph.qi@linux.alibaba.com>
      Cc: Julia Lawall <julia.lawall@inria.fr>
      Cc: Mark Fasheh <mark@fasheh.com>
      Cc: Paul Turner <pjt@google.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Phillip Potter <phil@philpotter.co.uk>
      Cc: Qing Wang <wangqing@vivo.com>
      Cc: Rodrigo Vivi <rodrigo.vivi@intel.com>
      Cc: Sebastian Reichel <sre@kernel.org>
      Cc: Suren Baghdasaryan <surenb@google.com>
      Cc: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      6aad36d4
    • Xiaoming Ni's avatar
      eventpoll: simplify sysctl declaration with register_sysctl() · a8f5de89
      Xiaoming Ni authored
      The kernel/sysctl.c is a kitchen sink where everyone leaves their dirty
      dishes, this makes it very difficult to maintain.
      
      To help with this maintenance let's start by moving sysctls to places
      where they actually belong.  The proc sysctl maintainers do not want to
      know what sysctl knobs you wish to add for your own piece of code, we
      just care about the core logic.
      
      So move the epoll_table sysctl to fs/eventpoll.c and use
      register_sysctl().
      
      Link: https://lkml.kernel.org/r/20211123202422.819032-9-mcgrof@kernel.org
      
      
      Signed-off-by: default avatarXiaoming Ni <nixiaoming@huawei.com>
      Signed-off-by: default avatarLuis Chamberlain <mcgrof@kernel.org>
      Cc: Al Viro <viro@zeniv.linux.org.uk>
      Cc: Amir Goldstein <amir73il@gmail.com>
      Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
      Cc: Antti Palosaari <crope@iki.fi>
      Cc: Arnd Bergmann <arnd@arndb.de>
      Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
      Cc: Benjamin LaHaise <bcrl@kvack.org>
      Cc: Clemens Ladisch <clemens@ladisch.de>
      Cc: David Airlie <airlied@linux.ie>
      Cc: "Eric W. Biederman" <ebiederm@xmission.com>
      Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
      Cc: Iurii Zaikin <yzaikin@google.com>
      Cc: Jani Nikula <jani.nikula@linux.intel.com>
      Cc: Jan Kara <jack@suse.cz>
      Cc: Joel Becker <jlbec@evilplan.org>
      Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
      Cc: Joseph Qi <joseph.qi@linux.alibaba.com>
      Cc: Julia Lawall <julia.lawall@inria.fr>
      Cc: Kees Cook <keescook@chromium.org>
      Cc: Lukas Middendorf <kernel@tuxforce.de>
      Cc: Mark Fasheh <mark@fasheh.com>
      Cc: Paul Turner <pjt@google.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Petr Mladek <pmladek@suse.com>
      Cc: Phillip Potter <phil@philpotter.co.uk>
      Cc: Qing Wang <wangqing@vivo.com>
      Cc: Rodrigo Vivi <rodrigo.vivi@intel.com>
      Cc: Sebastian Reichel <sre@kernel.org>
      Cc: Sergey Senozhatsky <senozhatsky@chromium.org>
      Cc: Stephen Kitt <steve@sk2.org>
      Cc: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
      Cc: Douglas Gilbert <dgilbert@interlog.com>
      Cc: James E.J. Bottomley <jejb@linux.ibm.com>
      Cc: Jani Nikula <jani.nikula@intel.com>
      Cc: John Ogness <john.ogness@linutronix.de>
      Cc: Martin K. Petersen <martin.petersen@oracle.com>
      Cc: "Rafael J. Wysocki" <rafael@kernel.org>
      Cc: Steven Rostedt (VMware) <rostedt@goodmis.org>
      Cc: Suren Baghdasaryan <surenb@google.com>
      Cc: "Theodore Ts'o" <tytso@mit.edu>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      a8f5de89
    • Luis Chamberlain's avatar
      cdrom: simplify subdirectory registration with register_sysctl() · ad8f7431
      Luis Chamberlain authored
      There is no need to user boiler plate code to specify a set of base
      directories we're going to stuff sysctls under.  Simplify this by using
      register_sysctl() and specifying the directory path directly.
      
      // pycocci sysctl-subdir-register-sysctl-simplify.cocci PATH
      
      @c1@
      expression E1;
      identifier subdir, sysctls;
      @@
      
      static struct ctl_table subdir[] = {
      	{
      		.procname = E1,
      		.maxlen = 0,
      		.mode = 0555,
      		.child = sysctls,
      	},
      	{ }
      };
      
      @c2@
      identifier c1.subdir;
      
      expression E2;
      identifier base;
      @@
      
      static struct ctl_table base[] = {
      	{
      		.procname = E2,
      		.maxlen = 0,
      		.mode = 0555,
      		.child = subdir,
      	},
      	{ }
      };
      
      @c3@
      identifier c2.base;
      identifier header;
      @@
      
      header = register_sysctl_table(base);
      
      @r1 depends on c1 && c2 && c3@
      expression c1.E1;
      identifier c1.subdir, c1.sysctls;
      @@
      
      -static struct ctl_table subdir[] = {
      -	{
      -		.procname = E1,
      -		.maxlen = 0,
      -		.mode = 0555,
      -		.child = sysctls,
      -	},
      -	{ }
      -};
      
      @r2 depends on c1 && c2 && c3@
      identifier c1.subdir;
      
      expression c2.E2;
      identifier c2.base;
      @@
      -static struct ctl_table base[] = {
      -	{
      -		.procname = E2,
      -		.maxlen = 0,
      -		.mode = 0555,
      -		.child = subdir,
      -	},
      -	{ }
      -};
      
      @initialize:python@
      @@
      
      def make_my_fresh_expression(s1, s2):
        return '"' + s1.strip('"') + "/" + s2.strip('"') + '"'
      
      @r3 depends on c1 && c2 && c3@
      expression c1.E1;
      identifier c1.sysctls;
      expression c2.E2;
      identifier c2.base;
      identifier c3.header;
      fresh identifier E3 = script:python(E2, E1) { make_my_fresh_expression(E2, E1) };
      @@
      
      header =
      -register_sysctl_table(base);
      +register_sysctl(E3, sysctls);
      
      Generated-by: Coccinelle SmPL
      Link: https://lkml.kernel.org/r/20211123202422.819032-8-mcgrof@kernel.org
      
      
      Signed-off-by: default avatarLuis Chamberlain <mcgrof@kernel.org>
      Cc: Al Viro <viro@zeniv.linux.org.uk>
      Cc: Amir Goldstein <amir73il@gmail.com>
      Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
      Cc: Antti Palosaari <crope@iki.fi>
      Cc: Arnd Bergmann <arnd@arndb.de>
      Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
      Cc: Benjamin LaHaise <bcrl@kvack.org>
      Cc: Clemens Ladisch <clemens@ladisch.de>
      Cc: David Airlie <airlied@linux.ie>
      Cc: "Eric W. Biederman" <ebiederm@xmission.com>
      Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
      Cc: Iurii Zaikin <yzaikin@google.com>
      Cc: Jani Nikula <jani.nikula@linux.intel.com>
      Cc: Jan Kara <jack@suse.cz>
      Cc: Joel Becker <jlbec@evilplan.org>
      Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
      Cc: Joseph Qi <joseph.qi@linux.alibaba.com>
      Cc: Julia Lawall <julia.lawall@inria.fr>
      Cc: Kees Cook <keescook@chromium.org>
      Cc: Lukas Middendorf <kernel@tuxforce.de>
      Cc: Mark Fasheh <mark@fasheh.com>
      Cc: Paul Turner <pjt@google.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Petr Mladek <pmladek@suse.com>
      Cc: Phillip Potter <phil@philpotter.co.uk>
      Cc: Qing Wang <wangqing@vivo.com>
      Cc: Rodrigo Vivi <rodrigo.vivi@intel.com>
      Cc: Sebastian Reichel <sre@kernel.org>
      Cc: Sergey Senozhatsky <senozhatsky@chromium.org>
      Cc: Stephen Kitt <steve@sk2.org>
      Cc: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
      Cc: Xiaoming Ni <nixiaoming@huawei.com>
      Cc: Douglas Gilbert <dgilbert@interlog.com>
      Cc: James E.J. Bottomley <jejb@linux.ibm.com>
      Cc: Jani Nikula <jani.nikula@intel.com>
      Cc: John Ogness <john.ogness@linutronix.de>
      Cc: Martin K. Petersen <martin.petersen@oracle.com>
      Cc: "Rafael J. Wysocki" <rafael@kernel.org>
      Cc: Steven Rostedt (VMware) <rostedt@goodmis.org>
      Cc: Suren Baghdasaryan <surenb@google.com>
      Cc: "Theodore Ts'o" <tytso@mit.edu>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      ad8f7431
    • Xiaoming Ni's avatar
      inotify: simplify subdirectory registration with register_sysctl() · 7b9ad122
      Xiaoming Ni authored
      There is no need to user boiler plate code to specify a set of base
      directories we're going to stuff sysctls under.  Simplify this by using
      register_sysctl() and specifying the directory path directly.
      
      Move inotify_user sysctl to inotify_user.c while at it to remove clutter
      from kernel/sysctl.c.
      
      [mcgrof@kernel.org: remember to register fanotify_table]
        Link: https://lkml.kernel.org/r/YZ5A6iWLb0h3N3RC@bombadil.infradead.org
      [mcgrof@kernel.org: update commit log to reflect new path we decided to take]
      
      Link: https://lkml.kernel.org/r/20211123202422.819032-7-mcgrof@kernel.org
      
      
      Signed-off-by: default avatarXiaoming Ni <nixiaoming@huawei.com>
      Signed-off-by: default avatarLuis Chamberlain <mcgrof@kernel.org>
      Cc: Al Viro <viro@zeniv.linux.org.uk>
      Cc: Amir Goldstein <amir73il@gmail.com>
      Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
      Cc: Antti Palosaari <crope@iki.fi>
      Cc: Arnd Bergmann <arnd@arndb.de>
      Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
      Cc: Benjamin LaHaise <bcrl@kvack.org>
      Cc: Clemens Ladisch <clemens@ladisch.de>
      Cc: David Airlie <airlied@linux.ie>
      Cc: "Eric W. Biederman" <ebiederm@xmission.com>
      Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
      Cc: Iurii Zaikin <yzaikin@google.com>
      Cc: Jani Nikula <jani.nikula@linux.intel.com>
      Cc: Jan Kara <jack@suse.cz>
      Cc: Joel Becker <jlbec@evilplan.org>
      Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
      Cc: Joseph Qi <joseph.qi@linux.alibaba.com>
      Cc: Julia Lawall <julia.lawall@inria.fr>
      Cc: Kees Cook <keescook@chromium.org>
      Cc: Lukas Middendorf <kernel@tuxforce.de>
      Cc: Mark Fasheh <mark@fasheh.com>
      Cc: Paul Turner <pjt@google.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Petr Mladek <pmladek@suse.com>
      Cc: Phillip Potter <phil@philpotter.co.uk>
      Cc: Qing Wang <wangqing@vivo.com>
      Cc: Rodrigo Vivi <rodrigo.vivi@intel.com>
      Cc: Sebastian Reichel <sre@kernel.org>
      Cc: Sergey Senozhatsky <senozhatsky@chromium.org>
      Cc: Stephen Kitt <steve@sk2.org>
      Cc: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
      Cc: Douglas Gilbert <dgilbert@interlog.com>
      Cc: James E.J. Bottomley <jejb@linux.ibm.com>
      Cc: Jani Nikula <jani.nikula@intel.com>
      Cc: John Ogness <john.ogness@linutronix.de>
      Cc: Martin K. Petersen <martin.petersen@oracle.com>
      Cc: "Rafael J. Wysocki" <rafael@kernel.org>
      Cc: Steven Rostedt (VMware) <rostedt@goodmis.org>
      Cc: Suren Baghdasaryan <surenb@google.com>
      Cc: "Theodore Ts'o" <tytso@mit.edu>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      7b9ad122
    • Luis Chamberlain's avatar
      test_sysctl: simplify subdirectory registration with register_sysctl() · 04bc883c
      Luis Chamberlain authored
      There is no need to user boiler plate code to specify a set of base
      directories we're going to stuff sysctls under.  Simplify this by using
      register_sysctl() and specifying the directory path directly.
      
      // pycocci sysctl-subdir-register-sysctl-simplify.cocci lib/test_sysctl.c
      
      @c1@
      expression E1;
      identifier subdir, sysctls;
      @@
      
      static struct ctl_table subdir[] = {
      	{
      		.procname = E1,
      		.maxlen = 0,
      		.mode = 0555,
      		.child = sysctls,
      	},
      	{ }
      };
      
      @c2@
      identifier c1.subdir;
      
      expression E2;
      identifier base;
      @@
      
      static struct ctl_table base[] = {
      	{
      		.procname = E2,
      		.maxlen = 0,
      		.mode = 0555,
      		.child = subdir,
      	},
      	{ }
      };
      
      @c3@
      identifier c2.base;
      identifier header;
      @@
      
      header = register_sysctl_table(base);
      
      @r1 depends on c1 && c2 && c3@
      expression c1.E1;
      identifier c1.subdir, c1.sysctls;
      @@
      
      -static struct ctl_table subdir[] = {
      -	{
      -		.procname = E1,
      -		.maxlen = 0,
      -		.mode = 0555,
      -		.child = sysctls,
      -	},
      -	{ }
      -};
      
      @r2 depends on c1 && c2 && c3@
      identifier c1.subdir;
      
      expression c2.E2;
      identifier c2.base;
      @@
      -static struct ctl_table base[] = {
      -	{
      -		.procname = E2,
      -		.maxlen = 0,
      -		.mode = 0555,
      -		.child = subdir,
      -	},
      -	{ }
      -};
      
      @initialize:python@
      @@
      
      def make_my_fresh_expression(s1, s2):
        return '"' + s1.strip('"') + "/" + s2.strip('"') + '"'
      
      @r3 depends on c1 && c2 && c3@
      expression c1.E1;
      identifier c1.sysctls;
      expression c2.E2;
      identifier c2.base;
      identifier c3.header;
      fresh identifier E3 = script:python(E2, E1) { make_my_fresh_expression(E2, E1) };
      @@
      
      header =
      -register_sysctl_table(base);
      +register_sysctl(E3, sysctls);
      
      Generated-by: Coccinelle SmPL
      Link: https://lkml.kernel.org/r/20211123202422.819032-6-mcgrof@kernel.org
      
      
      Signed-off-by: default avatarLuis Chamberlain <mcgrof@kernel.org>
      Cc: Al Viro <viro@zeniv.linux.org.uk>
      Cc: Amir Goldstein <amir73il@gmail.com>
      Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
      Cc: Antti Palosaari <crope@iki.fi>
      Cc: Arnd Bergmann <arnd@arndb.de>
      Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
      Cc: Benjamin LaHaise <bcrl@kvack.org>
      Cc: Clemens Ladisch <clemens@ladisch.de>
      Cc: David Airlie <airlied@linux.ie>
      Cc: "Eric W. Biederman" <ebiederm@xmission.com>
      Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
      Cc: Iurii Zaikin <yzaikin@google.com>
      Cc: Jani Nikula <jani.nikula@linux.intel.com>
      Cc: Jan Kara <jack@suse.cz>
      Cc: Joel Becker <jlbec@evilplan.org>
      Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
      Cc: Joseph Qi <joseph.qi@linux.alibaba.com>
      Cc: Julia Lawall <julia.lawall@inria.fr>
      Cc: Kees Cook <keescook@chromium.org>
      Cc: Lukas Middendorf <kernel@tuxforce.de>
      Cc: Mark Fasheh <mark@fasheh.com>
      Cc: Paul Turner <pjt@google.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Petr Mladek <pmladek@suse.com>
      Cc: Phillip Potter <phil@philpotter.co.uk>
      Cc: Qing Wang <wangqing@vivo.com>
      Cc: Rodrigo Vivi <rodrigo.vivi@intel.com>
      Cc: Sebastian Reichel <sre@kernel.org>
      Cc: Sergey Senozhatsky <senozhatsky@chromium.org>
      Cc: Stephen Kitt <steve@sk2.org>
      Cc: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
      Cc: Xiaoming Ni <nixiaoming@huawei.com>
      Cc: Douglas Gilbert <dgilbert@interlog.com>
      Cc: James E.J. Bottomley <jejb@linux.ibm.com>
      Cc: Jani Nikula <jani.nikula@intel.com>
      Cc: John Ogness <john.ogness@linutronix.de>
      Cc: Martin K. Petersen <martin.petersen@oracle.com>
      Cc: "Rafael J. Wysocki" <rafael@kernel.org>
      Cc: Steven Rostedt (VMware) <rostedt@goodmis.org>
      Cc: Suren Baghdasaryan <surenb@google.com>
      Cc: "Theodore Ts'o" <tytso@mit.edu>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      04bc883c
    • Luis Chamberlain's avatar
      ocfs2: simplify subdirectory registration with register_sysctl() · c42ff46f
      Luis Chamberlain authored
      There is no need to user boiler plate code to specify a set of base
      directories we're going to stuff sysctls under.  Simplify this by using
      register_sysctl() and specifying the directory path directly.
      
      // pycocci sysctl-subdir-register-sysctl-simplify.cocci PATH
      
      @c1@
      expression E1;
      identifier subdir, sysctls;
      @@
      
      static struct ctl_table subdir[] = {
      	{
      		.procname = E1,
      		.maxlen = 0,
      		.mode = 0555,
      		.child = sysctls,
      	},
      	{ }
      };
      
      @c2@
      identifier c1.subdir;
      
      expression E2;
      identifier base;
      @@
      
      static struct ctl_table base[] = {
      	{
      		.procname = E2,
      		.maxlen = 0,
      		.mode = 0555,
      		.child = subdir,
      	},
      	{ }
      };
      
      @c3@
      identifier c2.base;
      identifier header;
      @@
      
      header = register_sysctl_table(base);
      
      @r1 depends on c1 && c2 && c3@
      expression c1.E1;
      identifier c1.subdir, c1.sysctls;
      @@
      
      -static struct ctl_table subdir[] = {
      -	{
      -		.procname = E1,
      -		.maxlen = 0,
      -		.mode = 0555,
      -		.child = sysctls,
      -	},
      -	{ }
      -};
      
      @r2 depends on c1 && c2 && c3@
      identifier c1.subdir;
      
      expression c2.E2;
      identifier c2.base;
      @@
      -static struct ctl_table base[] = {
      -	{
      -		.procname = E2,
      -		.maxlen = 0,
      -		.mode = 0555,
      -		.child = subdir,
      -	},
      -	{ }
      -};
      
      @initialize:python@
      @@
      
      def make_my_fresh_expression(s1, s2):
        return '"' + s1.strip('"') + "/" + s2.strip('"') + '"'
      
      @r3 depends on c1 && c2 && c3@
      expression c1.E1;
      identifier c1.sysctls;
      expression c2.E2;
      identifier c2.base;
      identifier c3.header;
      fresh identifier E3 = script:python(E2, E1) { make_my_fresh_expression(E2, E1) };
      @@
      
      header =
      -register_sysctl_table(base);
      +register_sysctl(E3, sysctls);
      
      Generated-by: Coccinelle SmPL
      Link: https://lkml.kernel.org/r/20211123202422.819032-5-mcgrof@kernel.org
      
      
      Signed-off-by: default avatarLuis Chamberlain <mcgrof@kernel.org>
      Reviewed-by: default avatarJan Kara <jack@suse.cz>
      Cc: Al Viro <viro@zeniv.linux.org.uk>
      Cc: Amir Goldstein <amir73il@gmail.com>
      Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
      Cc: Antti Palosaari <crope@iki.fi>
      Cc: Arnd Bergmann <arnd@arndb.de>
      Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
      Cc: Benjamin LaHaise <bcrl@kvack.org>
      Cc: Clemens Ladisch <clemens@ladisch.de>
      Cc: David Airlie <airlied@linux.ie>
      Cc: "Eric W. Biederman" <ebiederm@xmission.com>
      Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
      Cc: Iurii Zaikin <yzaikin@google.com>
      Cc: Jani Nikula <jani.nikula@linux.intel.com>
      Cc: Joel Becker <jlbec@evilplan.org>
      Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
      Cc: Joseph Qi <joseph.qi@linux.alibaba.com>
      Cc: Julia Lawall <julia.lawall@inria.fr>
      Cc: Kees Cook <keescook@chromium.org>
      Cc: Lukas Middendorf <kernel@tuxforce.de>
      Cc: Mark Fasheh <mark@fasheh.com>
      Cc: Paul Turner <pjt@google.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Petr Mladek <pmladek@suse.com>
      Cc: Phillip Potter <phil@philpotter.co.uk>
      Cc: Qing Wang <wangqing@vivo.com>
      Cc: Rodrigo Vivi <rodrigo.vivi@intel.com>
      Cc: Sebastian Reichel <sre@kernel.org>
      Cc: Sergey Senozhatsky <senozhatsky@chromium.org>
      Cc: Stephen Kitt <steve@sk2.org>
      Cc: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
      Cc: Xiaoming Ni <nixiaoming@huawei.com>
      Cc: Douglas Gilbert <dgilbert@interlog.com>
      Cc: James E.J. Bottomley <jejb@linux.ibm.com>
      Cc: Jani Nikula <jani.nikula@intel.com>
      Cc: John Ogness <john.ogness@linutronix.de>
      Cc: Martin K. Petersen <martin.petersen@oracle.com>
      Cc: "Rafael J. Wysocki" <rafael@kernel.org>
      Cc: Steven Rostedt (VMware) <rostedt@goodmis.org>
      Cc: Suren Baghdasaryan <surenb@google.com>
      Cc: "Theodore Ts'o" <tytso@mit.edu>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      c42ff46f
    • Luis Chamberlain's avatar
      macintosh/mac_hid.c: simplify subdirectory registration with register_sysctl() · e99f5e74
      Luis Chamberlain authored
      There is no need to user boiler plate code to specify a set of base
      directories we're going to stuff sysctls under.  Simplify this by using
      register_sysctl() and specifying the directory path directly.
      
      // pycocci sysctl-subdir-register-sysctl-simplify.cocci PATH
      
      @c1@
      expression E1;
      identifier subdir, sysctls;
      @@
      
      static struct ctl_table subdir[] = {
      	{
      		.procname = E1,
      		.maxlen = 0,
      		.mode = 0555,
      		.child = sysctls,
      	},
      	{ }
      };
      
      @c2@
      identifier c1.subdir;
      
      expression E2;
      identifier base;
      @@
      
      static struct ctl_table base[] = {
      	{
      		.procname = E2,
      		.maxlen = 0,
      		.mode = 0555,
      		.child = subdir,
      	},
      	{ }
      };
      
      @c3@
      identifier c2.base;
      identifier header;
      @@
      
      header = register_sysctl_table(base);
      
      @r1 depends on c1 && c2 && c3@
      expression c1.E1;
      identifier c1.subdir, c1.sysctls;
      @@
      
      -static struct ctl_table subdir[] = {
      -	{
      -		.procname = E1,
      -		.maxlen = 0,
      -		.mode = 0555,
      -		.child = sysctls,
      -	},
      -	{ }
      -};
      
      @r2 depends on c1 && c2 && c3@
      identifier c1.subdir;
      
      expression c2.E2;
      identifier c2.base;
      @@
      -static struct ctl_table base[] = {
      -	{
      -		.procname = E2,
      -		.maxlen = 0,
      -		.mode = 0555,
      -		.child = subdir,
      -	},
      -	{ }
      -};
      
      @initialize:python@
      @@
      
      def make_my_fresh_expression(s1, s2):
        return '"' + s1.strip('"') + "/" + s2.strip('"') + '"'
      
      @r3 depends on c1 && c2 && c3@
      expression c1.E1;
      identifier c1.sysctls;
      expression c2.E2;
      identifier c2.base;
      identifier c3.header;
      fresh identifier E3 = script:python(E2, E1) { make_my_fresh_expression(E2, E1) };
      @@
      
      header =
      -register_sysctl_table(base);
      +register_sysctl(E3, sysctls);
      
      Generated-by: Coccinelle SmPL
      Link: https://lkml.kernel.org/r/20211123202422.819032-4-mcgrof@kernel.org
      
      
      Signed-off-by: default avatarLuis Chamberlain <mcgrof@kernel.org>
      Cc: Al Viro <viro@zeniv.linux.org.uk>
      Cc: Amir Goldstein <amir73il@gmail.com>
      Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
      Cc: Antti Palosaari <crope@iki.fi>
      Cc: Arnd Bergmann <arnd@arndb.de>
      Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
      Cc: Benjamin LaHaise <bcrl@kvack.org>
      Cc: Clemens Ladisch <clemens@ladisch.de>
      Cc: David Airlie <airlied@linux.ie>
      Cc: "Eric W. Biederman" <ebiederm@xmission.com>
      Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
      Cc: Iurii Zaikin <yzaikin@google.com>
      Cc: Jani Nikula <jani.nikula@linux.intel.com>
      Cc: Jan Kara <jack@suse.cz>
      Cc: Joel Becker <jlbec@evilplan.org>
      Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
      Cc: Joseph Qi <joseph.qi@linux.alibaba.com>
      Cc: Julia Lawall <julia.lawall@inria.fr>
      Cc: Kees Cook <keescook@chromium.org>
      Cc: Lukas Middendorf <kernel@tuxforce.de>
      Cc: Mark Fasheh <mark@fasheh.com>
      Cc: Paul Turner <pjt@google.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Petr Mladek <pmladek@suse.com>
      Cc: Phillip Potter <phil@philpotter.co.uk>
      Cc: Qing Wang <wangqing@vivo.com>
      Cc: Rodrigo Vivi <rodrigo.vivi@intel.com>
      Cc: Sebastian Reichel <sre@kernel.org>
      Cc: Sergey Senozhatsky <senozhatsky@chromium.org>
      Cc: Stephen Kitt <steve@sk2.org>
      Cc: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
      Cc: Xiaoming Ni <nixiaoming@huawei.com>
      Cc: Douglas Gilbert <dgilbert@interlog.com>
      Cc: James E.J. Bottomley <jejb@linux.ibm.com>
      Cc: Jani Nikula <jani.nikula@intel.com>
      Cc: John Ogness <john.ogness@linutronix.de>
      Cc: Martin K. Petersen <martin.petersen@oracle.com>
      Cc: "Rafael J. Wysocki" <rafael@kernel.org>
      Cc: Steven Rostedt (VMware) <rostedt@goodmis.org>
      Cc: Suren Baghdasaryan <surenb@google.com>
      Cc: "Theodore Ts'o" <tytso@mit.edu>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      e99f5e74
    • Luis Chamberlain's avatar
      i915: simplify subdirectory registration with register_sysctl() · e5a1fd99
      Luis Chamberlain authored
      There is no need to user boiler plate code to specify a set of base
      directories we're going to stuff sysctls under.  Simplify this by using
      register_sysctl() and specifying the directory path directly.
      
      // pycocci sysctl-subdir-register-sysctl-simplify.cocci PATH
      
      @c1@
      expression E1;
      identifier subdir, sysctls;
      @@
      
      static struct ctl_table subdir[] = {
      	{
      		.procname = E1,
      		.maxlen = 0,
      		.mode = 0555,
      		.child = sysctls,
      	},
      	{ }
      };
      
      @c2@
      identifier c1.subdir;
      
      expression E2;
      identifier base;
      @@
      
      static struct ctl_table base[] = {
      	{
      		.procname = E2,
      		.maxlen = 0,
      		.mode = 0555,
      		.child = subdir,
      	},
      	{ }
      };
      
      @c3@
      identifier c2.base;
      identifier header;
      @@
      
      header = register_sysctl_table(base);
      
      @r1 depends on c1 && c2 && c3@
      expression c1.E1;
      identifier c1.subdir, c1.sysctls;
      @@
      
      -static struct ctl_table subdir[] = {
      -	{
      -		.procname = E1,
      -		.maxlen = 0,
      -		.mode = 0555,
      -		.child = sysctls,
      -	},
      -	{ }
      -};
      
      @r2 depends on c1 && c2 && c3@
      identifier c1.subdir;
      
      expression c2.E2;
      identifier c2.base;
      @@
      -static struct ctl_table base[] = {
      -	{
      -		.procname = E2,
      -		.maxlen = 0,
      -		.mode = 0555,
      -		.child = subdir,
      -	},
      -	{ }
      -};
      
      @initialize:python@
      @@
      
      def make_my_fresh_expression(s1, s2):
        return '"' + s1.strip('"') + "/" + s2.strip('"') + '"'
      
      @r3 depends on c1 && c2 && c3@
      expression c1.E1;
      identifier c1.sysctls;
      expression c2.E2;
      identifier c2.base;
      identifier c3.header;
      fresh identifier E3 = script:python(E2, E1) { make_my_fresh_expression(E2, E1) };
      @@
      
      header =
      -register_sysctl_table(base);
      +register_sysctl(E3, sysctls);
      
      Generated-by: Coccinelle SmPL
      Link: https://lkml.kernel.org/r/20211123202422.819032-3-mcgrof@kernel.org
      
      
      Signed-off-by: default avatarLuis Chamberlain <mcgrof@kernel.org>
      Acked-by: default avatarJani Nikula <jani.nikula@intel.com>
      Cc: Al Viro <viro@zeniv.linux.org.uk>
      Cc: Amir Goldstein <amir73il@gmail.com>
      Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
      Cc: Antti Palosaari <crope@iki.fi>
      Cc: Arnd Bergmann <arnd@arndb.de>
      Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
      Cc: Benjamin LaHaise <bcrl@kvack.org>
      Cc: Clemens Ladisch <clemens@ladisch.de>
      Cc: David Airlie <airlied@linux.ie>
      Cc: "Eric W. Biederman" <ebiederm@xmission.com>
      Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
      Cc: Iurii Zaikin <yzaikin@google.com>
      Cc: Jan Kara <jack@suse.cz>
      Cc: Joel Becker <jlbec@evilplan.org>
      Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
      Cc: Joseph Qi <joseph.qi@linux.alibaba.com>
      Cc: Julia Lawall <julia.lawall@inria.fr>
      Cc: Kees Cook <keescook@chromium.org>
      Cc: Lukas Middendorf <kernel@tuxforce.de>
      Cc: Mark Fasheh <mark@fasheh.com>
      Cc: Paul Turner <pjt@google.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Petr Mladek <pmladek@suse.com>
      Cc: Phillip Potter <phil@philpotter.co.uk>
      Cc: Qing Wang <wangqing@vivo.com>
      Cc: Rodrigo Vivi <rodrigo.vivi@intel.com>
      Cc: Sebastian Reichel <sre@kernel.org>
      Cc: Sergey Senozhatsky <senozhatsky@chromium.org>
      Cc: Stephen Kitt <steve@sk2.org>
      Cc: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
      Cc: Xiaoming Ni <nixiaoming@huawei.com>
      Cc: Douglas Gilbert <dgilbert@interlog.com>
      Cc: James E.J. Bottomley <jejb@linux.ibm.com>
      Cc: Jani Nikula <jani.nikula@linux.intel.com>
      Cc: John Ogness <john.ogness@linutronix.de>
      Cc: Martin K. Petersen <martin.petersen@oracle.com>
      Cc: "Rafael J. Wysocki" <rafael@kernel.org>
      Cc: Steven Rostedt (VMware) <rostedt@goodmis.org>
      Cc: Suren Baghdasaryan <surenb@google.com>
      Cc: "Theodore Ts'o" <tytso@mit.edu>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      e5a1fd99
    • Luis Chamberlain's avatar
      hpet: simplify subdirectory registration with register_sysctl() · c8dd5541
      Luis Chamberlain authored
      Patch series "sysctl: second set of kernel/sysctl cleanups", v2.
      
      This is the 2nd set of kernel/sysctl.c cleanups.  The diff stat should
      reflect how this is a much better way to deal with theses.  Fortunately
      coccinelle can be used to ensure correctness for most of these and/or
      future merge conflicts.
      
      Note that since this is part of a larger effort to cleanup
      kernel/sysctl.c I think we have no other option but to go with merging
      these patches in either Andrew's tree or keep them staged in a separate
      tree and send a merge request later.  Otherwise kernel/sysctl.c will end
      up becoming a sore spot for the next merge window.
      
      This patch (of 8):
      
      There is no need to user boiler plate code to specify a set of base
      directories we're going to stuff sysctls under.  Simplify this by using
      register_sysctl() and specifying the directory path directly.
      
      // pycocci sysctl-subdir-register-sysctl-simplify.cocci drivers/char/hpet.c
      
      @c1@
      expression E1;
      identifier subdir, sysctls;
      @@
      
      static struct ctl_table subdir[] = {
      	{
      		.procname = E1,
      		.maxlen = 0,
      		.mode = 0555,
      		.child = sysctls,
      	},
      	{ }
      };
      
      @c2@
      identifier c1.subdir;
      
      expression E2;
      identifier base;
      @@
      
      static struct ctl_table base[] = {
      	{
      		.procname = E2,
      		.maxlen = 0,
      		.mode = 0555,
      		.child = subdir,
      	},
      	{ }
      };
      
      @c3@
      identifier c2.base;
      identifier header;
      @@
      
      header = register_sysctl_table(base);
      
      @r1 depends on c1 && c2 && c3@
      expression c1.E1;
      identifier c1.subdir, c1.sysctls;
      @@
      
      -static struct ctl_table subdir[] = {
      -	{
      -		.procname = E1,
      -		.maxlen = 0,
      -		.mode = 0555,
      -		.child = sysctls,
      -	},
      -	{ }
      -};
      
      @r2 depends on c1 && c2 && c3@
      identifier c1.subdir;
      
      expression c2.E2;
      identifier c2.base;
      @@
      -static struct ctl_table base[] = {
      -	{
      -		.procname = E2,
      -		.maxlen = 0,
      -		.mode = 0555,
      -		.child = subdir,
      -	},
      -	{ }
      -};
      
      @initialize:python@
      @@
      
      def make_my_fresh_expression(s1, s2):
        return '"' + s1.strip('"') + "/" + s2.strip('"') + '"'
      
      @r3 depends on c1 && c2 && c3@
      expression c1.E1;
      identifier c1.sysctls;
      expression c2.E2;
      identifier c2.base;
      identifier c3.header;
      fresh identifier E3 = script:python(E2, E1) { make_my_fresh_expression(E2, E1) };
      @@
      
      header =
      -register_sysctl_table(base);
      +register_sysctl(E3, sysctls);
      
      Generated-by: Coccinelle SmPL
      
      Link: https://lkml.kernel.org/r/20211123202422.819032-1-mcgrof@kernel.org
      Link: https://lkml.kernel.org/r/20211123202422.819032-2-mcgrof@kernel.org
      
      
      Signed-off-by: default avatarLuis Chamberlain <mcgrof@kernel.org>
      Cc: Kees Cook <keescook@chromium.org>
      Cc: Iurii Zaikin <yzaikin@google.com>
      Cc: Xiaoming Ni <nixiaoming@huawei.com>
      Cc: "Eric W. Biederman" <ebiederm@xmission.com>
      Cc: Clemens Ladisch <clemens@ladisch.de>
      Cc: Arnd Bergmann <arnd@arndb.de>
      Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
      Cc: Jani Nikula <jani.nikula@linux.intel.com>
      Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
      Cc: Rodrigo Vivi <rodrigo.vivi@intel.com>
      Cc: David Airlie <airlied@linux.ie>
      Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
      Cc: Mark Fasheh <mark@fasheh.com>
      Cc: Joel Becker <jlbec@evilplan.org>
      Cc: Joseph Qi <joseph.qi@linux.alibaba.com>
      Cc: Jan Kara <jack@suse.cz>
      Cc: Amir Goldstein <amir73il@gmail.com>
      Cc: Phillip Potter <phil@philpotter.co.uk>
      Cc: Al Viro <viro@zeniv.linux.org.uk>
      Cc: Julia Lawall <julia.lawall@inria.fr>
      Cc: Lukas Middendorf <kernel@tuxforce.de>
      Cc: Antti Palosaari <crope@iki.fi>
      Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
      Cc: Benjamin LaHaise <bcrl@kvack.org>
      Cc: Paul Turner <pjt@google.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Petr Mladek <pmladek@suse.com>
      Cc: Qing Wang <wangqing@vivo.com>
      Cc: Sebastian Reichel <sre@kernel.org>
      Cc: Sergey Senozhatsky <senozhatsky@chromium.org>
      Cc: Stephen Kitt <steve@sk2.org>
      Cc: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
      Cc: Douglas Gilbert <dgilbert@interlog.com>
      Cc: James E.J. Bottomley <jejb@linux.ibm.com>
      Cc: Jani Nikula <jani.nikula@intel.com>
      Cc: John Ogness <john.ogness@linutronix.de>
      Cc: Martin K. Petersen <martin.petersen@oracle.com>
      Cc: "Rafael J. Wysocki" <rafael@kernel.org>
      Cc: Steven Rostedt (VMware) <rostedt@goodmis.org>
      Cc: Suren Baghdasaryan <surenb@google.com>
      Cc: "Theodore Ts'o" <tytso@mit.edu>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      c8dd5541
    • Xiaoming Ni's avatar
      dnotify: move dnotify sysctl to dnotify.c · 49a4de75
      Xiaoming Ni authored
      The kernel/sysctl.c is a kitchen sink where everyone leaves their dirty
      dishes, this makes it very difficult to maintain.
      
      To help with this maintenance let's start by moving sysctls to places
      where they actually belong.  The proc sysctl maintainers do not want to
      know what sysctl knobs you wish to add for your own piece of code, we
      just care about the core logic.
      
      So move dnotify sysctls to dnotify.c and use the new
      register_sysctl_init() to register the sysctl interface.
      
      [mcgrof@kernel.org: adjust the commit log to justify the move]
      
      Link: https://lkml.kernel.org/r/20211123202347.818157-10-mcgrof@kernel.org
      
      
      Signed-off-by: default avatarXiaoming Ni <nixiaoming@huawei.com>
      Signed-off-by: default avatarLuis Chamberlain <mcgrof@kernel.org>
      Acked-by: default avatarJan Kara <jack@suse.cz>
      Cc: Al Viro <viro@zeniv.linux.org.uk>
      Cc: Amir Goldstein <amir73il@gmail.com>
      Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
      Cc: Benjamin LaHaise <bcrl@kvack.org>
      Cc: "Eric W. Biederman" <ebiederm@xmission.com>
      Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
      Cc: Iurii Zaikin <yzaikin@google.com>
      Cc: Kees Cook <keescook@chromium.org>
      Cc: Paul Turner <pjt@google.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Petr Mladek <pmladek@suse.com>
      Cc: Qing Wang <wangqing@vivo.com>
      Cc: Sebastian Reichel <sre@kernel.org>
      Cc: Sergey Senozhatsky <senozhatsky@chromium.org>
      Cc: Stephen Kitt <steve@sk2.org>
      Cc: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
      Cc: Antti Palosaari <crope@iki.fi>
      Cc: Arnd Bergmann <arnd@arndb.de>
      Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
      Cc: Clemens Ladisch <clemens@ladisch.de>
      Cc: David Airlie <airlied@linux.ie>
      Cc: Jani Nikula <jani.nikula@linux.intel.com>
      Cc: Joel Becker <jlbec@evilplan.org>
      Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
      Cc: Joseph Qi <joseph.qi@linux.alibaba.com>
      Cc: Julia Lawall <julia.lawall@inria.fr>
      Cc: Lukas Middendorf <kernel@tuxforce.de>
      Cc: Mark Fasheh <mark@fasheh.com>
      Cc: Phillip Potter <phil@philpotter.co.uk>
      Cc: Rodrigo Vivi <rodrigo.vivi@intel.com>
      Cc: Douglas Gilbert <dgilbert@interlog.com>
      Cc: James E.J. Bottomley <jejb@linux.ibm.com>
      Cc: Jani Nikula <jani.nikula@intel.com>
      Cc: John Ogness <john.ogness@linutronix.de>
      Cc: Martin K. Petersen <martin.petersen@oracle.com>
      Cc: "Rafael J. Wysocki" <rafael@kernel.org>
      Cc: Steven Rostedt (VMware) <rostedt@goodmis.org>
      Cc: Suren Baghdasaryan <surenb@google.com>
      Cc: "Theodore Ts'o" <tytso@mit.edu>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      49a4de75
    • Xiaoming Ni's avatar
      aio: move aio sysctl to aio.c · 86b12b6c
      Xiaoming Ni authored
      The kernel/sysctl.c is a kitchen sink where everyone leaves their dirty
      dishes, this makes it very difficult to maintain.
      
      To help with this maintenance let's start by moving sysctls to places
      where they actually belong.  The proc sysctl maintainers do not want to
      know what sysctl knobs you wish to add for your own piece of code, we
      just care about the core logic.
      
      Move aio sysctl to aio.c and use the new register_sysctl_init() to
      register the sysctl interface for aio.
      
      [mcgrof@kernel.org: adjust commit log to justify the move]
      
      Link: https://lkml.kernel.org/r/20211123202347.818157-9-mcgrof@kernel.org
      
      
      Signed-off-by: default avatarXiaoming Ni <nixiaoming@huawei.com>
      Signed-off-by: default avatarLuis Chamberlain <mcgrof@kernel.org>
      Reviewed-by: default avatarJan Kara <jack@suse.cz>
      Cc: Al Viro <viro@zeniv.linux.org.uk>
      Cc: Amir Goldstein <amir73il@gmail.com>
      Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
      Cc: Benjamin LaHaise <bcrl@kvack.org>
      Cc: "Eric W. Biederman" <ebiederm@xmission.com>
      Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
      Cc: Iurii Zaikin <yzaikin@google.com>
      Cc: Kees Cook <keescook@chromium.org>
      Cc: Paul Turner <pjt@google.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Petr Mladek <pmladek@suse.com>
      Cc: Qing Wang <wangqing@vivo.com>
      Cc: Sebastian Reichel <sre@kernel.org>
      Cc: Sergey Senozhatsky <senozhatsky@chromium.org>
      Cc: Stephen Kitt <steve@sk2.org>
      Cc: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
      Cc: Antti Palosaari <crope@iki.fi>
      Cc: Arnd Bergmann <arnd@arndb.de>
      Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
      Cc: Clemens Ladisch <clemens@ladisch.de>
      Cc: David Airlie <airlied@linux.ie>
      Cc: Jani Nikula <jani.nikula@linux.intel.com>
      Cc: Joel Becker <jlbec@evilplan.org>
      Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
      Cc: Joseph Qi <joseph.qi@linux.alibaba.com>
      Cc: Julia Lawall <julia.lawall@inria.fr>
      Cc: Lukas Middendorf <kernel@tuxforce.de>
      Cc: Mark Fasheh <mark@fasheh.com>
      Cc: Phillip Potter <phil@philpotter.co.uk>
      Cc: Rodrigo Vivi <rodrigo.vivi@intel.com>
      Cc: Douglas Gilbert <dgilbert@interlog.com>
      Cc: James E.J. Bottomley <jejb@linux.ibm.com>
      Cc: Jani Nikula <jani.nikula@intel.com>
      Cc: John Ogness <john.ogness@linutronix.de>
      Cc: Martin K. Petersen <martin.petersen@oracle.com>
      Cc: "Rafael J. Wysocki" <rafael@kernel.org>
      Cc: Steven Rostedt (VMware) <rostedt@goodmis.org>
      Cc: Suren Baghdasaryan <surenb@google.com>
      Cc: "Theodore Ts'o" <tytso@mit.edu>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      86b12b6c
    • Xiaoming Ni's avatar
      sysctl: use SYSCTL_ZERO to replace some static int zero uses · 2452dcb9
      Xiaoming Ni authored
      Use the variable SYSCTL_ZERO to replace some static int boundary
      variables with a value of 0 (minolduid, min_extfrag_threshold,
      min_wakeup_granularity_ns).
      
      Link: https://lkml.kernel.org/r/20211123202347.818157-8-mcgrof@kernel.org
      
      
      Signed-off-by: default avatarXiaoming Ni <nixiaoming@huawei.com>
      Signed-off-by: default avatarLuis Chamberlain <mcgrof@kernel.org>
      Cc: Al Viro <viro@zeniv.linux.org.uk>
      Cc: Amir Goldstein <amir73il@gmail.com>
      Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
      Cc: Benjamin LaHaise <bcrl@kvack.org>
      Cc: "Eric W. Biederman" <ebiederm@xmission.com>
      Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
      Cc: Iurii Zaikin <yzaikin@google.com>
      Cc: Jan Kara <jack@suse.cz>
      Cc: Kees Cook <keescook@chromium.org>
      Cc: Paul Turner <pjt@google.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Petr Mladek <pmladek@suse.com>
      Cc: Qing Wang <wangqing@vivo.com>
      Cc: Sebastian Reichel <sre@kernel.org>
      Cc: Sergey Senozhatsky <senozhatsky@chromium.org>
      Cc: Stephen Kitt <steve@sk2.org>
      Cc: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
      Cc: Antti Palosaari <crope@iki.fi>
      Cc: Arnd Bergmann <arnd@arndb.de>
      Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
      Cc: Clemens Ladisch <clemens@ladisch.de>
      Cc: David Airlie <airlied@linux.ie>
      Cc: Jani Nikula <jani.nikula@linux.intel.com>
      Cc: Joel Becker <jlbec@evilplan.org>
      Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
      Cc: Joseph Qi <joseph.qi@linux.alibaba.com>
      Cc: Julia Lawall <julia.lawall@inria.fr>
      Cc: Lukas Middendorf <kernel@tuxforce.de>
      Cc: Mark Fasheh <mark@fasheh.com>
      Cc: Phillip Potter <phil@philpotter.co.uk>
      Cc: Rodrigo Vivi <rodrigo.vivi@intel.com>
      Cc: Douglas Gilbert <dgilbert@interlog.com>
      Cc: James E.J. Bottomley <jejb@linux.ibm.com>
      Cc: Jani Nikula <jani.nikula@intel.com>
      Cc: John Ogness <john.ogness@linutronix.de>
      Cc: Martin K. Petersen <martin.petersen@oracle.com>
      Cc: "Rafael J. Wysocki" <rafael@kernel.org>
      Cc: Steven Rostedt (VMware) <rostedt@goodmis.org>
      Cc: Suren Baghdasaryan <surenb@google.com>
      Cc: "Theodore Ts'o" <tytso@mit.edu>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      2452dcb9
    • Xiaoming Ni's avatar
      sysctl: use const for typically used max/min proc sysctls · d73840ec
      Xiaoming Ni authored
      When proc_dointvec_minmax() or proc_doulongvec_minmax() are used we are
      using the extra1 and extra2 parameters on the sysctl table only for a
      min and max boundary, these extra1 and extra2 arguments are then used
      for read-only operations.  So make them const to reflect this.
      
      [mcgrof@kernel.org: commit log love]
      
      Link: https://lkml.kernel.org/r/20211123202347.818157-7-mcgrof@kernel.org
      
      
      Signed-off-by: default avatarXiaoming Ni <nixiaoming@huawei.com>
      Signed-off-by: default avatarLuis Chamberlain <mcgrof@kernel.org>
      Cc: Al Viro <viro@zeniv.linux.org.uk>
      Cc: Amir Goldstein <amir73il@gmail.com>
      Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
      Cc: Benjamin LaHaise <bcrl@kvack.org>
      Cc: "Eric W. Biederman" <ebiederm@xmission.com>
      Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
      Cc: Iurii Zaikin <yzaikin@google.com>
      Cc: Jan Kara <jack@suse.cz>
      Cc: Kees Cook <keescook@chromium.org>
      Cc: Paul Turner <pjt@google.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Petr Mladek <pmladek@suse.com>
      Cc: Qing Wang <wangqing@vivo.com>
      Cc: Sebastian Reichel <sre@kernel.org>
      Cc: Sergey Senozhatsky <senozhatsky@chromium.org>
      Cc: Stephen Kitt <steve@sk2.org>
      Cc: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
      Cc: Antti Palosaari <crope@iki.fi>
      Cc: Arnd Bergmann <arnd@arndb.de>
      Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
      Cc: Clemens Ladisch <clemens@ladisch.de>
      Cc: David Airlie <airlied@linux.ie>
      Cc: Jani Nikula <jani.nikula@linux.intel.com>
      Cc: Joel Becker <jlbec@evilplan.org>
      Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
      Cc: Joseph Qi <joseph.qi@linux.alibaba.com>
      Cc: Julia Lawall <julia.lawall@inria.fr>
      Cc: Lukas Middendorf <kernel@tuxforce.de>
      Cc: Mark Fasheh <mark@fasheh.com>
      Cc: Phillip Potter <phil@philpotter.co.uk>
      Cc: Rodrigo Vivi <rodrigo.vivi@intel.com>
      Cc: Douglas Gilbert <dgilbert@interlog.com>
      Cc: James E.J. Bottomley <jejb@linux.ibm.com>
      Cc: Jani Nikula <jani.nikula@intel.com>
      Cc: John Ogness <john.ogness@linutronix.de>
      Cc: Martin K. Petersen <martin.petersen@oracle.com>
      Cc: "Rafael J. Wysocki" <rafael@kernel.org>
      Cc: Steven Rostedt (VMware) <rostedt@goodmis.org>
      Cc: Suren Baghdasaryan <surenb@google.com>
      Cc: "Theodore Ts'o" <tytso@mit.edu>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      d73840ec
    • Stephen Kitt's avatar
      sysctl: make ngroups_max const · f628867d
      Stephen Kitt authored
      ngroups_max is a read-only sysctl entry, reflecting NGROUPS_MAX.  Make
      it const, in the same way as cap_last_cap.
      
      Link: https://lkml.kernel.org/r/20211123202347.818157-6-mcgrof@kernel.org
      
      
      Signed-off-by: default avatarStephen Kitt <steve@sk2.org>
      Signed-off-by: default avatarLuis Chamberlain <mcgrof@kernel.org>
      Cc: Al Viro <viro@zeniv.linux.org.uk>
      Cc: Amir Goldstein <amir73il@gmail.com>
      Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
      Cc: Benjamin LaHaise <bcrl@kvack.org>
      Cc: "Eric W. Biederman" <ebiederm@xmission.com>
      Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
      Cc: Iurii Zaikin <yzaikin@google.com>
      Cc: Jan Kara <jack@suse.cz>
      Cc: Kees Cook <keescook@chromium.org>
      Cc: Paul Turner <pjt@google.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Petr Mladek <pmladek@suse.com>
      Cc: Qing Wang <wangqing@vivo.com>
      Cc: Sebastian Reichel <sre@kernel.org>
      Cc: Sergey Senozhatsky <senozhatsky@chromium.org>
      Cc: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
      Cc: Xiaoming Ni <nixiaoming@huawei.com>
      Cc: Antti Palosaari <crope@iki.fi>
      Cc: Arnd Bergmann <arnd@arndb.de>
      Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
      Cc: Clemens Ladisch <clemens@ladisch.de>
      Cc: David Airlie <airlied@linux.ie>
      Cc: Jani Nikula <jani.nikula@linux.intel.com>
      Cc: Joel Becker <jlbec@evilplan.org>
      Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
      Cc: Joseph Qi <joseph.qi@linux.alibaba.com>
      Cc: Julia Lawall <julia.lawall@inria.fr>
      Cc: Lukas Middendorf <kernel@tuxforce.de>
      Cc: Mark Fasheh <mark@fasheh.com>
      Cc: Phillip Potter <phil@philpotter.co.uk>
      Cc: Rodrigo Vivi <rodrigo.vivi@intel.com>
      Cc: Douglas Gilbert <dgilbert@interlog.com>
      Cc: James E.J. Bottomley <jejb@linux.ibm.com>
      Cc: Jani Nikula <jani.nikula@intel.com>
      Cc: John Ogness <john.ogness@linutronix.de>
      Cc: Martin K. Petersen <martin.petersen@oracle.com>
      Cc: "Rafael J. Wysocki" <rafael@kernel.org>
      Cc: Steven Rostedt (VMware) <rostedt@goodmis.org>
      Cc: Suren Baghdasaryan <surenb@google.com>
      Cc: "Theodore Ts'o" <tytso@mit.edu>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      f628867d
    • Xiaoming Ni's avatar
      watchdog: move watchdog sysctl interface to watchdog.c · dd0693fd
      Xiaoming Ni authored
      The kernel/sysctl.c is a kitchen sink where everyone leaves their dirty
      dishes, this makes it very difficult to maintain.
      
      To help with this maintenance let's start by moving sysctls to places
      where they actually belong.  The proc sysctl maintainers do not want to
      know what sysctl knobs you wish to add for your own piece of code, we
      just care about the core logic of proc sysctl.
      
      So, move the watchdog syscl interface to watchdog.c.  Use
      register_sysctl() to register the sysctl interface to avoid merge
      conflicts when different features modify sysctl.c at the same time.
      
      [mcgrof@kernel.org: justify the move on the commit log]
      
      Link: https://lkml.kernel.org/r/20211123202347.818157-5-mcgrof@kernel.org
      
      
      Signed-off-by: default avatarXiaoming Ni <nixiaoming@huawei.com>
      Signed-off-by: default avatarLuis Chamberlain <mcgrof@kernel.org>
      Reviewed-by: default avatarKees Cook <keescook@chromium.org>
      Reviewed-by: default avatarPetr Mladek <pmladek@suse.com>
      Cc: Al Viro <viro@zeniv.linux.org.uk>
      Cc: Amir Goldstein <amir73il@gmail.com>
      Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
      Cc: Benjamin LaHaise <bcrl@kvack.org>
      Cc: "Eric W. Biederman" <ebiederm@xmission.com>
      Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
      Cc: Iurii Zaikin <yzaikin@google.com>
      Cc: Jan Kara <jack@suse.cz>
      Cc: Paul Turner <pjt@google.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Qing Wang <wangqing@vivo.com>
      Cc: Sebastian Reichel <sre@kernel.org>
      Cc: Sergey Senozhatsky <senozhatsky@chromium.org>
      Cc: Stephen Kitt <steve@sk2.org>
      Cc: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
      Cc: Antti Palosaari <crope@iki.fi>
      Cc: Arnd Bergmann <arnd@arndb.de>
      Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
      Cc: Clemens Ladisch <clemens@ladisch.de>
      Cc: David Airlie <airlied@linux.ie>
      Cc: Jani Nikula <jani.nikula@linux.intel.com>
      Cc: Joel Becker <jlbec@evilplan.org>
      Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
      Cc: Joseph Qi <joseph.qi@linux.alibaba.com>
      Cc: Julia Lawall <julia.lawall@inria.fr>
      Cc: Lukas Middendorf <kernel@tuxforce.de>
      Cc: Mark Fasheh <mark@fasheh.com>
      Cc: Phillip Potter <phil@philpotter.co.uk>
      Cc: Rodrigo Vivi <rodrigo.vivi@intel.com>
      Cc: Douglas Gilbert <dgilbert@interlog.com>
      Cc: James E.J. Bottomley <jejb@linux.ibm.com>
      Cc: Jani Nikula <jani.nikula@intel.com>
      Cc: John Ogness <john.ogness@linutronix.de>
      Cc: Martin K. Petersen <martin.petersen@oracle.com>
      Cc: "Rafael J. Wysocki" <rafael@kernel.org>
      Cc: Steven Rostedt (VMware) <rostedt@goodmis.org>
      Cc: Suren Baghdasaryan <surenb@google.com>
      Cc: "Theodore Ts'o" <tytso@mit.edu>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      dd0693fd
    • Xiaoming Ni's avatar
      hung_task: move hung_task sysctl interface to hung_task.c · bbe7a10e
      Xiaoming Ni authored
      The kernel/sysctl.c is a kitchen sink where everyone leaves their dirty
      dishes, this makes it very difficult to maintain.
      
      To help with this maintenance let's start by moving sysctls to places
      where they actually belong.  The proc sysctl maintainers do not want to
      know what sysctl knobs you wish to add for your own piece of code, we
      just care about the core logic.
      
      So move hung_task sysctl interface to hung_task.c and use
      register_sysctl() to register the sysctl interface.
      
      [mcgrof@kernel.org: commit log refresh and fixed 2-3 0day reported compile issues]
      
      Link: https://lkml.kernel.org/r/20211123202347.818157-4-mcgrof@kernel.org
      
      
      Signed-off-by: default avatarXiaoming Ni <nixiaoming@huawei.com>
      Signed-off-by: default avatarLuis Chamberlain <mcgrof@kernel.org>
      Reviewed-by: default avatarKees Cook <keescook@chromium.org>
      Reviewed-by: default avatarPetr Mladek <pmladek@suse.com>
      Cc: Al Viro <viro@zeniv.linux.org.uk>
      Cc: Amir Goldstein <amir73il@gmail.com>
      Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
      Cc: Benjamin LaHaise <bcrl@kvack.org>
      Cc: "Eric W. Biederman" <ebiederm@xmission.com>
      Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
      Cc: Iurii Zaikin <yzaikin@google.com>
      Cc: Jan Kara <jack@suse.cz>
      Cc: Paul Turner <pjt@google.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Qing Wang <wangqing@vivo.com>
      Cc: Sebastian Reichel <sre@kernel.org>
      Cc: Sergey Senozhatsky <senozhatsky@chromium.org>
      Cc: Stephen Kitt <steve@sk2.org>
      Cc: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
      Cc: Antti Palosaari <crope@iki.fi>
      Cc: Arnd Bergmann <arnd@arndb.de>
      Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
      Cc: Clemens Ladisch <clemens@ladisch.de>
      Cc: David Airlie <airlied@linux.ie>
      Cc: Jani Nikula <jani.nikula@linux.intel.com>
      Cc: Joel Becker <jlbec@evilplan.org>
      Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
      Cc: Joseph Qi <joseph.qi@linux.alibaba.com>
      Cc: Julia Lawall <julia.lawall@inria.fr>
      Cc: Lukas Middendorf <kernel@tuxforce.de>
      Cc: Mark Fasheh <mark@fasheh.com>
      Cc: Phillip Potter <phil@philpotter.co.uk>
      Cc: Rodrigo Vivi <rodrigo.vivi@intel.com>
      Cc: Douglas Gilbert <dgilbert@interlog.com>
      Cc: James E.J. Bottomley <jejb@linux.ibm.com>
      Cc: Jani Nikula <jani.nikula@intel.com>
      Cc: John Ogness <john.ogness@linutronix.de>
      Cc: Martin K. Petersen <martin.petersen@oracle.com>
      Cc: "Rafael J. Wysocki" <rafael@kernel.org>
      Cc: Steven Rostedt (VMware) <rostedt@goodmis.org>
      Cc: Suren Baghdasaryan <surenb@google.com>
      Cc: "Theodore Ts'o" <tytso@mit.edu>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      bbe7a10e
    • Xiaoming Ni's avatar
      sysctl: move some boundary constants from sysctl.c to sysctl_vals · 78e36f3b
      Xiaoming Ni authored
      sysctl has helpers which let us specify boundary values for a min or max
      int value.  Since these are used for a boundary check only they don't
      change, so move these variables to sysctl_vals to avoid adding duplicate
      variables.  This will help with our cleanup of kernel/sysctl.c.
      
      [akpm@linux-foundation.org: update it for "mm/pagealloc: sysctl: change watermark_scale_factor max limit to 30%"]
      [mcgrof@kernel.org: major rebase]
      
      Link: https://lkml.kernel.org/r/20211123202347.818157-3-mcgrof@kernel.org
      
      
      Signed-off-by: default avatarXiaoming Ni <nixiaoming@huawei.com>
      Signed-off-by: default avatarLuis Chamberlain <mcgrof@kernel.org>
      Reviewed-by: default avatarKees Cook <keescook@chromium.org>
      Cc: Al Viro <viro@zeniv.linux.org.uk>
      Cc: Amir Goldstein <amir73il@gmail.com>
      Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
      Cc: Benjamin LaHaise <bcrl@kvack.org>
      Cc: "Eric W. Biederman" <ebiederm@xmission.com>
      Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
      Cc: Iurii Zaikin <yzaikin@google.com>
      Cc: Jan Kara <jack@suse.cz>
      Cc: Paul Turner <pjt@google.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Petr Mladek <pmladek@suse.com>
      Cc: Qing Wang <wangqing@vivo.com>
      Cc: Sebastian Reichel <sre@kernel.org>
      Cc: Sergey Senozhatsky <senozhatsky@chromium.org>
      Cc: Stephen Kitt <steve@sk2.org>
      Cc: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
      Cc: Antti Palosaari <crope@iki.fi>
      Cc: Arnd Bergmann <arnd@arndb.de>
      Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
      Cc: Clemens Ladisch <clemens@ladisch.de>
      Cc: David Airlie <airlied@linux.ie>
      Cc: Jani Nikula <jani.nikula@linux.intel.com>
      Cc: Joel Becker <jlbec@evilplan.org>
      Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
      Cc: Joseph Qi <joseph.qi@linux.alibaba.com>
      Cc: Julia Lawall <julia.lawall@inria.fr>
      Cc: Lukas Middendorf <kernel@tuxforce.de>
      Cc: Mark Fasheh <mark@fasheh.com>
      Cc: Phillip Potter <phil@philpotter.co.uk>
      Cc: Rodrigo Vivi <rodrigo.vivi@intel.com>
      Cc: Douglas Gilbert <dgilbert@interlog.com>
      Cc: James E.J. Bottomley <jejb@linux.ibm.com>
      Cc: Jani Nikula <jani.nikula@intel.com>
      Cc: John Ogness <john.ogness@linutronix.de>
      Cc: Martin K. Petersen <martin.petersen@oracle.com>
      Cc: "Rafael J. Wysocki" <rafael@kernel.org>
      Cc: Steven Rostedt (VMware) <rostedt@goodmis.org>
      Cc: Suren Baghdasaryan <surenb@google.com>
      Cc: "Theodore Ts'o" <tytso@mit.edu>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      78e36f3b
    • Xiaoming Ni's avatar
      sysctl: add a new register_sysctl_init() interface · 3ddd9a80
      Xiaoming Ni authored
      Patch series "sysctl: first set of kernel/sysctl cleanups", v2.
      
      Finally had time to respin the series of the work we had started last
      year on cleaning up the kernel/sysct.c kitchen sink.  People keeps
      stuffing their sysctls in that file and this creates a maintenance
      burden.  So this effort is aimed at placing sysctls where they actually
      belong.
      
      I'm going to split patches up into series as there is quite a bit of
      work.
      
      This first set adds register_sysctl_init() for uses of registerting a
      sysctl on the init path, adds const where missing to a few places,
      generalizes common values so to be more easy to share, and starts the
      move of a few kernel/sysctl.c out where they belong.
      
      The majority of rework on v2 in this first patch set is 0-day fixes.
      Eric Biederman's feedback is later addressed in subsequent patch sets.
      
      I'll only post the first two patch sets for now.  We can address the
      rest once the first two patch sets get completely reviewed / Acked.
      
      This patch (of 9):
      
      The kernel/sysctl.c is a kitchen sink where everyone leaves their dirty
      dishes, this makes it very difficult to maintain.
      
      To help with this maintenance let's start by moving sysctls to places
      where they actually belong.  The proc sysctl maintainers do not want to
      know what sysctl knobs you wish to add for your own piece of code, we
      just care about the core logic.
      
      Today though folks heavily rely on tables on kernel/sysctl.c so they can
      easily just extend this table with their needed sysctls.  In order to
      help users move their sysctls out we need to provide a helper which can
      be used during code initialization.
      
      We special-case the initialization use of register_sysctl() since it
      *is* safe to fail, given all that sysctls do is provide a dynamic
      interface to query or modify at runtime an existing variable.  So the
      use case of register_sysctl() on init should *not* stop if the sysctls
      don't end up getting registered.  It would be counter productive to stop
      boot if a simple sysctl registration failed.
      
      Provide a helper for init then, and document the recommended init levels
      to use for callers of this routine.  We will later use this in
      subsequent patches to start slimming down kernel/sysctl.c tables and
      moving sysctl registration to the code which actually needs these
      sysctls.
      
      [mcgrof@kernel.org: major commit log and documentation rephrasing also moved to fs/proc/proc_sysctl.c                  ]
      
      Link: https://lkml.kernel.org/r/20211123202347.818157-1-mcgrof@kernel.org
      Link: https://lkml.kernel.org/r/20211123202347.818157-2-mcgrof@kernel.org
      
      
      Signed-off-by: default avatarXiaoming Ni <nixiaoming@huawei.com>
      Signed-off-by: default avatarLuis Chamberlain <mcgrof@kernel.org>
      Reviewed-by: default avatarKees Cook <keescook@chromium.org>
      Cc: Iurii Zaikin <yzaikin@google.com>
      Cc: "Eric W. Biederman" <ebiederm@xmission.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
      Cc: Paul Turner <pjt@google.com>
      Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
      Cc: Sebastian Reichel <sre@kernel.org>
      Cc: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
      Cc: Petr Mladek <pmladek@suse.com>
      Cc: Sergey Senozhatsky <senozhatsky@chromium.org>
      Cc: Qing Wang <wangqing@vivo.com>
      Cc: Benjamin LaHaise <bcrl@kvack.org>
      Cc: Al Viro <viro@zeniv.linux.org.uk>
      Cc: Jan Kara <jack@suse.cz>
      Cc: Amir Goldstein <amir73il@gmail.com>
      Cc: Stephen Kitt <steve@sk2.org>
      Cc: Antti Palosaari <crope@iki.fi>
      Cc: Arnd Bergmann <arnd@arndb.de>
      Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
      Cc: Clemens Ladisch <clemens@ladisch.de>
      Cc: David Airlie <airlied@linux.ie>
      Cc: Jani Nikula <jani.nikula@linux.intel.com>
      Cc: Joel Becker <jlbec@evilplan.org>
      Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
      Cc: Joseph Qi <joseph.qi@linux.alibaba.com>
      Cc: Julia Lawall <julia.lawall@inria.fr>
      Cc: Lukas Middendorf <kernel@tuxforce.de>
      Cc: Mark Fasheh <mark@fasheh.com>
      Cc: Phillip Potter <phil@philpotter.co.uk>
      Cc: Rodrigo Vivi <rodrigo.vivi@intel.com>
      Cc: Douglas Gilbert <dgilbert@interlog.com>
      Cc: James E.J. Bottomley <jejb@linux.ibm.com>
      Cc: Jani Nikula <jani.nikula@intel.com>
      Cc: John Ogness <john.ogness@linutronix.de>
      Cc: Martin K. Petersen <martin.petersen@oracle.com>
      Cc: "Rafael J. Wysocki" <rafael@kernel.org>
      Cc: Steven Rostedt (VMware) <rostedt@goodmis.org>
      Cc: Suren Baghdasaryan <surenb@google.com>
      Cc: "Theodore Ts'o" <tytso@mit.edu>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      3ddd9a80
    • Alistair Popple's avatar
      mm/migrate.c: rework migration_entry_wait() to not take a pageref · ffa65753
      Alistair Popple authored
      This fixes the FIXME in migrate_vma_check_page().
      
      Before migrating a page migration code will take a reference and check
      there are no unexpected page references, failing the migration if there
      are.  When a thread faults on a migration entry it will take a temporary
      reference to the page to wait for the page to become unlocked signifying
      the migration entry has been removed.
      
      This reference is dropped just prior to waiting on the page lock,
      however the extra reference can cause migration failures so it is
      desirable to avoid taking it.
      
      As migration code already has a reference to the migrating page an extra
      reference to wait on PG_locked is unnecessary so long as the reference
      can't be dropped whilst setting up the wait.
      
      When faulting on a migration entry the ptl is taken to check the
      migration entry.  Removing a migration entry also requires the ptl, and
      migration code won't drop its page reference until after the migration
      entry has been removed.  Therefore retaining the ptl of a migration
      entry is sufficient to ensure the page has a reference.  Reworking
      migration_entry_wait() to hold the ptl until the wait setup is complete
      means the extra page reference is no longer needed.
      
      [apopple@nvidia.com: v5]
        Link: https://lkml.kernel.org/r/20211213033848.1973946-1-apopple@nvidia.com
      
      Link: https://lkml.kernel.org/r/20211118020754.954425-1-apopple@nvidia.com
      
      
      Signed-off-by: default avatarAlistair Popple <apopple@nvidia.com>
      Acked-by: default avatarDavid Hildenbrand <david@redhat.com>
      Cc: David Howells <dhowells@redhat.com>
      Cc: Hugh Dickins <hughd@google.com>
      Cc: Jason Gunthorpe <jgg@nvidia.com>
      Cc: Jerome Glisse <jglisse@redhat.com>
      Cc: John Hubbard <jhubbard@nvidia.com>
      Cc: Matthew Wilcox (Oracle) <willy@infradead.org>
      Cc: Ralph Campbell <rcampbell@nvidia.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      ffa65753
  2. Jan 21, 2022
    • Linus Torvalds's avatar
      Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/hid/hid · 9b57f458
      Linus Torvalds authored
      Pull HID fixes from Jiri Kosina:
      
       - fix for race condition that could lead to NULL pointer dereferences
         or UAF during uhid device destruction (Jann Horn)
      
       - contact count handling regression fixes for Wacom devices (Jason
         Gerecke)
      
       - fix for handling unnumbered HID reports handling in Google Vivaldi
         driver (Dmitry Torokhov)
      
      * 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/hid/hid:
        HID: wacom: Avoid using stale array indicies to read contact count
        HID: wacom: Ignore the confidence flag when a touch is removed
        HID: wacom: Reset expected and received contact counts at the same time
        HID: uhid: Use READ_ONCE()/WRITE_ONCE() for ->running
        HID: uhid: Fix worker destroying device without any protection
        HID: vivaldi: Minor cleanups
        HID: vivaldi: fix handling devices not using numbered reports
        HID: Ignore battery for Elan touchscreen on HP Envy X360 15t-dr100
      9b57f458
    • Linus Torvalds's avatar
      Merge tag 'block-5.17-2022-01-21' of git://git.kernel.dk/linux-block · 3c7c2503
      Linus Torvalds authored
      Pull block fixes from Jens Axboe:
       "Various little minor fixes that should go into this release:
      
         - Fix issue with cloned bios and IO accounting (Christoph)
      
         - Remove redundant assignments (Colin, GuoYong)
      
         - Fix an issue with the mq-deadline async_depth sysfs interface (me)
      
         - Fix brd module loading race (Tetsuo)
      
         - Shared tag map wakeup fix (Laibin)
      
         - End of bdev read fix (OGAWA)
      
         - srcu leak fix (Ming)"
      
      * tag 'block-5.17-2022-01-21' of git://git.kernel.dk/linux-block:
        block: fix async_depth sysfs interface for mq-deadline
        block: Fix wrong offset in bio_truncate()
        block: assign bi_bdev for cloned bios in blk_rq_prep_clone
        block: cleanup q->srcu
        block: Remove unnecessary variable assignment
        brd: remove brd_devices_mutex mutex
        aoe: remove redundant assignment on variable n
        loop: remove redundant initialization of pointer node
        blk-mq: fix tag_get wait task can't be awakened
      3c7c2503
    • Jason Gerecke's avatar
      HID: wacom: Avoid using stale array indicies to read contact count · 20f3cf5f
      Jason Gerecke authored
      If we ever see a touch report with contact count data we initialize
      several variables used to read the contact count in the pre-report
      phase. These variables are never reset if we process a report which
      doesn't contain a contact count, however. This can cause the pre-
      report function to trigger a read of arbitrary memory (e.g. NULL
      if we're lucky) and potentially crash the driver.
      
      This commit restores resetting of the variables back to default
      "none" values that were used prior to the commit mentioned
      below.
      
      Link: https://github.com/linuxwacom/input-wacom/issues/276
      Fixes: 003f50ab
      
       (HID: wacom: Update last_slot_field during pre_report phase)
      CC: stable@vger.kernel.org
      Signed-off-by: default avatarJason Gerecke <jason.gerecke@wacom.com>
      Reviewed-by: default avatarPing Cheng <ping.cheng@wacom.com>
      Signed-off-by: default avatarJiri Kosina <jkosina@suse.cz>
      20f3cf5f