Skip to content
Snippets Groups Projects
  1. Jan 30, 2024
  2. Jan 26, 2024
  3. Jan 24, 2024
  4. Jan 09, 2024
    • Gaosheng Cui's avatar
      apparmor: Fix memory leak in unpack_profile() · 8ead196b
      Gaosheng Cui authored
      
      The aa_put_pdb(rules->file) should be called when rules->file is
      reassigned, otherwise there may be a memory leak.
      
      This was found via kmemleak:
      
      unreferenced object 0xffff986c17056600 (size 192):
        comm "apparmor_parser", pid 875, jiffies 4294893488
        hex dump (first 32 bytes):
          00 00 00 00 00 00 00 00 00 89 14 04 6c 98 ff ff  ............l...
          00 00 8c 11 6c 98 ff ff bc 0c 00 00 00 00 00 00  ....l...........
        backtrace (crc e28c80c4):
          [<ffffffffba25087f>] kmemleak_alloc+0x4f/0x90
          [<ffffffffb95ecd42>] kmalloc_trace+0x2d2/0x340
          [<ffffffffb98a7b3d>] aa_alloc_pdb+0x4d/0x90
          [<ffffffffb98ab3b8>] unpack_pdb+0x48/0x660
          [<ffffffffb98ac073>] unpack_profile+0x693/0x1090
          [<ffffffffb98acf5a>] aa_unpack+0x10a/0x6e0
          [<ffffffffb98a93e3>] aa_replace_profiles+0xa3/0x1210
          [<ffffffffb989a183>] policy_update+0x163/0x2a0
          [<ffffffffb989a381>] profile_replace+0xb1/0x130
          [<ffffffffb966cb64>] vfs_write+0xd4/0x3d0
          [<ffffffffb966d05b>] ksys_write+0x6b/0xf0
          [<ffffffffb966d10e>] __x64_sys_write+0x1e/0x30
          [<ffffffffba242316>] do_syscall_64+0x76/0x120
          [<ffffffffba4000e5>] entry_SYSCALL_64_after_hwframe+0x6c/0x74
      
      So add aa_put_pdb(rules->file) to fix it when rules->file is reassigned.
      
      Fixes: 98b824ff ("apparmor: refcount the pdb")
      Signed-off-by: default avatarGaosheng Cui <cuigaosheng1@huawei.com>
      Signed-off-by: default avatarJohn Johansen <john.johansen@canonical.com>
      8ead196b
  5. Jan 08, 2024
  6. Jan 04, 2024
    • Mickaël Salaün's avatar
      selinux: Fix error priority for bind with AF_UNSPEC on PF_INET6 socket · bbf5a1d0
      Mickaël Salaün authored
      
      The IPv6 network stack first checks the sockaddr length (-EINVAL error)
      before checking the family (-EAFNOSUPPORT error).
      
      This was discovered thanks to commit a549d055 ("selftests/landlock:
      Add network tests").
      
      Cc: Eric Paris <eparis@parisplace.org>
      Cc: Konstantin Meskhidze <konstantin.meskhidze@huawei.com>
      Cc: Paul Moore <paul@paul-moore.com>
      Cc: Stephen Smalley <stephen.smalley.work@gmail.com>
      Reported-by: default avatarMuhammad Usama Anjum <usama.anjum@collabora.com>
      Closes: https://lore.kernel.org/r/0584f91c-537c-4188-9e4f-04f192565667@collabora.com
      
      
      Fixes: 0f8db8cc ("selinux: add AF_UNSPEC and INADDR_ANY checks to selinux_socket_bind()")
      Signed-off-by: default avatarMickaël Salaün <mic@digikod.net>
      Tested-by: default avatarMuhammad Usama Anjum <usama.anjum@collabora.com>
      Signed-off-by: default avatarPaul Moore <paul@paul-moore.com>
      bbf5a1d0
    • Fedor Pchelkin's avatar
      apparmor: avoid crash when parsed profile name is empty · 55a8210c
      Fedor Pchelkin authored
      
      When processing a packed profile in unpack_profile() described like
      
       "profile :ns::samba-dcerpcd /usr/lib*/samba/{,samba/}samba-dcerpcd {...}"
      
      a string ":samba-dcerpcd" is unpacked as a fully-qualified name and then
      passed to aa_splitn_fqname().
      
      aa_splitn_fqname() treats ":samba-dcerpcd" as only containing a namespace.
      Thus it returns NULL for tmpname, meanwhile tmpns is non-NULL. Later
      aa_alloc_profile() crashes as the new profile name is NULL now.
      
      general protection fault, probably for non-canonical address 0xdffffc0000000000: 0000 [#1] PREEMPT SMP KASAN NOPTI
      KASAN: null-ptr-deref in range [0x0000000000000000-0x0000000000000007]
      CPU: 6 PID: 1657 Comm: apparmor_parser Not tainted 6.7.0-rc2-dirty #16
      Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.16.2-3-gd478f380-rebuilt.opensuse.org 04/01/2014
      RIP: 0010:strlen+0x1e/0xa0
      Call Trace:
       <TASK>
       ? strlen+0x1e/0xa0
       aa_policy_init+0x1bb/0x230
       aa_alloc_profile+0xb1/0x480
       unpack_profile+0x3bc/0x4960
       aa_unpack+0x309/0x15e0
       aa_replace_profiles+0x213/0x33c0
       policy_update+0x261/0x370
       profile_replace+0x20e/0x2a0
       vfs_write+0x2af/0xe00
       ksys_write+0x126/0x250
       do_syscall_64+0x46/0xf0
       entry_SYSCALL_64_after_hwframe+0x6e/0x76
       </TASK>
      ---[ end trace 0000000000000000 ]---
      RIP: 0010:strlen+0x1e/0xa0
      
      It seems such behaviour of aa_splitn_fqname() is expected and checked in
      other places where it is called (e.g. aa_remove_profiles). Well, there
      is an explicit comment "a ns name without a following profile is allowed"
      inside.
      
      AFAICS, nothing can prevent unpacked "name" to be in form like
      ":samba-dcerpcd" - it is passed from userspace.
      
      Deny the whole profile set replacement in such case and inform user with
      EPROTO and an explaining message.
      
      Found by Linux Verification Center (linuxtesting.org).
      
      Fixes: 04dc715e ("apparmor: audit policy ns specified in policy load")
      Signed-off-by: default avatarFedor Pchelkin <pchelkin@ispras.ru>
      Signed-off-by: default avatarJohn Johansen <john.johansen@canonical.com>
      55a8210c
    • Fedor Pchelkin's avatar
      apparmor: fix possible memory leak in unpack_trans_table · 1342ad78
      Fedor Pchelkin authored
      
      If we fail to unpack the transition table then the table elements which
      have been already allocated are not freed on error path.
      
      unreferenced object 0xffff88802539e000 (size 128):
        comm "apparmor_parser", pid 903, jiffies 4294914938 (age 35.085s)
        hex dump (first 32 bytes):
          20 73 6f 6d 65 20 6e 61 73 74 79 20 73 74 72 69   some nasty stri
          6e 67 20 73 6f 6d 65 20 6e 61 73 74 79 20 73 74  ng some nasty st
        backtrace:
          [<ffffffff81ddb312>] __kmem_cache_alloc_node+0x1e2/0x2d0
          [<ffffffff81c47194>] __kmalloc_node_track_caller+0x54/0x170
          [<ffffffff81c225b9>] kmemdup+0x29/0x60
          [<ffffffff83e1ee65>] aa_unpack_strdup+0xe5/0x1b0
          [<ffffffff83e20808>] unpack_pdb+0xeb8/0x2700
          [<ffffffff83e23567>] unpack_profile+0x1507/0x4a30
          [<ffffffff83e27bfa>] aa_unpack+0x36a/0x1560
          [<ffffffff83e194c3>] aa_replace_profiles+0x213/0x33c0
          [<ffffffff83de9461>] policy_update+0x261/0x370
          [<ffffffff83de978e>] profile_replace+0x20e/0x2a0
          [<ffffffff81eac8bf>] vfs_write+0x2af/0xe00
          [<ffffffff81eaddd6>] ksys_write+0x126/0x250
          [<ffffffff88f34fb6>] do_syscall_64+0x46/0xf0
          [<ffffffff890000ea>] entry_SYSCALL_64_after_hwframe+0x6e/0x76
      
      Call aa_free_str_table() on error path as was done before the blamed
      commit. It implements all necessary checks, frees str_table if it is
      available and nullifies the pointers.
      
      Found by Linux Verification Center (linuxtesting.org).
      
      Fixes: a0792e2c ("apparmor: make transition table unpack generic so it can be reused")
      Signed-off-by: default avatarFedor Pchelkin <pchelkin@ispras.ru>
      Signed-off-by: default avatarJohn Johansen <john.johansen@canonical.com>
      1342ad78
  7. Jan 03, 2024
  8. Dec 29, 2023
  9. Dec 24, 2023
    • Alfred Piccioni's avatar
      lsm: new security_file_ioctl_compat() hook · f1bb47a3
      Alfred Piccioni authored
      
      Some ioctl commands do not require ioctl permission, but are routed to
      other permissions such as FILE_GETATTR or FILE_SETATTR. This routing is
      done by comparing the ioctl cmd to a set of 64-bit flags (FS_IOC_*).
      
      However, if a 32-bit process is running on a 64-bit kernel, it emits
      32-bit flags (FS_IOC32_*) for certain ioctl operations. These flags are
      being checked erroneously, which leads to these ioctl operations being
      routed to the ioctl permission, rather than the correct file
      permissions.
      
      This was also noted in a RED-PEN finding from a while back -
      "/* RED-PEN how should LSM module know it's handling 32bit? */".
      
      This patch introduces a new hook, security_file_ioctl_compat(), that is
      called from the compat ioctl syscall. All current LSMs have been changed
      to support this hook.
      
      Reviewing the three places where we are currently using
      security_file_ioctl(), it appears that only SELinux needs a dedicated
      compat change; TOMOYO and SMACK appear to be functional without any
      change.
      
      Cc: stable@vger.kernel.org
      Fixes: 0b24dcb7 ("Revert "selinux: simplify ioctl checking"")
      Signed-off-by: default avatarAlfred Piccioni <alpic@google.com>
      Reviewed-by: default avatarStephen Smalley <stephen.smalley.work@gmail.com>
      [PM: subject tweak, line length fixes, and alignment corrections]
      Signed-off-by: default avatarPaul Moore <paul@paul-moore.com>
      f1bb47a3
  10. Dec 22, 2023
    • Paul Moore's avatar
      selinux: fix style issues in security/selinux/include/initial_sid_to_string.h · cc2a7341
      Paul Moore authored
      
      As part of on ongoing effort to perform more automated testing and
      provide more tools for individual developers to validate their
      patches before submitting, we are trying to make our code
      "clang-format clean".  My hope is that once we have fixed all of our
      style "quirks", developers will be able to run clang-format on their
      patches to help avoid silly formatting problems and ensure their
      changes fit in well with the rest of the SELinux kernel code.
      
      Signed-off-by: default avatarPaul Moore <paul@paul-moore.com>
      cc2a7341
    • Paul Moore's avatar
      selinux: fix style issues in security/selinux/include/xfrm.h · cea92163
      Paul Moore authored
      
      As part of on ongoing effort to perform more automated testing and
      provide more tools for individual developers to validate their
      patches before submitting, we are trying to make our code
      "clang-format clean".  My hope is that once we have fixed all of our
      style "quirks", developers will be able to run clang-format on their
      patches to help avoid silly formatting problems and ensure their
      changes fit in well with the rest of the SELinux kernel code.
      
      Signed-off-by: default avatarPaul Moore <paul@paul-moore.com>
      cea92163
    • Paul Moore's avatar
      selinux: fix style issues in security/selinux/include/security.h · 7d1464bd
      Paul Moore authored
      
      As part of on ongoing effort to perform more automated testing and
      provide more tools for individual developers to validate their
      patches before submitting, we are trying to make our code
      "clang-format clean".  My hope is that once we have fixed all of our
      style "quirks", developers will be able to run clang-format on their
      patches to help avoid silly formatting problems and ensure their
      changes fit in well with the rest of the SELinux kernel code.
      
      Signed-off-by: default avatarPaul Moore <paul@paul-moore.com>
      7d1464bd
    • Paul Moore's avatar
      selinux: fix style issues with security/selinux/include/policycap_names.h · 376ef14d
      Paul Moore authored
      
      As part of on ongoing effort to perform more automated testing and
      provide more tools for individual developers to validate their
      patches before submitting, we are trying to make our code
      "clang-format clean".  My hope is that once we have fixed all of our
      style "quirks", developers will be able to run clang-format on their
      patches to help avoid silly formatting problems and ensure their
      changes fit in well with the rest of the SELinux kernel code.
      
      Signed-off-by: default avatarPaul Moore <paul@paul-moore.com>
      376ef14d
    • Paul Moore's avatar
      selinux: fix style issues in security/selinux/include/policycap.h · db896a00
      Paul Moore authored
      
      As part of on ongoing effort to perform more automated testing and
      provide more tools for individual developers to validate their
      patches before submitting, we are trying to make our code
      "clang-format clean".  My hope is that once we have fixed all of our
      style "quirks", developers will be able to run clang-format on their
      patches to help avoid silly formatting problems and ensure their
      changes fit in well with the rest of the SELinux kernel code.
      
      Signed-off-by: default avatarPaul Moore <paul@paul-moore.com>
      db896a00
    • Paul Moore's avatar
      selinux: fix style issues in security/selinux/include/objsec.h · c7870220
      Paul Moore authored
      
      As part of on ongoing effort to perform more automated testing and
      provide more tools for individual developers to validate their
      patches before submitting, we are trying to make our code
      "clang-format clean".  My hope is that once we have fixed all of our
      style "quirks", developers will be able to run clang-format on their
      patches to help avoid silly formatting problems and ensure their
      changes fit in well with the rest of the SELinux kernel code.
      
      Signed-off-by: default avatarPaul Moore <paul@paul-moore.com>
      c7870220
    • Paul Moore's avatar
      selinux: fix style issues with security/selinux/include/netlabel.h · 3e7773f8
      Paul Moore authored
      
      As part of on ongoing effort to perform more automated testing and
      provide more tools for individual developers to validate their
      patches before submitting, we are trying to make our code
      "clang-format clean".  My hope is that once we have fixed all of our
      style "quirks", developers will be able to run clang-format on their
      patches to help avoid silly formatting problems and ensure their
      changes fit in well with the rest of the SELinux kernel code.
      
      Signed-off-by: default avatarPaul Moore <paul@paul-moore.com>
      3e7773f8
    • Paul Moore's avatar
      selinux: fix style issues in security/selinux/include/netif.h · e04f8585
      Paul Moore authored
      
      As part of on ongoing effort to perform more automated testing and
      provide more tools for individual developers to validate their
      patches before submitting, we are trying to make our code
      "clang-format clean".  My hope is that once we have fixed all of our
      style "quirks", developers will be able to run clang-format on their
      patches to help avoid silly formatting problems and ensure their
      changes fit in well with the rest of the SELinux kernel code.
      
      Signed-off-by: default avatarPaul Moore <paul@paul-moore.com>
      e04f8585
    • Paul Moore's avatar
      selinux: fix style issues in security/selinux/include/ima.h · e5a4cc30
      Paul Moore authored
      
      As part of on ongoing effort to perform more automated testing and
      provide more tools for individual developers to validate their
      patches before submitting, we are trying to make our code
      "clang-format clean".  My hope is that once we have fixed all of our
      style "quirks", developers will be able to run clang-format on their
      patches to help avoid silly formatting problems and ensure their
      changes fit in well with the rest of the SELinux kernel code.
      
      Signed-off-by: default avatarPaul Moore <paul@paul-moore.com>
      e5a4cc30
    • Paul Moore's avatar
      selinux: fix style issues in security/selinux/include/conditional.h · ce4a781b
      Paul Moore authored
      
      As part of on ongoing effort to perform more automated testing and
      provide more tools for individual developers to validate their
      patches before submitting, we are trying to make our code
      "clang-format clean".  My hope is that once we have fixed all of our
      style "quirks", developers will be able to run clang-format on their
      patches to help avoid silly formatting problems and ensure their
      changes fit in well with the rest of the SELinux kernel code.
      
      Signed-off-by: default avatarPaul Moore <paul@paul-moore.com>
      ce4a781b
    • Paul Moore's avatar
      selinux: fix style issues in security/selinux/include/classmap.h · 27283b31
      Paul Moore authored
      
      As part of on ongoing effort to perform more automated testing and
      provide more tools for individual developers to validate their
      patches before submitting, we are trying to make our code
      "clang-format clean".  My hope is that once we have fixed all of our
      style "quirks", developers will be able to run clang-format on their
      patches to help avoid silly formatting problems and ensure their
      changes fit in well with the rest of the SELinux kernel code.
      
      Signed-off-by: default avatarPaul Moore <paul@paul-moore.com>
      27283b31
    • Paul Moore's avatar
      selinux: fix style issues in security/selinux/include/avc_ss.h · 1d08fa8b
      Paul Moore authored
      
      As part of on ongoing effort to perform more automated testing and
      provide more tools for individual developers to validate their
      patches before submitting, we are trying to make our code
      "clang-format clean".  My hope is that once we have fixed all of our
      style "quirks", developers will be able to run clang-format on their
      patches to help avoid silly formatting problems and ensure their
      changes fit in well with the rest of the SELinux kernel code.
      
      Signed-off-by: default avatarPaul Moore <paul@paul-moore.com>
      1d08fa8b
    • Paul Moore's avatar
      selinux: align avc_has_perm_noaudit() prototype with definition · bb4e5993
      Paul Moore authored
      
      A trivial correction to convert an 'unsigned' parameter into an
      'unsigned int' parameter so the prototype matches the function
      definition.
      
      I really thought that someone submitted a patch for this a few years
      ago but sadly I can't find it now.
      
      Signed-off-by: default avatarPaul Moore <paul@paul-moore.com>
      bb4e5993
    • Paul Moore's avatar
      selinux: fix style issues in security/selinux/include/avc.h · bdaaf515
      Paul Moore authored
      
      As part of on ongoing effort to perform more automated testing and
      provide more tools for individual developers to validate their
      patches before submitting, we are trying to make our code
      "clang-format clean".  My hope is that once we have fixed all of our
      style "quirks", developers will be able to run clang-format on their
      patches to help avoid silly formatting problems and ensure their
      changes fit in well with the rest of the SELinux kernel code.
      
      Signed-off-by: default avatarPaul Moore <paul@paul-moore.com>
      bdaaf515
    • Paul Moore's avatar
      selinux: fix style issues in security/selinux/include/audit.h · e9b0748b
      Paul Moore authored
      
      As part of on ongoing effort to perform more automated testing and
      provide more tools for individual developers to validate their
      patches before submitting, we are trying to make our code
      "clang-format clean".  My hope is that once we have fixed all of our
      style "quirks", developers will be able to run clang-format on their
      patches to help avoid silly formatting problems and ensure their
      changes fit in well with the rest of the SELinux kernel code.
      
      Signed-off-by: default avatarPaul Moore <paul@paul-moore.com>
      e9b0748b
  11. Dec 21, 2023
    • Al Viro's avatar
      apparmorfs: don't duplicate kfree_link() · c5f3fd21
      Al Viro authored
      
      rawdata_link_cb() is identical to it
      
      Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
      c5f3fd21
    • David Howells's avatar
      keys, dns: Allow key types (eg. DNS) to be reclaimed immediately on expiry · 39299bdd
      David Howells authored
      
      If a key has an expiration time, then when that time passes, the key is
      left around for a certain amount of time before being collected (5 mins by
      default) so that EKEYEXPIRED can be returned instead of ENOKEY.  This is a
      problem for DNS keys because we want to redo the DNS lookup immediately at
      that point.
      
      Fix this by allowing key types to be marked such that keys of that type
      don't have this extra period, but are reclaimed as soon as they expire and
      turn this on for dns_resolver-type keys.  To make this easier to handle,
      key->expiry is changed to be permanent if TIME64_MAX rather than 0.
      
      Furthermore, give such new-style negative DNS results a 1s default expiry
      if no other expiry time is set rather than allowing it to stick around
      indefinitely.  This shouldn't be zero as ls will follow a failing stat call
      immediately with a second with AT_SYMLINK_NOFOLLOW added.
      
      Fixes: 1a4240f4 ("DNS: Separate out CIFS DNS Resolver code")
      Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
      Tested-by: default avatarMarkus Suvanto <markus.suvanto@gmail.com>
      cc: Wang Lei <wang840925@gmail.com>
      cc: Jeff Layton <jlayton@redhat.com>
      cc: Steve French <smfrench@gmail.com>
      cc: Marc Dionne <marc.dionne@auristor.com>
      cc: Jarkko Sakkinen <jarkko@kernel.org>
      cc: "David S. Miller" <davem@davemloft.net>
      cc: Eric Dumazet <edumazet@google.com>
      cc: Jakub Kicinski <kuba@kernel.org>
      cc: Paolo Abeni <pabeni@redhat.com>
      cc: linux-afs@lists.infradead.org
      cc: linux-cifs@vger.kernel.org
      cc: linux-nfs@vger.kernel.org
      cc: ceph-devel@vger.kernel.org
      cc: keyrings@vger.kernel.org
      cc: netdev@vger.kernel.org
      39299bdd
    • Kent Overstreet's avatar
      shm: Slim down dependencies · bc46ef3c
      Kent Overstreet authored
      
      list_head is in types.h, not list.h., and the uapi header wasn't needed.
      
      Signed-off-by: default avatarKent Overstreet <kent.overstreet@linux.dev>
      bc46ef3c
  12. Dec 20, 2023
  13. Dec 19, 2023
  14. Dec 15, 2023
Loading