Skip to content
Snippets Groups Projects
  1. Mar 01, 2023
    • Linus Torvalds's avatar
      capability: just use a 'u64' instead of a 'u32[2]' array · f122a08b
      Linus Torvalds authored
      
      Back in 2008 we extended the capability bits from 32 to 64, and we did
      it by extending the single 32-bit capability word from one word to an
      array of two words.  It was then obfuscated by hiding the "2" behind two
      macro expansions, with the reasoning being that maybe it gets extended
      further some day.
      
      That reasoning may have been valid at the time, but the last thing we
      want to do is to extend the capability set any more.  And the array of
      values not only causes source code oddities (with loops to deal with
      it), but also results in worse code generation.  It's a lose-lose
      situation.
      
      So just change the 'u32[2]' into a 'u64' and be done with it.
      
      We still have to deal with the fact that the user space interface is
      designed around an array of these 32-bit values, but that was the case
      before too, since the array layouts were different (ie user space
      doesn't use an array of 32-bit values for individual capability masks,
      but an array of 32-bit slices of multiple masks).
      
      So that marshalling of data is actually simplified too, even if it does
      remain somewhat obscure and odd.
      
      This was all triggered by my reaction to the new "cap_isidentical()"
      introduced recently.  By just using a saner data structure, it went from
      
      	unsigned __capi;
      	CAP_FOR_EACH_U32(__capi) {
      		if (a.cap[__capi] != b.cap[__capi])
      			return false;
      	}
      	return true;
      
      to just being
      
      	return a.val == b.val;
      
      instead.  Which is rather more obvious both to humans and to compilers.
      
      Cc: Mateusz Guzik <mjguzik@gmail.com>
      Cc: Casey Schaufler <casey@schaufler-ca.com>
      Cc: Serge Hallyn <serge@hallyn.com>
      Cc: Al Viro <viro@zeniv.linux.org.uk>
      Cc: Paul Moore <paul@paul-moore.com>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      f122a08b
  2. Feb 21, 2023
  3. Feb 15, 2023
    • John Johansen's avatar
      apparmor: Fix regression in compat permissions for getattr · cbb13e12
      John Johansen authored
      
      This fixes a regression in mediation of getattr when old policy built
      under an older ABI is loaded and mapped to internal permissions.
      
      The regression does not occur for all getattr permission requests,
      only appearing if state zero is the final state in the permission
      lookup.  This is because despite the first state (index 0) being
      guaranteed to not have permissions in both newer and older permission
      formats, it may have to carry permissions that were not mediated as
      part of an older policy. These backward compat permissions are
      mapped here to avoid special casing the mediation code paths.
      
      Since the mapping code already takes into account backwards compat
      permission from older formats it can be applied to state 0 to fix
      the regression.
      
      Fixes: 408d53e9 ("apparmor: compute file permissions on profile load")
      Reported-by: default avatarPhilip Meulengracht <the_meulengracht@hotmail.com>
      Signed-off-by: default avatarJohn Johansen <john.johansen@canonical.com>
      cbb13e12
  4. Feb 13, 2023
  5. Feb 12, 2023
  6. Feb 10, 2023
  7. Feb 09, 2023
  8. Jan 31, 2023
    • Roberto Sassu's avatar
      ima: Introduce MMAP_CHECK_REQPROT hook · 4958db32
      Roberto Sassu authored
      
      Commit 98de59bf ("take calculation of final prot in
      security_mmap_file() into a helper") caused ima_file_mmap() to receive the
      protections requested by the application and not those applied by the
      kernel.
      
      After restoring the original MMAP_CHECK behavior, existing attestation
      servers might be broken due to not being ready to handle new entries
      (previously missing) in the IMA measurement list.
      
      Restore the original correct MMAP_CHECK behavior, instead of keeping the
      current buggy one and introducing a new hook with the correct behavior.
      Otherwise, there would have been the risk of IMA users not noticing the
      problem at all, as they would actively have to update the IMA policy, to
      switch to the correct behavior.
      
      Also, introduce the new MMAP_CHECK_REQPROT hook to keep the current
      behavior, so that IMA users could easily fix a broken attestation server,
      although this approach is discouraged due to potentially missing
      measurements.
      
      Signed-off-by: default avatarRoberto Sassu <roberto.sassu@huawei.com>
      Signed-off-by: default avatarMimi Zohar <zohar@linux.ibm.com>
      4958db32
    • Roberto Sassu's avatar
      ima: Align ima_file_mmap() parameters with mmap_file LSM hook · 4971c268
      Roberto Sassu authored
      
      Commit 98de59bf ("take calculation of final prot in
      security_mmap_file() into a helper") moved the code to update prot, to be
      the actual protections applied to the kernel, to a new helper called
      mmap_prot().
      
      However, while without the helper ima_file_mmap() was getting the updated
      prot, with the helper ima_file_mmap() gets the original prot, which
      contains the protections requested by the application.
      
      A possible consequence of this change is that, if an application calls
      mmap() with only PROT_READ, and the kernel applies PROT_EXEC in addition,
      that application would have access to executable memory without having this
      event recorded in the IMA measurement list. This situation would occur for
      example if the application, before mmap(), calls the personality() system
      call with READ_IMPLIES_EXEC as the first argument.
      
      Align ima_file_mmap() parameters with those of the mmap_file LSM hook, so
      that IMA can receive both the requested prot and the final prot. Since the
      requested protections are stored in a new variable, and the final
      protections are stored in the existing variable, this effectively restores
      the original behavior of the MMAP_CHECK hook.
      
      Cc: stable@vger.kernel.org
      Fixes: 98de59bf ("take calculation of final prot in security_mmap_file() into a helper")
      Signed-off-by: default avatarRoberto Sassu <roberto.sassu@huawei.com>
      Reviewed-by: default avatarStefan Berger <stefanb@linux.ibm.com>
      Signed-off-by: default avatarMimi Zohar <zohar@linux.ibm.com>
      4971c268
    • Xiu Jianfeng's avatar
      evm: call dump_security_xattr() in all cases to remove code duplication · 8250865c
      Xiu Jianfeng authored
      
      Currently dump_security_xattr() is used to dump security xattr value
      which is larger than 64 bytes, otherwise, pr_debug() is used. In order
      to remove code duplication, refactor dump_security_xattr() and call it
      in all cases.
      
      Signed-off-by: default avatarXiu Jianfeng <xiujianfeng@huawei.com>
      Signed-off-by: default avatarMimi Zohar <zohar@linux.ibm.com>
      8250865c
  9. Jan 20, 2023
  10. Jan 19, 2023
    • Christian Brauner's avatar
      fs: port vfs{g,u}id helpers to mnt_idmap · 4d7ca409
      Christian Brauner authored
      
      Convert to struct mnt_idmap.
      
      Last cycle we merged the necessary infrastructure in
      256c8aed ("fs: introduce dedicated idmap type for mounts").
      This is just the conversion to struct mnt_idmap.
      
      Currently we still pass around the plain namespace that was attached to a
      mount. This is in general pretty convenient but it makes it easy to
      conflate namespaces that are relevant on the filesystem with namespaces
      that are relevent on the mount level. Especially for non-vfs developers
      without detailed knowledge in this area this can be a potential source for
      bugs.
      
      Once the conversion to struct mnt_idmap is done all helpers down to the
      really low-level helpers will take a struct mnt_idmap argument instead of
      two namespace arguments. This way it becomes impossible to conflate the two
      eliminating the possibility of any bugs. All of the vfs and all filesystems
      only operate on struct mnt_idmap.
      
      Acked-by: default avatarDave Chinner <dchinner@redhat.com>
      Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
      Signed-off-by: default avatarChristian Brauner (Microsoft) <brauner@kernel.org>
      4d7ca409
    • Christian Brauner's avatar
      fs: port i_{g,u}id_into_vfs{g,u}id() to mnt_idmap · e67fe633
      Christian Brauner authored
      
      Convert to struct mnt_idmap.
      Remove legacy file_mnt_user_ns() and mnt_user_ns().
      
      Last cycle we merged the necessary infrastructure in
      256c8aed ("fs: introduce dedicated idmap type for mounts").
      This is just the conversion to struct mnt_idmap.
      
      Currently we still pass around the plain namespace that was attached to a
      mount. This is in general pretty convenient but it makes it easy to
      conflate namespaces that are relevant on the filesystem with namespaces
      that are relevent on the mount level. Especially for non-vfs developers
      without detailed knowledge in this area this can be a potential source for
      bugs.
      
      Once the conversion to struct mnt_idmap is done all helpers down to the
      really low-level helpers will take a struct mnt_idmap argument instead of
      two namespace arguments. This way it becomes impossible to conflate the two
      eliminating the possibility of any bugs. All of the vfs and all filesystems
      only operate on struct mnt_idmap.
      
      Acked-by: default avatarDave Chinner <dchinner@redhat.com>
      Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
      Signed-off-by: default avatarChristian Brauner (Microsoft) <brauner@kernel.org>
      e67fe633
    • Christian Brauner's avatar
      fs: port i_{g,u}id_{needs_}update() to mnt_idmap · 0dbe12f2
      Christian Brauner authored
      
      Convert to struct mnt_idmap.
      
      Last cycle we merged the necessary infrastructure in
      256c8aed ("fs: introduce dedicated idmap type for mounts").
      This is just the conversion to struct mnt_idmap.
      
      Currently we still pass around the plain namespace that was attached to a
      mount. This is in general pretty convenient but it makes it easy to
      conflate namespaces that are relevant on the filesystem with namespaces
      that are relevent on the mount level. Especially for non-vfs developers
      without detailed knowledge in this area this can be a potential source for
      bugs.
      
      Once the conversion to struct mnt_idmap is done all helpers down to the
      really low-level helpers will take a struct mnt_idmap argument instead of
      two namespace arguments. This way it becomes impossible to conflate the two
      eliminating the possibility of any bugs. All of the vfs and all filesystems
      only operate on struct mnt_idmap.
      
      Acked-by: default avatarDave Chinner <dchinner@redhat.com>
      Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
      Signed-off-by: default avatarChristian Brauner (Microsoft) <brauner@kernel.org>
      0dbe12f2
    • Christian Brauner's avatar
      fs: port privilege checking helpers to mnt_idmap · 9452e93e
      Christian Brauner authored
      
      Convert to struct mnt_idmap.
      
      Last cycle we merged the necessary infrastructure in
      256c8aed ("fs: introduce dedicated idmap type for mounts").
      This is just the conversion to struct mnt_idmap.
      
      Currently we still pass around the plain namespace that was attached to a
      mount. This is in general pretty convenient but it makes it easy to
      conflate namespaces that are relevant on the filesystem with namespaces
      that are relevent on the mount level. Especially for non-vfs developers
      without detailed knowledge in this area this can be a potential source for
      bugs.
      
      Once the conversion to struct mnt_idmap is done all helpers down to the
      really low-level helpers will take a struct mnt_idmap argument instead of
      two namespace arguments. This way it becomes impossible to conflate the two
      eliminating the possibility of any bugs. All of the vfs and all filesystems
      only operate on struct mnt_idmap.
      
      Acked-by: default avatarDave Chinner <dchinner@redhat.com>
      Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
      Signed-off-by: default avatarChristian Brauner (Microsoft) <brauner@kernel.org>
      9452e93e
    • Christian Brauner's avatar
      fs: port inode_owner_or_capable() to mnt_idmap · 01beba79
      Christian Brauner authored
      
      Convert to struct mnt_idmap.
      
      Last cycle we merged the necessary infrastructure in
      256c8aed ("fs: introduce dedicated idmap type for mounts").
      This is just the conversion to struct mnt_idmap.
      
      Currently we still pass around the plain namespace that was attached to a
      mount. This is in general pretty convenient but it makes it easy to
      conflate namespaces that are relevant on the filesystem with namespaces
      that are relevent on the mount level. Especially for non-vfs developers
      without detailed knowledge in this area this can be a potential source for
      bugs.
      
      Once the conversion to struct mnt_idmap is done all helpers down to the
      really low-level helpers will take a struct mnt_idmap argument instead of
      two namespace arguments. This way it becomes impossible to conflate the two
      eliminating the possibility of any bugs. All of the vfs and all filesystems
      only operate on struct mnt_idmap.
      
      Acked-by: default avatarDave Chinner <dchinner@redhat.com>
      Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
      Signed-off-by: default avatarChristian Brauner (Microsoft) <brauner@kernel.org>
      01beba79
    • Christian Brauner's avatar
      fs: port acl to mnt_idmap · 700b7940
      Christian Brauner authored
      
      Convert to struct mnt_idmap.
      
      Last cycle we merged the necessary infrastructure in
      256c8aed ("fs: introduce dedicated idmap type for mounts").
      This is just the conversion to struct mnt_idmap.
      
      Currently we still pass around the plain namespace that was attached to a
      mount. This is in general pretty convenient but it makes it easy to
      conflate namespaces that are relevant on the filesystem with namespaces
      that are relevent on the mount level. Especially for non-vfs developers
      without detailed knowledge in this area this can be a potential source for
      bugs.
      
      Once the conversion to struct mnt_idmap is done all helpers down to the
      really low-level helpers will take a struct mnt_idmap argument instead of
      two namespace arguments. This way it becomes impossible to conflate the two
      eliminating the possibility of any bugs. All of the vfs and all filesystems
      only operate on struct mnt_idmap.
      
      Acked-by: default avatarDave Chinner <dchinner@redhat.com>
      Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
      Signed-off-by: default avatarChristian Brauner (Microsoft) <brauner@kernel.org>
      700b7940
    • Christian Brauner's avatar
      fs: port xattr to mnt_idmap · 39f60c1c
      Christian Brauner authored
      
      Convert to struct mnt_idmap.
      
      Last cycle we merged the necessary infrastructure in
      256c8aed ("fs: introduce dedicated idmap type for mounts").
      This is just the conversion to struct mnt_idmap.
      
      Currently we still pass around the plain namespace that was attached to a
      mount. This is in general pretty convenient but it makes it easy to
      conflate namespaces that are relevant on the filesystem with namespaces
      that are relevent on the mount level. Especially for non-vfs developers
      without detailed knowledge in this area this can be a potential source for
      bugs.
      
      Once the conversion to struct mnt_idmap is done all helpers down to the
      really low-level helpers will take a struct mnt_idmap argument instead of
      two namespace arguments. This way it becomes impossible to conflate the two
      eliminating the possibility of any bugs. All of the vfs and all filesystems
      only operate on struct mnt_idmap.
      
      Acked-by: default avatarDave Chinner <dchinner@redhat.com>
      Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
      Signed-off-by: default avatarChristian Brauner (Microsoft) <brauner@kernel.org>
      39f60c1c
    • Christian Brauner's avatar
      fs: port ->permission() to pass mnt_idmap · 4609e1f1
      Christian Brauner authored
      
      Convert to struct mnt_idmap.
      
      Last cycle we merged the necessary infrastructure in
      256c8aed ("fs: introduce dedicated idmap type for mounts").
      This is just the conversion to struct mnt_idmap.
      
      Currently we still pass around the plain namespace that was attached to a
      mount. This is in general pretty convenient but it makes it easy to
      conflate namespaces that are relevant on the filesystem with namespaces
      that are relevent on the mount level. Especially for non-vfs developers
      without detailed knowledge in this area this can be a potential source for
      bugs.
      
      Once the conversion to struct mnt_idmap is done all helpers down to the
      really low-level helpers will take a struct mnt_idmap argument instead of
      two namespace arguments. This way it becomes impossible to conflate the two
      eliminating the possibility of any bugs. All of the vfs and all filesystems
      only operate on struct mnt_idmap.
      
      Acked-by: default avatarDave Chinner <dchinner@redhat.com>
      Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
      Signed-off-by: default avatarChristian Brauner (Microsoft) <brauner@kernel.org>
      4609e1f1
    • Christian Brauner's avatar
      fs: port ->mkdir() to pass mnt_idmap · c54bd91e
      Christian Brauner authored
      
      Convert to struct mnt_idmap.
      
      Last cycle we merged the necessary infrastructure in
      256c8aed ("fs: introduce dedicated idmap type for mounts").
      This is just the conversion to struct mnt_idmap.
      
      Currently we still pass around the plain namespace that was attached to a
      mount. This is in general pretty convenient but it makes it easy to
      conflate namespaces that are relevant on the filesystem with namespaces
      that are relevent on the mount level. Especially for non-vfs developers
      without detailed knowledge in this area this can be a potential source for
      bugs.
      
      Once the conversion to struct mnt_idmap is done all helpers down to the
      really low-level helpers will take a struct mnt_idmap argument instead of
      two namespace arguments. This way it becomes impossible to conflate the two
      eliminating the possibility of any bugs. All of the vfs and all filesystems
      only operate on struct mnt_idmap.
      
      Acked-by: default avatarDave Chinner <dchinner@redhat.com>
      Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
      Signed-off-by: default avatarChristian Brauner (Microsoft) <brauner@kernel.org>
      c54bd91e
    • Christian Brauner's avatar
      fs: port ->setattr() to pass mnt_idmap · c1632a0f
      Christian Brauner authored
      
      Convert to struct mnt_idmap.
      
      Last cycle we merged the necessary infrastructure in
      256c8aed ("fs: introduce dedicated idmap type for mounts").
      This is just the conversion to struct mnt_idmap.
      
      Currently we still pass around the plain namespace that was attached to a
      mount. This is in general pretty convenient but it makes it easy to
      conflate namespaces that are relevant on the filesystem with namespaces
      that are relevent on the mount level. Especially for non-vfs developers
      without detailed knowledge in this area this can be a potential source for
      bugs.
      
      Once the conversion to struct mnt_idmap is done all helpers down to the
      really low-level helpers will take a struct mnt_idmap argument instead of
      two namespace arguments. This way it becomes impossible to conflate the two
      eliminating the possibility of any bugs. All of the vfs and all filesystems
      only operate on struct mnt_idmap.
      
      Acked-by: default avatarDave Chinner <dchinner@redhat.com>
      Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
      Signed-off-by: default avatarChristian Brauner (Microsoft) <brauner@kernel.org>
      c1632a0f
    • Hao Sun's avatar
      mm: new primitive kvmemdup() · 0b7b8704
      Hao Sun authored
      Similar to kmemdup(), but support large amount of bytes with kvmalloc()
      and does *not* guarantee that the result will be physically contiguous. 
      Use only in cases where kvmalloc() is needed and free it with kvfree(). 
      Also adapt policy_unpack.c in case someone bisect into this.
      
      Link: https://lkml.kernel.org/r/20221221144245.27164-1-sunhao.th@gmail.com
      
      
      Signed-off-by: default avatarHao Sun <sunhao.th@gmail.com>
      Suggested-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
      Cc: Nick Terrell <terrelln@fb.com>
      Cc: John Johansen <john.johansen@canonical.com>
      Cc: Paul Moore <paul@paul-moore.com>
      Cc: James Morris <jmorris@namei.org>
      Cc: "Serge E. Hallyn" <serge@hallyn.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      0b7b8704
  11. Jan 18, 2023
  12. Jan 13, 2023
  13. Jan 09, 2023
    • Masahiro Yamada's avatar
      tomoyo: Omit use of bin2c · 80f8be7a
      Masahiro Yamada authored
      
      bin2c was, as its name implies, introduced to convert a binary file to
      C code.
      
      However, I did not see any good reason ever for using this tool because
      using the .incbin directive is much faster, and often results in simpler
      code.
      
      Most of the uses of bin2c have been killed, for example:
      
        - 13610aa9 ("kernel/configs: use .incbin directive to embed config_data.gz")
        - 4c0f032d ("s390/purgatory: Omit use of bin2c")
      
      security/tomoyo/Makefile has even less reason for using bin2c because
      the policy files are text data. So, sed is enough for converting them
      to C string literals, and what is nicer, generates human-readable
      builtin-policy.h.
      
      This is the last user of bin2c. After this commit lands, bin2c will be
      removed.
      
      Signed-off-by: default avatarMasahiro Yamada <masahiroy@kernel.org>
      [penguin-kernel: Update sed script to also escape backslash and quote ]
      Signed-off-by: default avatarTetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
      80f8be7a
  14. Jan 07, 2023
  15. Dec 15, 2022
  16. Dec 14, 2022
  17. Dec 13, 2022
  18. Dec 12, 2022
Loading