1. 28 Apr, 2023 1 commit
    • Randy Dunlap's avatar
      lsm: move hook comments docs to security/security.c · 6d2ed653
      Randy Dunlap authored
      Fix one kernel-doc warning, but invesigating that led to other
      kernel-doc movement (lsm_hooks.h to security.c) that needs to be
      fixed also.
      
      include/linux/lsm_hooks.h:1: warning: no structured comments found
      
      Fixes: e261301c ("lsm: move the remaining LSM hook comments to security/security.c")
      Fixes: 1cd2aca6 ("lsm: move the io_uring hook comments to security/security.c")
      Fixes: 452b670c ("lsm: move the perf hook comments to security/security.c")
      Fixes: 55e85320 ("lsm: move the bpf hook comments to security/security.c")
      Fixes: b14faf9c ("lsm: move the audit hook comments to security/security.c")
      Fixes: 1427ddbe ("lsm: move the binder hook comments to security/security.c")
      Fixes: 43fad282 ("lsm: move the sysv hook comments to security/security.c")
      Fixes: ecc419a4 ("lsm: move the key hook comments to security/security.c")
      Fixes: 742b9945 ("lsm: move the xfrm hook comments to security/security.c")
      Fixes: ac318aed ("lsm: move the Infiniband hook comments to security/security.c")
      Fixes: 4a49f592 ("lsm: move the SCTP hook comments to security/security.c")
      Fixes: 6b6bbe8c ("lsm: move the socket hook comments to security/security.c")
      Fixes: 2c2442fd ("lsm: move the AF_UNIX hook comments to security/security.c")
      Fixes: 2bcf51bf ("lsm: move the netlink hook comments to security/security.c")
      Fixes: 130c53bf ("lsm: move the task hook comments to security/security.c")
      Fixes: a0fd6480 ("lsm: move the file hook comments to security/security.c")
      Fixes: 9348944b ("lsm: move the kernfs hook comments to security/security.c")
      Fixes: 916e3258 ("lsm: move the inode hook comments to security/security.c")
      Fixes: 08526a90 ("lsm: move the filesystem hook comments to security/security.c")
      Fixes: 36819f18 ("lsm: move the fs_context hook comments to security/security.c")
      Fixes: 1661372c ("lsm: move the program execution hook comments to security/security.c")
      Signed-off-by: default avatarRandy Dunlap <rdunlap@infradead.org>
      Cc: Paul Moore <paul@paul-moore.com>
      Cc: James Morris <jmorris@namei.org>
      Cc: "Serge E. Hallyn" <serge@hallyn.com>
      Cc: linux-security-module@vger.kernel.org
      Cc: Jonathan Corbet <corbet@lwn.net>
      Cc: linux-doc@vger.kernel.org
      Cc: KP Singh <kpsingh@kernel.org>
      Cc: bpf@vger.kernel.org
      Signed-off-by: default avatarPaul Moore <paul@paul-moore.com>
      6d2ed653
  2. 04 Apr, 2023 1 commit
    • Roberto Sassu's avatar
      reiserfs: Add security prefix to xattr name in reiserfs_security_write() · d82dcd9e
      Roberto Sassu authored
      Reiserfs sets a security xattr at inode creation time in two stages: first,
      it calls reiserfs_security_init() to obtain the xattr from active LSMs;
      then, it calls reiserfs_security_write() to actually write that xattr.
      
      Unfortunately, it seems there is a wrong expectation that LSMs provide the
      full xattr name in the form 'security.<suffix>'. However, LSMs always
      provided just the suffix, causing reiserfs to not write the xattr at all
      (if the suffix is shorter than the prefix), or to write an xattr with the
      wrong name.
      
      Add a temporary buffer in reiserfs_security_write(), and write to it the
      full xattr name, before passing it to reiserfs_xattr_set_handle().
      
      Also replace the name length check with a check that the full xattr name is
      not larger than XATTR_NAME_MAX.
      
      Cc: stable@vger.kernel.org # v2.6.x
      Fixes: 57fe60df ("reiserfs: add atomic addition of selinux attributes during inode creation")
      Signed-off-by: default avatarRoberto Sassu <roberto.sassu@huawei.com>
      Signed-off-by: default avatarPaul Moore <paul@paul-moore.com>
      d82dcd9e
  3. 23 Mar, 2023 3 commits
    • Roberto Sassu's avatar
      security: Remove security_old_inode_init_security() · 0d57b970
      Roberto Sassu authored
      As the remaining two users reiserfs and ocfs2 switched to
      security_inode_init_security(), security_old_inode_init_security() can be
      now removed.
      
      Out-of-tree kernel modules should switch to security_inode_init_security()
      too.
      Signed-off-by: default avatarRoberto Sassu <roberto.sassu@huawei.com>
      Reviewed-by: default avatarCasey Schaufler <casey@schaufler-ca.com>
      Reviewed-by: default avatarMimi Zohar <zohar@linux.ibm.com>
      Signed-off-by: default avatarPaul Moore <paul@paul-moore.com>
      0d57b970
    • Roberto Sassu's avatar
      ocfs2: Switch to security_inode_init_security() · de3004c8
      Roberto Sassu authored
      In preparation for removing security_old_inode_init_security(), switch to
      security_inode_init_security().
      
      Extend the existing ocfs2_initxattrs() to take the
      ocfs2_security_xattr_info structure from fs_info, and populate the
      name/value/len triple with the first xattr provided by LSMs.
      
      As fs_info was not used before, ocfs2_initxattrs() can now handle the case
      of replicating the behavior of security_old_inode_init_security(), i.e.
      just obtaining the xattr, in addition to setting all xattrs provided by
      LSMs.
      
      Supporting multiple xattrs is not currently supported where
      security_old_inode_init_security() was called (mknod, symlink), as it
      requires non-trivial changes that can be done at a later time. Like for
      reiserfs, even if EVM is invoked, it will not provide an xattr (if it is
      not the first to set it, its xattr will be discarded; if it is the first,
      it does not have xattrs to calculate the HMAC on).
      
      Finally, since security_inode_init_security(), unlike
      security_old_inode_init_security(), returns zero instead of -EOPNOTSUPP if
      no xattrs were provided by LSMs or if inodes are private, additionally
      check in ocfs2_init_security_get() if the xattr name is set.
      
      If not, act as if security_old_inode_init_security() returned -EOPNOTSUPP,
      and set si->enable to zero to notify to the functions following
      ocfs2_init_security_get() that no xattrs are available.
      Signed-off-by: default avatarRoberto Sassu <roberto.sassu@huawei.com>
      Reviewed-by: default avatarCasey Schaufler <casey@schaufler-ca.com>
      Acked-by: default avatarJoseph Qi <joseph.qi@linux.alibaba.com>
      Reviewed-by: default avatarMimi Zohar <zohar@linux.ibm.com>
      Signed-off-by: default avatarPaul Moore <paul@paul-moore.com>
      de3004c8
    • Roberto Sassu's avatar
      reiserfs: Switch to security_inode_init_security() · 52ca4b64
      Roberto Sassu authored
      In preparation for removing security_old_inode_init_security(), switch to
      security_inode_init_security(). Commit 572302af ("reiserfs: Add missing
      calls to reiserfs_security_free()") fixed possible memory leaks and another
      issue related to adding an xattr at inode creation time.
      
      Define the initxattrs callback reiserfs_initxattrs(), to populate the
      name/value/len triple in the reiserfs_security_handle() with the first
      xattr provided by LSMs. Make a copy of the xattr value, as
      security_inode_init_security() frees it.
      
      After the call to security_inode_init_security(), remove the check for
      returning -EOPNOTSUPP, as security_inode_init_security() changes it to
      zero.
      
      Multiple xattrs are currently not supported, as the
      reiserfs_security_handle structure is exported to user space. As a
      consequence, even if EVM is invoked, it will not provide an xattr (if it
      is not the first to set it, its xattr will be discarded; if it is the
      first, it does not have xattrs to calculate the HMAC on).
      Signed-off-by: default avatarRoberto Sassu <roberto.sassu@huawei.com>
      Reviewed-by: default avatarCasey Schaufler <casey@schaufler-ca.com>
      Reviewed-by: default avatarMimi Zohar <zohar@linux.ibm.com>
      Signed-off-by: default avatarPaul Moore <paul@paul-moore.com>
      52ca4b64
  4. 10 Mar, 2023 3 commits
  5. 08 Mar, 2023 3 commits
  6. 06 Mar, 2023 22 commits
    • Paul Moore's avatar
      lsm: styling fixes to security/security.c · 63c1845b
      Paul Moore authored
      As we were already making massive changes to security/security.c by
      moving all of the function header comments above the function
      definitions, let's take the opportunity to fix various style crimes.
      Acked-by: default avatarCasey Schaufler <casey@schaufler-ca.com>
      Signed-off-by: default avatarPaul Moore <paul@paul-moore.com>
      63c1845b
    • Paul Moore's avatar
      lsm: move the remaining LSM hook comments to security/security.c · e261301c
      Paul Moore authored
      This patch relocates the LSM hook function comments to the function
      definitions, in keeping with the current kernel conventions.  This
      should make the hook descriptions more easily discoverable and easier
      to maintain.
      
      While formatting changes have been done to better fit the kernel-doc
      style, content changes have been kept to a minimum and limited to
      text which was obviously incorrect and/or outdated.  It is expected
      the future patches will improve the quality of the function header
      comments.
      Acked-by: default avatarCasey Schaufler <casey@schaufler-ca.com>
      Signed-off-by: default avatarPaul Moore <paul@paul-moore.com>
      e261301c
    • Paul Moore's avatar
      lsm: move the io_uring hook comments to security/security.c · 1cd2aca6
      Paul Moore authored
      This patch relocates the LSM hook function comments to the function
      definitions, in keeping with the current kernel conventions.  This
      should make the hook descriptions more easily discoverable and easier
      to maintain.
      
      While formatting changes have been done to better fit the kernel-doc
      style, content changes have been kept to a minimum and limited to
      text which was obviously incorrect and/or outdated.  It is expected
      the future patches will improve the quality of the function header
      comments.
      Acked-by: default avatarCasey Schaufler <casey@schaufler-ca.com>
      Signed-off-by: default avatarPaul Moore <paul@paul-moore.com>
      1cd2aca6
    • Paul Moore's avatar
      lsm: move the perf hook comments to security/security.c · 452b670c
      Paul Moore authored
      This patch relocates the LSM hook function comments to the function
      definitions, in keeping with the current kernel conventions.  This
      should make the hook descriptions more easily discoverable and easier
      to maintain.
      
      While formatting changes have been done to better fit the kernel-doc
      style, content changes have been kept to a minimum and limited to
      text which was obviously incorrect and/or outdated.  It is expected
      the future patches will improve the quality of the function header
      comments.
      Acked-by: default avatarCasey Schaufler <casey@schaufler-ca.com>
      Signed-off-by: default avatarPaul Moore <paul@paul-moore.com>
      452b670c
    • Paul Moore's avatar
      lsm: move the bpf hook comments to security/security.c · 55e85320
      Paul Moore authored
      This patch relocates the LSM hook function comments to the function
      definitions, in keeping with the current kernel conventions.  This
      should make the hook descriptions more easily discoverable and easier
      to maintain.
      
      While formatting changes have been done to better fit the kernel-doc
      style, content changes have been kept to a minimum and limited to
      text which was obviously incorrect and/or outdated.  It is expected
      the future patches will improve the quality of the function header
      comments.
      Acked-by: default avatarCasey Schaufler <casey@schaufler-ca.com>
      Signed-off-by: default avatarPaul Moore <paul@paul-moore.com>
      55e85320
    • Paul Moore's avatar
      lsm: move the audit hook comments to security/security.c · b14faf9c
      Paul Moore authored
      This patch relocates the LSM hook function comments to the function
      definitions, in keeping with the current kernel conventions.  This
      should make the hook descriptions more easily discoverable and easier
      to maintain.
      
      While formatting changes have been done to better fit the kernel-doc
      style, content changes have been kept to a minimum and limited to
      text which was obviously incorrect and/or outdated.  It is expected
      the future patches will improve the quality of the function header
      comments.
      Acked-by: default avatarCasey Schaufler <casey@schaufler-ca.com>
      Signed-off-by: default avatarPaul Moore <paul@paul-moore.com>
      b14faf9c
    • Paul Moore's avatar
      lsm: move the binder hook comments to security/security.c · 1427ddbe
      Paul Moore authored
      This patch relocates the LSM hook function comments to the function
      definitions, in keeping with the current kernel conventions.  This
      should make the hook descriptions more easily discoverable and easier
      to maintain.
      
      While formatting changes have been done to better fit the kernel-doc
      style, content changes have been kept to a minimum and limited to
      text which was obviously incorrect and/or outdated.  It is expected
      the future patches will improve the quality of the function header
      comments.
      Acked-by: default avatarCasey Schaufler <casey@schaufler-ca.com>
      Signed-off-by: default avatarPaul Moore <paul@paul-moore.com>
      1427ddbe
    • Paul Moore's avatar
      lsm: move the sysv hook comments to security/security.c · 43fad282
      Paul Moore authored
      This patch relocates the LSM hook function comments to the function
      definitions, in keeping with the current kernel conventions.  This
      should make the hook descriptions more easily discoverable and easier
      to maintain.
      
      While formatting changes have been done to better fit the kernel-doc
      style, content changes have been kept to a minimum and limited to
      text which was obviously incorrect and/or outdated.  It is expected
      the future patches will improve the quality of the function header
      comments.
      Acked-by: default avatarCasey Schaufler <casey@schaufler-ca.com>
      Signed-off-by: default avatarPaul Moore <paul@paul-moore.com>
      43fad282
    • Paul Moore's avatar
      lsm: move the key hook comments to security/security.c · ecc419a4
      Paul Moore authored
      This patch relocates the LSM hook function comments to the function
      definitions, in keeping with the current kernel conventions.  This
      should make the hook descriptions more easily discoverable and easier
      to maintain.
      
      While formatting changes have been done to better fit the kernel-doc
      style, content changes have been kept to a minimum and limited to
      text which was obviously incorrect and/or outdated.  It is expected
      the future patches will improve the quality of the function header
      comments.
      Acked-by: default avatarCasey Schaufler <casey@schaufler-ca.com>
      Signed-off-by: default avatarPaul Moore <paul@paul-moore.com>
      ecc419a4
    • Paul Moore's avatar
      lsm: move the xfrm hook comments to security/security.c · 742b9945
      Paul Moore authored
      This patch relocates the LSM hook function comments to the function
      definitions, in keeping with the current kernel conventions.  This
      should make the hook descriptions more easily discoverable and easier
      to maintain.
      
      While formatting changes have been done to better fit the kernel-doc
      style, content changes have been kept to a minimum and limited to
      text which was obviously incorrect and/or outdated.  It is expected
      the future patches will improve the quality of the function header
      comments.
      Acked-by: default avatarCasey Schaufler <casey@schaufler-ca.com>
      Signed-off-by: default avatarPaul Moore <paul@paul-moore.com>
      742b9945
    • Paul Moore's avatar
      lsm: move the Infiniband hook comments to security/security.c · ac318aed
      Paul Moore authored
      This patch relocates the LSM hook function comments to the function
      definitions, in keeping with the current kernel conventions.  This
      should make the hook descriptions more easily discoverable and easier
      to maintain.
      
      While formatting changes have been done to better fit the kernel-doc
      style, content changes have been kept to a minimum and limited to
      text which was obviously incorrect and/or outdated.  It is expected
      the future patches will improve the quality of the function header
      comments.
      Acked-by: default avatarCasey Schaufler <casey@schaufler-ca.com>
      Signed-off-by: default avatarPaul Moore <paul@paul-moore.com>
      ac318aed
    • Paul Moore's avatar
      lsm: move the SCTP hook comments to security/security.c · 4a49f592
      Paul Moore authored
      This patch relocates the LSM hook function comments to the function
      definitions, in keeping with the current kernel conventions.  This
      should make the hook descriptions more easily discoverable and easier
      to maintain.
      
      While formatting changes have been done to better fit the kernel-doc
      style, content changes have been kept to a minimum and limited to
      text which was obviously incorrect and/or outdated.  It is expected
      the future patches will improve the quality of the function header
      comments.
      Acked-by: default avatarCasey Schaufler <casey@schaufler-ca.com>
      Signed-off-by: default avatarPaul Moore <paul@paul-moore.com>
      4a49f592
    • Paul Moore's avatar
      lsm: move the socket hook comments to security/security.c · 6b6bbe8c
      Paul Moore authored
      This patch relocates the LSM hook function comments to the function
      definitions, in keeping with the current kernel conventions.  This
      should make the hook descriptions more easily discoverable and easier
      to maintain.
      
      While formatting changes have been done to better fit the kernel-doc
      style, content changes have been kept to a minimum and limited to
      text which was obviously incorrect and/or outdated.  It is expected
      the future patches will improve the quality of the function header
      comments.
      Acked-by: default avatarCasey Schaufler <casey@schaufler-ca.com>
      Signed-off-by: default avatarPaul Moore <paul@paul-moore.com>
      6b6bbe8c
    • Paul Moore's avatar
      lsm: move the AF_UNIX hook comments to security/security.c · 2c2442fd
      Paul Moore authored
      This patch relocates the LSM hook function comments to the function
      definitions, in keeping with the current kernel conventions.  This
      should make the hook descriptions more easily discoverable and easier
      to maintain.
      
      While formatting changes have been done to better fit the kernel-doc
      style, content changes have been kept to a minimum and limited to
      text which was obviously incorrect and/or outdated.  It is expected
      the future patches will improve the quality of the function header
      comments.
      Acked-by: default avatarCasey Schaufler <casey@schaufler-ca.com>
      Signed-off-by: default avatarPaul Moore <paul@paul-moore.com>
      2c2442fd
    • Paul Moore's avatar
      lsm: move the netlink hook comments to security/security.c · 2bcf51bf
      Paul Moore authored
      This patch relocates the LSM hook function comments to the function
      definitions, in keeping with the current kernel conventions.  This
      should make the hook descriptions more easily discoverable and easier
      to maintain.
      
      While formatting changes have been done to better fit the kernel-doc
      style, content changes have been kept to a minimum and limited to
      text which was obviously incorrect and/or outdated.  It is expected
      the future patches will improve the quality of the function header
      comments.
      Acked-by: default avatarCasey Schaufler <casey@schaufler-ca.com>
      Signed-off-by: default avatarPaul Moore <paul@paul-moore.com>
      2bcf51bf
    • Paul Moore's avatar
      lsm: move the task hook comments to security/security.c · 130c53bf
      Paul Moore authored
      This patch relocates the LSM hook function comments to the function
      definitions, in keeping with the current kernel conventions.  This
      should make the hook descriptions more easily discoverable and easier
      to maintain.
      
      While formatting changes have been done to better fit the kernel-doc
      style, content changes have been kept to a minimum and limited to
      text which was obviously incorrect and/or outdated.  It is expected
      the future patches will improve the quality of the function header
      comments.
      Acked-by: default avatarCasey Schaufler <casey@schaufler-ca.com>
      Signed-off-by: default avatarPaul Moore <paul@paul-moore.com>
      130c53bf
    • Paul Moore's avatar
      lsm: move the file hook comments to security/security.c · a0fd6480
      Paul Moore authored
      This patch relocates the LSM hook function comments to the function
      definitions, in keeping with the current kernel conventions.  This
      should make the hook descriptions more easily discoverable and easier
      to maintain.
      
      While formatting changes have been done to better fit the kernel-doc
      style, content changes have been kept to a minimum and limited to
      text which was obviously incorrect and/or outdated.  It is expected
      the future patches will improve the quality of the function header
      comments.
      Acked-by: default avatarCasey Schaufler <casey@schaufler-ca.com>
      Signed-off-by: default avatarPaul Moore <paul@paul-moore.com>
      a0fd6480
    • Paul Moore's avatar
      lsm: move the kernfs hook comments to security/security.c · 9348944b
      Paul Moore authored
      This patch relocates the LSM hook function comments to the function
      definitions, in keeping with the current kernel conventions.  This
      should make the hook descriptions more easily discoverable and easier
      to maintain.
      
      While formatting changes have been done to better fit the kernel-doc
      style, content changes have been kept to a minimum and limited to
      text which was obviously incorrect and/or outdated.  It is expected
      the future patches will improve the quality of the function header
      comments.
      Acked-by: default avatarCasey Schaufler <casey@schaufler-ca.com>
      Signed-off-by: default avatarPaul Moore <paul@paul-moore.com>
      9348944b
    • Paul Moore's avatar
      lsm: move the inode hook comments to security/security.c · 916e3258
      Paul Moore authored
      This patch relocates the LSM hook function comments to the function
      definitions, in keeping with the current kernel conventions.  This
      should make the hook descriptions more easily discoverable and easier
      to maintain.
      
      While formatting changes have been done to better fit the kernel-doc
      style, content changes have been kept to a minimum and limited to
      text which was obviously incorrect and/or outdated.  It is expected
      the future patches will improve the quality of the function header
      comments.
      Acked-by: default avatarCasey Schaufler <casey@schaufler-ca.com>
      Signed-off-by: default avatarPaul Moore <paul@paul-moore.com>
      916e3258
    • Paul Moore's avatar
      lsm: move the filesystem hook comments to security/security.c · 08526a90
      Paul Moore authored
      This patch relocates the LSM hook function comments to the function
      definitions, in keeping with the current kernel conventions.  This
      should make the hook descriptions more easily discoverable and easier
      to maintain.
      
      While formatting changes have been done to better fit the kernel-doc
      style, content changes have been kept to a minimum and limited to
      text which was obviously incorrect and/or outdated.  It is expected
      the future patches will improve the quality of the function header
      comments.
      Acked-by: default avatarCasey Schaufler <casey@schaufler-ca.com>
      Signed-off-by: default avatarPaul Moore <paul@paul-moore.com>
      08526a90
    • Paul Moore's avatar
      lsm: move the fs_context hook comments to security/security.c · 36819f18
      Paul Moore authored
      This patch relocates the LSM hook function comments to the function
      definitions, in keeping with the current kernel conventions.  This
      should make the hook descriptions more easily discoverable and easier
      to maintain.
      
      While formatting changes have been done to better fit the kernel-doc
      style, content changes have been kept to a minimum and limited to
      text which was obviously incorrect and/or outdated.  It is expected
      the future patches will improve the quality of the function header
      comments.
      Acked-by: default avatarCasey Schaufler <casey@schaufler-ca.com>
      Signed-off-by: default avatarPaul Moore <paul@paul-moore.com>
      36819f18
    • Paul Moore's avatar
      lsm: move the program execution hook comments to security/security.c · 1661372c
      Paul Moore authored
      This patch relocates the LSM hook function comments to the function
      definitions, in keeping with the current kernel conventions.  This
      should make the hook descriptions more easily discoverable and easier
      to maintain.
      
      While formatting changes have been done to better fit the kernel-doc
      style, content changes have been kept to a minimum and limited to
      text which was obviously incorrect and/or outdated.  It is expected
      the future patches will improve the quality of the function header
      comments.
      Acked-by: default avatarCasey Schaufler <casey@schaufler-ca.com>
      Signed-off-by: default avatarPaul Moore <paul@paul-moore.com>
      1661372c
  7. 05 Mar, 2023 7 commits
    • Linus Torvalds's avatar
      Linux 6.3-rc1 · fe15c26e
      Linus Torvalds authored
      fe15c26e
    • Linus Torvalds's avatar
      cpumask: re-introduce constant-sized cpumask optimizations · 596ff4a0
      Linus Torvalds authored
      Commit aa47a7c2 ("lib/cpumask: deprecate nr_cpumask_bits") resulted
      in the cpumask operations potentially becoming hugely less efficient,
      because suddenly the cpumask was always considered to be variable-sized.
      
      The optimization was then later added back in a limited form by commit
      6f9c07be ("lib/cpumask: add FORCE_NR_CPUS config option"), but that
      FORCE_NR_CPUS option is not useful in a generic kernel and more of a
      special case for embedded situations with fixed hardware.
      
      Instead, just re-introduce the optimization, with some changes.
      
      Instead of depending on CPUMASK_OFFSTACK being false, and then always
      using the full constant cpumask width, this introduces three different
      cpumask "sizes":
      
       - the exact size (nr_cpumask_bits) remains identical to nr_cpu_ids.
      
         This is used for situations where we should use the exact size.
      
       - the "small" size (small_cpumask_bits) is the NR_CPUS constant if it
         fits in a single word and the bitmap operations thus end up able
         to trigger the "small_const_nbits()" optimizations.
      
         This is used for the operations that have optimized single-word
         cases that get inlined, notably the bit find and scanning functions.
      
       - the "large" size (large_cpumask_bits) is the NR_CPUS constant if it
         is an sufficiently small constant that makes simple "copy" and
         "clear" operations more efficient.
      
         This is arbitrarily set at four words or less.
      
      As a an example of this situation, without this fixed size optimization,
      cpumask_clear() will generate code like
      
              movl    nr_cpu_ids(%rip), %edx
              addq    $63, %rdx
              shrq    $3, %rdx
              andl    $-8, %edx
              callq   memset@PLT
      
      on x86-64, because it would calculate the "exact" number of longwords
      that need to be cleared.
      
      In contrast, with this patch, using a MAX_CPU of 64 (which is quite a
      reasonable value to use), the above becomes a single
      
      	movq $0,cpumask
      
      instruction instead, because instead of caring to figure out exactly how
      many CPU's the system has, it just knows that the cpumask will be a
      single word and can just clear it all.
      
      Note that this does end up tightening the rules a bit from the original
      version in another way: operations that set bits in the cpumask are now
      limited to the actual nr_cpu_ids limit, whereas we used to do the
      nr_cpumask_bits thing almost everywhere in the cpumask code.
      
      But if you just clear bits, or scan for bits, we can use the simpler
      compile-time constants.
      
      In the process, remove 'cpumask_complement()' and 'for_each_cpu_not()'
      which were not useful, and which fundamentally have to be limited to
      'nr_cpu_ids'.  Better remove them now than have somebody introduce use
      of them later.
      
      Of course, on x86-64 with MAXSMP there is no sane small compile-time
      constant for the cpumask sizes, and we end up using the actual CPU bits,
      and will generate the above kind of horrors regardless.  Please don't
      use MAXSMP unless you really expect to have machines with thousands of
      cores.
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      596ff4a0
    • Linus Torvalds's avatar
      Merge tag 'v6.3-p2' of git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6 · f915322f
      Linus Torvalds authored
      Pull crypto fix from Herbert Xu:
       "Fix a regression in the caam driver"
      
      * tag 'v6.3-p2' of git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6:
        crypto: caam - Fix edesc/iv ordering mixup
      f915322f
    • Linus Torvalds's avatar
      Merge tag 'x86-urgent-2023-03-05' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip · 7f9ec7d8
      Linus Torvalds authored
      Pull x86 updates from Thomas Gleixner:
       "A small set of updates for x86:
      
         - Return -EIO instead of success when the certificate buffer for SEV
           guests is not large enough
      
         - Allow STIPB to be enabled with legacy IBSR. Legacy IBRS is cleared
           on return to userspace for performance reasons, but the leaves user
           space vulnerable to cross-thread attacks which STIBP prevents.
           Update the documentation accordingly"
      
      * tag 'x86-urgent-2023-03-05' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
        virt/sev-guest: Return -EIO if certificate buffer is not large enough
        Documentation/hw-vuln: Document the interaction between IBRS and STIBP
        x86/speculation: Allow enabling STIBP with legacy IBRS
      7f9ec7d8
    • Linus Torvalds's avatar
      Merge tag 'irq-urgent-2023-03-05' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip · 4e9c542c
      Linus Torvalds authored
      Pull irq updates from Thomas Gleixner:
       "A set of updates for the interrupt susbsystem:
      
         - Prevent possible NULL pointer derefences in
           irq_data_get_affinity_mask() and irq_domain_create_hierarchy()
      
         - Take the per device MSI lock before invoking code which relies on
           it being hold
      
         - Make sure that MSI descriptors are unreferenced before freeing
           them. This was overlooked when the platform MSI code was converted
           to use core infrastructure and results in a fals positive warning
      
         - Remove dead code in the MSI subsystem
      
         - Clarify the documentation for pci_msix_free_irq()
      
         - More kobj_type constification"
      
      * tag 'irq-urgent-2023-03-05' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
        genirq/msi, platform-msi: Ensure that MSI descriptors are unreferenced
        genirq/msi: Drop dead domain name assignment
        irqdomain: Add missing NULL pointer check in irq_domain_create_hierarchy()
        genirq/irqdesc: Make kobj_type structures constant
        PCI/MSI: Clarify usage of pci_msix_free_irq()
        genirq/msi: Take the per-device MSI lock before validating the control structure
        genirq/ipi: Fix NULL pointer deref in irq_data_get_affinity_mask()
      4e9c542c
    • Linus Torvalds's avatar
      Merge tag 'pull-misc' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs · 1a90673e
      Linus Torvalds authored
      Pull vfs update from Al Viro:
       "Adding Christian Brauner as VFS co-maintainer"
      
      * tag 'pull-misc' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs:
        Adding VFS co-maintainer
      1a90673e
    • Linus Torvalds's avatar
      Merge tag 'pull-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs · 1a8d05a7
      Linus Torvalds authored
      Pull VM_FAULT_RETRY fixes from Al Viro:
       "Some of the page fault handlers do not deal with the following case
        correctly:
      
         - handle_mm_fault() has returned VM_FAULT_RETRY
      
         - there is a pending fatal signal
      
         - fault had happened in kernel mode
      
        Correct action in such case is not "return unconditionally" - fatal
        signals are handled only upon return to userland and something like
        copy_to_user() would end up retrying the faulting instruction and
        triggering the same fault again and again.
      
        What we need to do in such case is to make the caller to treat that as
        failed uaccess attempt - handle exception if there is an exception
        handler for faulting instruction or oops if there isn't one.
      
        Over the years some architectures had been fixed and now are handling
        that case properly; some still do not. This series should fix the
        remaining ones.
      
        Status:
      
         - m68k, riscv, hexagon, parisc: tested/acked by maintainers.
      
         - alpha, sparc32, sparc64: tested locally - bug has been reproduced
           on the unpatched kernel and verified to be fixed by this series.
      
         - ia64, microblaze, nios2, openrisc: build, but otherwise completely
           untested"
      
      * tag 'pull-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs:
        openrisc: fix livelock in uaccess
        nios2: fix livelock in uaccess
        microblaze: fix livelock in uaccess
        ia64: fix livelock in uaccess
        sparc: fix livelock in uaccess
        alpha: fix livelock in uaccess
        parisc: fix livelock in uaccess
        hexagon: fix livelock in uaccess
        riscv: fix livelock in uaccess
        m68k: fix livelock in uaccess
      1a8d05a7