Forum | Documentation | Website | Blog

Skip to content
Snippets Groups Projects
  1. Jul 24, 2024
  2. Jul 18, 2024
  3. Jul 09, 2024
  4. Jul 08, 2024
  5. Jul 02, 2024
  6. Jul 01, 2024
  7. Jun 19, 2024
    • Konstantin Andreev's avatar
      smack: unix sockets: fix accept()ed socket label · e86cac0a
      Konstantin Andreev authored
      
      When a process accept()s connection from a unix socket
      (either stream or seqpacket)
      it gets the socket with the label of the connecting process.
      
      For example, if a connecting process has a label 'foo',
      the accept()ed socket will also have 'in' and 'out' labels 'foo',
      regardless of the label of the listener process.
      
      This is because kernel creates unix child sockets
      in the context of the connecting process.
      
      I do not see any obvious way for the listener to abuse
      alien labels coming with the new socket, but,
      to be on the safe side, it's better fix new socket labels.
      
      Signed-off-by: default avatarKonstantin Andreev <andreev@swemel.ru>
      Signed-off-by: default avatarCasey Schaufler <casey@schaufler-ca.com>
      e86cac0a
  8. Jun 15, 2024
    • David Hildenbrand's avatar
      Revert "mm: init_mlocked_on_free_v3" · 384a746b
      David Hildenbrand authored
      There was insufficient review and no agreement that this is the right
      approach.
      
      There are serious flaws with the implementation that make processes using
      mlock() not even work with simple fork() [1] and we get reliable crashes
      when rebooting.
      
      Further, simply because we might be unmapping a single PTE of a large
      mlocked folio, we shouldn't zero out the whole folio.
      
      ... especially because the code can also *corrupt* urelated memory because
      	kernel_init_pages(page, folio_nr_pages(folio));
      
      Could end up writing outside of the actual folio if we work with a tail
      page.
      
      Let's revert it.  Once there is agreement that this is the right approach,
      the issues were fixed and there was reasonable review and proper testing,
      we can consider it again.
      
      [1] https://lkml.kernel.org/r/4da9da2f-73e4-45fd-b62f-a8a513314057@redhat.com
      
      Link: https://lkml.kernel.org/r/20240605091710.38961-1-david@redhat.com
      Fixes: ba42b524 ("mm: init_mlocked_on_free_v3")
      Signed-off-by: David Hildenbra...
      384a746b
  9. Jun 13, 2024
    • GUO Zihua's avatar
      ima: Avoid blocking in RCU read-side critical section · 9a95c5bf
      GUO Zihua authored
      A panic happens in ima_match_policy:
      
      BUG: unable to handle kernel NULL pointer dereference at 0000000000000010
      PGD 42f873067 P4D 0
      Oops: 0000 [#1] SMP NOPTI
      CPU: 5 PID: 1286325 Comm: kubeletmonit.sh
      Kdump: loaded Tainted: P
      Hardware name: QEMU Standard PC (i440FX + PIIX, 1996),
                     BIOS 0.0.0 02/06/2015
      RIP: 0010:ima_match_policy+0x84/0x450
      Code: 49 89 fc 41 89 cf 31 ed 89 44 24 14 eb 1c 44 39
            7b 18 74 26 41 83 ff 05 74 20 48 8b 1b 48 3b 1d
            f2 b9 f4 00 0f 84 9c 01 00 00 <44> 85 73 10 74 ea
            44 8b 6b 14 41 f6 c5 01 75 d4 41 f6 c5 02 74 0f
      RSP: 0018:ff71570009e07a80 EFLAGS: 00010207
      RAX: 0000000000000000 RBX: 0000000000000000 RCX: 0000000000000200
      RDX: ffffffffad8dc7c0 RSI: 0000000024924925 RDI: ff3e27850dea2000
      RBP: 0000000000000000 R08: 0000000000000000 R09: ffffffffabfce739
      R10: ff3e27810cc42400 R11: 0000000000000000 R12: ff3e2781825ef970
      R13: 00000000ff3e2785 R14: 000000000000000c R15: 0000000000000001
      FS:  00007f5195b51740(0000)
      GS:ff3e278b12d40000(0000) knlGS:0000000000000000
      CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
      CR2: 0000000000000010 CR3: 0000000626d24002 CR4: 0000000000361ee0
      DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
      DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
      Call Trace:
       ima_get_action+0x22/0x30
       process_measurement+0xb0/0x830
       ? page_add_file_rmap+0x15/0x170
       ? alloc_set_pte+0x269/0x4c0
       ? prep_new_page+0x81/0x140
       ? simple_xattr_get+0x75/0xa0
       ? selinux_file_open+0x9d/0xf0
       ima_file_check+0x64/0x90
       path_openat+0x571/0x1720
       do_filp_open+0x9b/0x110
       ? page_counter_try_charge+0x57/0xc0
       ? files_cgroup_alloc_fd+0x38/0x60
       ? __alloc_fd+0xd4/0x250
       ? do_sys_open+0x1bd/0x250
       do_sys_open+0x1bd/0x250
       do_syscall_64+0x5d/0x1d0
       entry_SYSCALL_64_after_hwframe+0x65/0xca
      
      Commit c7423dbd ("ima: Handle -ESTALE returned by
      ima_filter_rule_match()") introduced call to ima_lsm_copy_rule within a
      RCU read-side critical section which contains kmalloc with GFP_KERNEL.
      This implies a possible sleep and violates limitations of RCU read-side
      critical sections on non-PREEMPT systems.
      
      Sleeping within RCU read-side critical section might cause
      synchronize_rcu() returning early and break RCU protection, allowing a
      UAF to happen.
      
      The root cause of this issue could be described as follows:
      |	Thread A	|	Thread B	|
      |			|ima_match_policy	|
      |			|  rcu_read_lock	|
      |ima_lsm_update_rule	|			|
      |  synchronize_rcu	|			|
      |			|    kmalloc(GFP_KERNEL)|
      |			|      sleep		|
      ==> synchronize_rcu returns early
      |  kfree(entry)		|			|
      |			|    entry = entry->next|
      ==> UAF happens and entry now becomes NULL (or could be anything).
      |			|    entry->action	|
      ==> Accessing entry might cause panic.
      
      To fix this issue, we are converting all kmalloc that is called within
      RCU read-side critical section to use GFP_ATOMIC.
      
      Fixes: c7423dbd
      
       ("ima: Handle -ESTALE returned by ima_filter_rule_match()")
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarGUO Zihua <guozihua@huawei.com>
      Acked-by: default avatarJohn Johansen <john.johansen@canonical.com>
      Reviewed-by: default avatarMimi Zohar <zohar@linux.ibm.com>
      Reviewed-by: default avatarCasey Schaufler <casey@schaufler-ca.com>
      [PM: fixed missing comment, long lines, !CONFIG_IMA_LSM_RULES case]
      Signed-off-by: default avatarPaul Moore <paul@paul-moore.com>
      9a95c5bf
  10. Jun 07, 2024
    • Herbert Xu's avatar
      crypto: sm2 - Remove sm2 algorithm · 46b3ff73
      Herbert Xu authored
      
      The SM2 algorithm has a single user in the kernel.  However, it's
      never been integrated properly with that user: asymmetric_keys.
      
      The crux of the issue is that the way it computes its digest with
      sm3 does not fit into the architecture of asymmetric_keys.  As no
      solution has been proposed, remove this algorithm.
      
      It can be resubmitted when it is integrated properly into the
      asymmetric_keys subsystem.
      
      Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
      46b3ff73
  11. Jun 06, 2024
  12. Jun 05, 2024
    • Casey Schaufler's avatar
      smack: tcp: ipv4, fix incorrect labeling · 2fe209d0
      Casey Schaufler authored
      
      Currently, Smack mirrors the label of incoming tcp/ipv4 connections:
      when a label 'foo' connects to a label 'bar' with tcp/ipv4,
      'foo' always gets 'foo' in returned ipv4 packets. So,
      1) returned packets are incorrectly labeled ('foo' instead of 'bar')
      2) 'bar' can write to 'foo' without being authorized to write.
      
      Here is a scenario how to see this:
      
      * Take two machines, let's call them C and S,
         with active Smack in the default state
         (no settings, no rules, no labeled hosts, only builtin labels)
      
      * At S, add Smack rule 'foo bar w'
         (labels 'foo' and 'bar' are instantiated at S at this moment)
      
      * At S, at label 'bar', launch a program
         that listens for incoming tcp/ipv4 connections
      
      * From C, at label 'foo', connect to the listener at S.
         (label 'foo' is instantiated at C at this moment)
         Connection succeedes and works.
      
      * Send some data in both directions.
      * Collect network traffic of this connection.
      
      All packets in both directions are labeled with the CIPSO
      of the label 'foo'. Hence, label 'bar' writes to 'foo' without
      being authorized, and even without ever being known at C.
      
      If anybody cares: exactly the same happens with DCCP.
      
      This behavior 1st manifested in release 2.6.29.4 (see Fixes below)
      and it looks unintentional. At least, no explanation was provided.
      
      I changed returned packes label into the 'bar',
      to bring it into line with the Smack documentation claims.
      
      Signed-off-by: default avatarKonstantin Andreev <andreev@swemel.ru>
      Signed-off-by: default avatarCasey Schaufler <casey@schaufler-ca.com>
      2fe209d0
  13. Jun 03, 2024
    • Paul Moore's avatar
      lsm: fixup the inode xattr capability handling · 61df7b82
      Paul Moore authored
      
      The current security_inode_setxattr() and security_inode_removexattr()
      hooks rely on individual LSMs to either call into the associated
      capability hooks (cap_inode_setxattr() or cap_inode_removexattr()), or
      return a magic value of 1 to indicate that the LSM layer itself should
      perform the capability checks.  Unfortunately, with the default return
      value for these LSM hooks being 0, an individual LSM hook returning a
      1 will cause the LSM hook processing to exit early, potentially
      skipping a LSM.  Thankfully, with the exception of the BPF LSM, none
      of the LSMs which currently register inode xattr hooks should end up
      returning a value of 1, and in the BPF LSM case, with the BPF LSM hooks
      executing last there should be no real harm in stopping processing of
      the LSM hooks.  However, the reliance on the individual LSMs to either
      call the capability hooks themselves, or signal the LSM with a return
      value of 1, is fragile and relies on a specific set of LSMs being
      enabled.  This patch is an effort to resolve, or minimize, these
      issues.
      
      Before we discuss the solution, there are a few observations and
      considerations that we need to take into account:
      * BPF LSM registers an implementation for every LSM hook, and that
        implementation simply returns the hook's default return value, a
        0 in this case.  We want to ensure that the default BPF LSM behavior
        results in the capability checks being called.
      * SELinux and Smack do not expect the traditional capability checks
        to be applied to the xattrs that they "own".
      * SELinux and Smack are currently written in such a way that the
        xattr capability checks happen before any additional LSM specific
        access control checks.  SELinux does apply SELinux specific access
        controls to all xattrs, even those not "owned" by SELinux.
      * IMA and EVM also register xattr hooks but assume that the LSM layer
        and specific LSMs have already authorized the basic xattr operation.
      
      In order to ensure we perform the capability based access controls
      before the individual LSM access controls, perform only one capability
      access control check for each operation, and clarify the logic around
      applying the capability controls, we need a mechanism to determine if
      any of the enabled LSMs "own" a particular xattr and want to take
      responsibility for controlling access to that xattr.  The solution in
      this patch is to create a new LSM hook, 'inode_xattr_skipcap', that is
      not exported to the rest of the kernel via a security_XXX() function,
      but is used by the LSM layer to determine if a LSM wants to control
      access to a given xattr and avoid the traditional capability controls.
      Registering an inode_xattr_skipcap hook is optional, if a LSM declines
      to register an implementation, or uses an implementation that simply
      returns the default value (0), there is no effect as the LSM continues
      to enforce the capability based controls (unless another LSM takes
      ownership of the xattr).  If none of the LSMs signal that the
      capability checks should be skipped, the capability check is performed
      and if access is granted the individual LSM xattr access control hooks
      are executed, keeping with the DAC-before-LSM convention.
      
      Cc: stable@vger.kernel.org
      Acked-by: default avatarCasey Schaufler <casey@schaufler-ca.com>
      Signed-off-by: default avatarPaul Moore <paul@paul-moore.com>
      61df7b82
    • Enrico Bravi's avatar
      ima: fix wrong zero-assignment during securityfs dentry remove · fbf06cee
      Enrico Bravi authored
      In case of error during ima_fs_init() all the dentry already created
      are removed. {ascii, binary}_securityfs_measurement_lists are freed
      calling for each array the remove_securityfs_measurement_lists(). This
      function, at the end, assigns to zero the securityfs_measurement_list_count.
      This causes during the second call of remove_securityfs_measurement_lists()
      to leave the dentry of the array pending, not removing them correctly,
      because the securityfs_measurement_list_count is already zero.
      
      Move the securityfs_measurement_list_count = 0 after the two
      remove_securityfs_measurement_lists() calls to correctly remove all the
      dentry already allocated.
      
      Fixes: 9fa8e762
      
       ("ima: add crypto agility support for template-hash algorithm")
      Signed-off-by: default avatarEnrico Bravi <enrico.bravi@polito.it>
      Reviewed-by: default avatarRoberto Sassu <roberto.sassu@huawei.com>
      Signed-off-by: default avatarMimi Zohar <zohar@linux.ibm.com>
      fbf06cee
    • Tetsuo Handa's avatar
      tomoyo: update project links · c6144a21
      Tetsuo Handa authored
      
      TOMOYO project has moved to SourceForge.net .
      
      Signed-off-by: default avatarTetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
      c6144a21
  14. May 31, 2024
  15. May 20, 2024
    • Jarkko Sakkinen's avatar
      KEYS: trusted: Do not use WARN when encode fails · 050bf3c7
      Jarkko Sakkinen authored
      When asn1_encode_sequence() fails, WARN is not the correct solution.
      
      1. asn1_encode_sequence() is not an internal function (located
         in lib/asn1_encode.c).
      2. Location is known, which makes the stack trace useless.
      3. Results a crash if panic_on_warn is set.
      
      It is also noteworthy that the use of WARN is undocumented, and it
      should be avoided unless there is a carefully considered rationale to
      use it.
      
      Replace WARN with pr_err, and print the return value instead, which is
      only useful piece of information.
      
      Cc: stable@vger.kernel.org # v5.13+
      Fixes: f2219745
      
       ("security: keys: trusted: use ASN.1 TPM2 key format for the blobs")
      Signed-off-by: default avatarJarkko Sakkinen <jarkko@kernel.org>
      050bf3c7
    • Jarkko Sakkinen's avatar
      KEYS: trusted: Fix memory leak in tpm2_key_encode() · ffcaa217
      Jarkko Sakkinen authored
      'scratch' is never freed. Fix this by calling kfree() in the success, and
      in the error case.
      
      Cc: stable@vger.kernel.org # +v5.13
      Fixes: f2219745
      
       ("security: keys: trusted: use ASN.1 TPM2 key format for the blobs")
      Signed-off-by: default avatarJarkko Sakkinen <jarkko@kernel.org>
      ffcaa217
  16. May 18, 2024
  17. May 13, 2024
    • Davide Caratti's avatar
      netlabel: fix RCU annotation for IPv4 options on socket creation · 8ec9897e
      Davide Caratti authored
      Xiumei reports the following splat when netlabel and TCP socket are used:
      
       =============================
       WARNING: suspicious RCU usage
       6.9.0-rc2+ #637 Not tainted
       -----------------------------
       net/ipv4/cipso_ipv4.c:1880 suspicious rcu_dereference_protected() usage!
      
       other info that might help us debug this:
      
       rcu_scheduler_active = 2, debug_locks = 1
       1 lock held by ncat/23333:
        #0: ffffffff906030c0 (rcu_read_lock){....}-{1:2}, at: netlbl_sock_setattr+0x25/0x1b0
      
       stack backtrace:
       CPU: 11 PID: 23333 Comm: ncat Kdump: loaded Not tainted 6.9.0-rc2+ #637
       Hardware name: Supermicro SYS-6027R-72RF/X9DRH-7TF/7F/iTF/iF, BIOS 3.0  07/26/2013
       Call Trace:
        <TASK>
        dump_stack_lvl+0xa9/0xc0
        lockdep_rcu_suspicious+0x117/0x190
        cipso_v4_sock_setattr+0x1ab/0x1b0
        netlbl_sock_setattr+0x13e/0x1b0
        selinux_netlbl_socket_post_create+0x3f/0x80
        selinux_socket_post_create+0x1a0/0x460
        security_socket_post_create+0x42/0x60
        __sock_create+0x342/0x3a0
        __sys_socket_create.part.22+0x42/0x70
        __sys_socket+0x37/0xb0
        __x64_sys_socket+0x16/0x20
        do_syscall_64+0x96/0x180
        ? do_user_addr_fault+0x68d/0xa30
        ? exc_page_fault+0x171/0x280
        ? asm_exc_page_fault+0x22/0x30
        entry_SYSCALL_64_after_hwframe+0x71/0x79
       RIP: 0033:0x7fbc0ca3fc1b
       Code: 73 01 c3 48 8b 0d 05 f2 1b 00 f7 d8 64 89 01 48 83 c8 ff c3 66 2e 0f 1f 84 00 00 00 00 00 90 f3 0f 1e fa b8 29 00 00 00 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 8b 0d d5 f1 1b 00 f7 d8 64 89 01 48
       RSP: 002b:00007fff18635208 EFLAGS: 00000246 ORIG_RAX: 0000000000000029
       RAX: ffffffffffffffda RBX: 0000000000000001 RCX: 00007fbc0ca3fc1b
       RDX: 0000000000000006 RSI: 0000000000000001 RDI: 0000000000000002
       RBP: 000055d24f80f8a0 R08: 0000000000000003 R09: 0000000000000001
      
      R10: 0000000000020000 R11: 0000000000000246 R12: 000055d24f80f8a0
       R13: 0000000000000000 R14: 000055d24f80fb88 R15: 0000000000000000
        </TASK>
      
      The current implementation of cipso_v4_sock_setattr() replaces IP options
      under the assumption that the caller holds the socket lock; however, such
      assumption is not true, nor needed, in selinux_socket_post_create() hook.
      
      Let all callers of cipso_v4_sock_setattr() specify the "socket lock held"
      condition, except selinux_socket_post_create() _ where such condition can
      safely be set as true even without holding the socket lock.
      
      Fixes: f6d8bd05
      
       ("inet: add RCU protection to inet->opt")
      Reported-by: default avatarXiumei Mu <xmu@redhat.com>
      Signed-off-by: default avatarDavide Caratti <dcaratti@redhat.com>
      Acked-by: default avatarCasey Schaufler <casey@schaufler-ca.com>
      Acked-by: default avatarPaul Moore <paul@paul-moore.com>
      Link: https://lore.kernel.org/r/f4260d000a3a55b9e8b6a3b4e3fffc7da9f82d41.1715359817.git.dcaratti@redhat.com
      
      
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      8ec9897e
    • Günther Noack's avatar
      landlock: Add IOCTL access right for character and block devices · b25f7415
      Günther Noack authored
      
      Introduces the LANDLOCK_ACCESS_FS_IOCTL_DEV right
      and increments the Landlock ABI version to 5.
      
      This access right applies to device-custom IOCTL commands
      when they are invoked on block or character device files.
      
      Like the truncate right, this right is associated with a file
      descriptor at the time of open(2), and gets respected even when the
      file descriptor is used outside of the thread which it was originally
      opened in.
      
      Therefore, a newly enabled Landlock policy does not apply to file
      descriptors which are already open.
      
      If the LANDLOCK_ACCESS_FS_IOCTL_DEV right is handled, only a small
      number of safe IOCTL commands will be permitted on newly opened device
      files.  These include FIOCLEX, FIONCLEX, FIONBIO and FIOASYNC, as well
      as other IOCTL commands for regular files which are implemented in
      fs/ioctl.c.
      
      Noteworthy scenarios which require special attention:
      
      TTY devices are often passed into a process from the parent process,
      and so a newly enabled Landlock policy does not retroactively apply to
      them automatically.  In the past, TTY devices have often supported
      IOCTL commands like TIOCSTI and some TIOCLINUX subcommands, which were
      letting callers control the TTY input buffer (and simulate
      keypresses).  This should be restricted to CAP_SYS_ADMIN programs on
      modern kernels though.
      
      Known limitations:
      
      The LANDLOCK_ACCESS_FS_IOCTL_DEV access right is a coarse-grained
      control over IOCTL commands.
      
      Landlock users may use path-based restrictions in combination with
      their knowledge about the file system layout to control what IOCTLs
      can be done.
      
      Cc: Paul Moore <paul@paul-moore.com>
      Cc: Christian Brauner <brauner@kernel.org>
      Cc: Arnd Bergmann <arnd@arndb.de>
      Signed-off-by: default avatarGünther Noack <gnoack@google.com>
      Link: https://lore.kernel.org/r/20240419161122.2023765-2-gnoack@google.com
      
      
      Signed-off-by: default avatarMickaël Salaün <mic@digikod.net>
      b25f7415
  18. May 10, 2024
    • Leesoo Ahn's avatar
      apparmor: fix possible NULL pointer dereference · 3dd38410
      Leesoo Ahn authored
      
      profile->parent->dents[AAFS_PROF_DIR] could be NULL only if its parent is made
      from __create_missing_ancestors(..) and 'ent->old' is NULL in
      aa_replace_profiles(..).
      In that case, it must return an error code and the code, -ENOENT represents
      its state that the path of its parent is not existed yet.
      
      BUG: kernel NULL pointer dereference, address: 0000000000000030
      PGD 0 P4D 0
      PREEMPT SMP PTI
      CPU: 4 PID: 3362 Comm: apparmor_parser Not tainted 6.8.0-24-generic #24
      Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.15.0-1 04/01/2014
      RIP: 0010:aafs_create.constprop.0+0x7f/0x130
      Code: 4c 63 e0 48 83 c4 18 4c 89 e0 5b 41 5c 41 5d 41 5e 41 5f 5d 31 d2 31 c9 31 f6 31 ff 45 31 c0 45 31 c9 45 31 d2 c3 cc cc cc cc <4d> 8b 55 30 4d 8d ba a0 00 00 00 4c 89 55 c0 4c 89 ff e8 7a 6a ae
      RSP: 0018:ffffc9000b2c7c98 EFLAGS: 00010246
      RAX: 0000000000000000 RBX: 00000000000041ed RCX: 0000000000000000
      RDX: 0000000000000000 RSI: 0000000000000000 RDI: 0000000000000000
      RBP: ffffc9000b2c7cd8 R08: 0000000000000000 R09: 0000000000000000
      R10: 0000000000000000 R11: 0000000000000000 R12: ffffffff82baac10
      R13: 0000000000000000 R14: 0000000000000000 R15: 0000000000000000
      FS:  00007be9f22cf740(0000) GS:ffff88817bc00000(0000) knlGS:0000000000000000
      CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
      CR2: 0000000000000030 CR3: 0000000134b08000 CR4: 00000000000006f0
      Call Trace:
       <TASK>
       ? show_regs+0x6d/0x80
       ? __die+0x24/0x80
       ? page_fault_oops+0x99/0x1b0
       ? kernelmode_fixup_or_oops+0xb2/0x140
       ? __bad_area_nosemaphore+0x1a5/0x2c0
       ? find_vma+0x34/0x60
       ? bad_area_nosemaphore+0x16/0x30
       ? do_user_addr_fault+0x2a2/0x6b0
       ? exc_page_fault+0x83/0x1b0
       ? asm_exc_page_fault+0x27/0x30
       ? aafs_create.constprop.0+0x7f/0x130
       ? aafs_create.constprop.0+0x51/0x130
       __aafs_profile_mkdir+0x3d6/0x480
       aa_replace_profiles+0x83f/0x1270
       policy_update+0xe3/0x180
       profile_load+0xbc/0x150
       ? rw_verify_area+0x47/0x140
       vfs_write+0x100/0x480
       ? __x64_sys_openat+0x55/0xa0
       ? syscall_exit_to_user_mode+0x86/0x260
       ksys_write+0x73/0x100
       __x64_sys_write+0x19/0x30
       x64_sys_call+0x7e/0x25c0
       do_syscall_64+0x7f/0x180
       entry_SYSCALL_64_after_hwframe+0x78/0x80
      RIP: 0033:0x7be9f211c574
      Code: c7 00 16 00 00 00 b8 ff ff ff ff c3 66 2e 0f 1f 84 00 00 00 00 00 f3 0f 1e fa 80 3d d5 ea 0e 00 00 74 13 b8 01 00 00 00 0f 05 <48> 3d 00 f0 ff ff 77 54 c3 0f 1f 00 55 48 89 e5 48 83 ec 20 48 89
      RSP: 002b:00007ffd26f2b8c8 EFLAGS: 00000202 ORIG_RAX: 0000000000000001
      RAX: ffffffffffffffda RBX: 00005d504415e200 RCX: 00007be9f211c574
      RDX: 0000000000001fc1 RSI: 00005d504418bc80 RDI: 0000000000000004
      RBP: 0000000000001fc1 R08: 0000000000001fc1 R09: 0000000080000000
      R10: 0000000000000000 R11: 0000000000000202 R12: 00005d504418bc80
      R13: 0000000000000004 R14: 00007ffd26f2b9b0 R15: 00007ffd26f2ba30
       </TASK>
      Modules linked in: snd_seq_dummy snd_hrtimer qrtr snd_hda_codec_generic snd_hda_intel snd_intel_dspcfg snd_intel_sdw_acpi snd_hda_codec snd_hda_core snd_hwdep snd_pcm snd_seq_midi snd_seq_midi_event snd_rawmidi snd_seq snd_seq_device i2c_i801 snd_timer i2c_smbus qxl snd soundcore drm_ttm_helper lpc_ich ttm joydev input_leds serio_raw mac_hid binfmt_misc msr parport_pc ppdev lp parport efi_pstore nfnetlink dmi_sysfs qemu_fw_cfg ip_tables x_tables autofs4 hid_generic usbhid hid ahci libahci psmouse virtio_rng xhci_pci xhci_pci_renesas
      CR2: 0000000000000030
      ---[ end trace 0000000000000000 ]---
      RIP: 0010:aafs_create.constprop.0+0x7f/0x130
      Code: 4c 63 e0 48 83 c4 18 4c 89 e0 5b 41 5c 41 5d 41 5e 41 5f 5d 31 d2 31 c9 31 f6 31 ff 45 31 c0 45 31 c9 45 31 d2 c3 cc cc cc cc <4d> 8b 55 30 4d 8d ba a0 00 00 00 4c 89 55 c0 4c 89 ff e8 7a 6a ae
      RSP: 0018:ffffc9000b2c7c98 EFLAGS: 00010246
      RAX: 0000000000000000 RBX: 00000000000041ed RCX: 0000000000000000
      RDX: 0000000000000000 RSI: 0000000000000000 RDI: 0000000000000000
      RBP: ffffc9000b2c7cd8 R08: 0000000000000000 R09: 0000000000000000
      R10: 0000000000000000 R11: 0000000000000000 R12: ffffffff82baac10
      R13: 0000000000000000 R14: 0000000000000000 R15: 0000000000000000
      FS:  00007be9f22cf740(0000) GS:ffff88817bc00000(0000) knlGS:0000000000000000
      CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
      CR2: 0000000000000030 CR3: 0000000134b08000 CR4: 00000000000006f0
      
      Signed-off-by: default avatarLeesoo Ahn <lsahn@ooseel.net>
      Signed-off-by: default avatarJohn Johansen <john.johansen@canonical.com>
      3dd38410
    • Christian Göttsche's avatar
      apparmor: fix typo in kernel doc · b2c85814
      Christian Göttsche authored
      
      Fix the typo in the function documentation to please kernel doc
      warnings.
      
      Signed-off-by: default avatarChristian Göttsche <cgzones@googlemail.com>
      Reviewed-by: default avatarKees Cook <keescook@chromium.org>
      Signed-off-by: default avatarJohn Johansen <john.johansen@canonical.com>
      b2c85814
    • Colin Ian King's avatar
      apparmor: remove useless static inline function is_deleted · 4a8db367
      Colin Ian King authored
      
      The inlined function is_deleted is redundant, it is not called at all
      from any function in security/apparmor/file.c and so it can be removed.
      
      Cleans up clang scan build warning:
      security/apparmor/file.c:153:20: warning: unused function
      'is_deleted' [-Wunused-function]
      
      Signed-off-by: default avatarColin Ian King <colin.i.king@gmail.com>
      Signed-off-by: default avatarJohn Johansen <john.johansen@canonical.com>
      4a8db367
    • Fedor Pchelkin's avatar
      apparmor: use kvfree_sensitive to free data->data · 2bc73505
      Fedor Pchelkin authored
      Inside unpack_profile() data->data is allocated using kvmemdup() so it
      should be freed with the corresponding kvfree_sensitive().
      
      Also add missing data->data release for rhashtable insertion failure path
      in unpack_profile().
      
      Found by Linux Verification Center (linuxtesting.org).
      
      Fixes: e025be0f
      
       ("apparmor: support querying extended trusted helper extra data")
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarFedor Pchelkin <pchelkin@ispras.ru>
      Signed-off-by: default avatarJohn Johansen <john.johansen@canonical.com>
      2bc73505
    • Xiao Liang's avatar
      apparmor: Fix null pointer deref when receiving skb during sock creation · fce09ea3
      Xiao Liang authored
      The panic below is observed when receiving ICMP packets with secmark set
      while an ICMP raw socket is being created. SK_CTX(sk)->label is updated
      in apparmor_socket_post_create(), but the packet is delivered to the
      socket before that, causing the null pointer dereference.
      Drop the packet if label context is not set.
      
          BUG: kernel NULL pointer dereference, address: 000000000000004c
          #PF: supervisor read access in kernel mode
          #PF: error_code(0x0000) - not-present page
          PGD 0 P4D 0
          Oops: 0000 [#1] PREEMPT SMP NOPTI
          CPU: 0 PID: 407 Comm: a.out Not tainted 6.4.12-arch1-1 #1 3e6fa2753a2d75925c34ecb78e22e85a65d083df
          Hardware name: VMware, Inc. VMware Virtual Platform/440BX Desktop Reference Platform, BIOS 6.00 05/28/2020
          RIP: 0010:aa_label_next_confined+0xb/0x40
          Code: 00 00 48 89 ef e8 d5 25 0c 00 e9 66 ff ff ff 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 66 0f 1f 00 0f 1f 44 00 00 89 f0 <8b> 77 4c 39 c6 7e 1f 48 63 d0 48 8d 14 d7 eb 0b 83 c0 01 48 83 c2
          RSP: 0018:ffffa92940003b08 EFLAGS: 00010246
          RAX: 0000000000000000 RBX: 0000000000000000 RCX: 000000000000000e
          RDX: ffffa92940003be8 RSI: 0000000000000000 RDI: 0000000000000000
          RBP: ffff8b57471e7800 R08: ffff8b574c642400 R09: 0000000000000002
          R10: ffffffffbd820eeb R11: ffffffffbeb7ff00 R12: ffff8b574c642400
          R13: 0000000000000001 R14: 0000000000000001 R15: 0000000000000000
          FS:  00007fb092ea7640(0000) GS:ffff8b577bc00000(0000) knlGS:0000000000000000
          CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
          CR2: 000000000000004c CR3: 00000001020f2005 CR4: 00000000007706f0
          PKRU: 55555554
          Call Trace:
           <IRQ>
           ? __die+0x23/0x70
           ? page_fault_oops+0x171/0x4e0
           ? exc_page_fault+0x7f/0x180
           ? asm_exc_page_fault+0x26/0x30
           ? aa_label_next_confined+0xb/0x40
           apparmor_secmark_check+0xec/0x330
           security_sock_rcv_skb+0x35/0x50
           sk_filter_trim_cap+0x47/0x250
           sock_queue_rcv_skb_reason+0x20/0x60
           raw_rcv+0x13c/0x210
           raw_local_deliver+0x1f3/0x250
           ip_protocol_deliver_rcu+0x4f/0x2f0
           ip_local_deliver_finish+0x76/0xa0
           __netif_receive_skb_one_core+0x89/0xa0
           netif_receive_skb+0x119/0x170
           ? __netdev_alloc_skb+0x3d/0x140
           vmxnet3_rq_rx_complete+0xb23/0x1010 [vmxnet3 56a84f9c97178c57a43a24ec073b45a9d6f01f3a]
           vmxnet3_poll_rx_only+0x36/0xb0 [vmxnet3 56a84f9c97178c57a43a24ec073b45a9d6f01f3a]
           __napi_poll+0x28/0x1b0
           net_rx_action+0x2a4/0x380
           __do_softirq+0xd1/0x2c8
           __irq_exit_rcu+0xbb/0xf0
           common_interrupt+0x86/0xa0
           </IRQ>
           <TASK>
           asm_common_interrupt+0x26/0x40
          RIP: 0010:apparmor_socket_post_create+0xb/0x200
          Code: 08 48 85 ff 75 a1 eb b1 0f 1f 80 00 00 00 00 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 f3 0f 1e fa 0f 1f 44 00 00 41 54 <55> 48 89 fd 53 45 85 c0 0f 84 b2 00 00 00 48 8b 1d 80 56 3f 02 48
          RSP: 0018:ffffa92940ce7e50 EFLAGS: 00000286
          RAX: ffffffffbc756440 RBX: 0000000000000000 RCX: 0000000000000001
          RDX: 0000000000000003 RSI: 0000000000000002 RDI: ffff8b574eaab740
          RBP: 0000000000000001 R08: 0000000000000000 R09: 0000000000000000
          R10: ffff8b57444cec70 R11: 0000000000000000 R12: 0000000000000003
          R13: 0000000000000002 R14: ffff8b574eaab740 R15: ffffffffbd8e4748
           ? __pfx_apparmor_socket_post_create+0x10/0x10
           security_socket_post_create+0x4b/0x80
           __sock_create+0x176/0x1f0
           __sys_socket+0x89/0x100
           __x64_sys_socket+0x17/0x20
           do_syscall_64+0x5d/0x90
           ? do_syscall_64+0x6c/0x90
           ? do_syscall_64+0x6c/0x90
           ? do_syscall_64+0x6c/0x90
           entry_SYSCALL_64_after_hwframe+0x72/0xdc
      
      Fixes: ab9f2115
      
       ("apparmor: Allow filtering based on secmark policy")
      Signed-off-by: default avatarXiao Liang <shaw.leon@gmail.com>
      Signed-off-by: default avatarJohn Johansen <john.johansen@canonical.com>
      fce09ea3
  19. May 09, 2024