Skip to content
Snippets Groups Projects
  1. May 25, 2023
  2. Mar 18, 2023
  3. Mar 17, 2023
  4. Oct 28, 2022
  5. Aug 16, 2022
  6. May 03, 2022
    • Christian Göttsche's avatar
      selinux: log anon inode class name · c29722fa
      Christian Göttsche authored
      
      Log the anonymous inode class name in the security hook
      inode_init_security_anon.  This name is the key for name based type
      transitions on the anon_inode security class on creation.  Example:
      
          type=AVC msg=audit(02/16/22 22:02:50.585:216) : avc:  granted \
              { create } for  pid=2136 comm=mariadbd anonclass=[io_uring] \
              scontext=system_u:system_r:mysqld_t:s0 \
              tcontext=system_u:system_r:mysqld_iouring_t:s0 tclass=anon_inode
      
      Add a new LSM audit data type holding the inode and the class name.
      
      Signed-off-by: default avatarChristian Göttsche <cgzones@googlemail.com>
      [PM: adjusted 'anonclass' to be a trusted string, cgzones approved]
      Signed-off-by: default avatarPaul Moore <paul@paul-moore.com>
      c29722fa
  7. Sep 20, 2021
    • Ondrej Mosnacek's avatar
      lsm_audit: avoid overloading the "key" audit field · 8e71168e
      Ondrej Mosnacek authored
      
      The "key" field is used to associate records with the rule that
      triggered them, os it's not a good idea to overload it with an
      additional IPC key semantic. Moreover, as the classic "key" field is a
      text field, while the IPC key is numeric, AVC records containing the IPC
      key info actually confuse audit userspace, which tries to interpret the
      number as a hex-encoded string, thus showing garbage for example in the
      ausearch "interpret" output mode.
      
      Hence, change it to "ipc_key" to fix both issues and also make the
      meaning of this field more clear.
      
      Signed-off-by: default avatarOndrej Mosnacek <omosnace@redhat.com>
      Reviewed-by: default avatarRichard Guy Briggs <rgb@redhat.com>
      Signed-off-by: default avatarPaul Moore <paul@paul-moore.com>
      8e71168e
  8. Jun 11, 2021
  9. Jan 16, 2021
  10. Dec 03, 2020
  11. Oct 28, 2020
    • Richard Guy Briggs's avatar
      audit: trigger accompanying records when no rules present · 6d915476
      Richard Guy Briggs authored
      When there are no audit rules registered, mandatory records (config,
      etc.) are missing their accompanying records (syscall, proctitle, etc.).
      
      This is due to audit context dummy set on syscall entry based on absence
      of rules that signals that no other records are to be printed.  Clear the dummy
      bit if any record is generated, open coding this in audit_log_start().
      
      The proctitle context and dummy checks are pointless since the
      proctitle record will not be printed if no syscall records are printed.
      
      The fds array is reset to -1 after the first syscall to indicate it
      isn't valid any more, but was never set to -1 when the context was
      allocated to indicate it wasn't yet valid.
      
      Check ctx->pwd in audit_log_name().
      
      The audit_inode* functions can be called without going through
      getname_flags() or getname_kernel() that sets audit_names and cwd, so
      set the cwd in audit_alloc_name() if it has not already been done so due to
      audit_names being valid and purge all other audit_getcwd() calls.
      
      Revert the LSM dump_common_audit_data() LSM_AUDIT_DATA_* cases from the
      ghak96 patch since they are no longer necessary due to cwd coverage in
      audit_alloc_name().
      
      Thanks to bauen1 <j2468h@googlemail.com> for reporting LSM situations in
      which context->cwd is not valid, inadvertantly fixed by the ghak96 patch.
      
      Please see upstream github issue
      https://github.com/linux-audit/audit-kernel/issues/120
      This is also related to upstream github issue
      https://github.com/linux-audit/audit-kernel/issues/96
      
      
      
      Signed-off-by: default avatarRichard Guy Briggs <rgb@redhat.com>
      Signed-off-by: default avatarPaul Moore <paul@paul-moore.com>
      6d915476
  12. Jul 21, 2020
  13. Jul 08, 2020
  14. Dec 09, 2019
    • Stephen Smalley's avatar
      security,lockdown,selinux: implement SELinux lockdown · 59438b46
      Stephen Smalley authored
      
      Implement a SELinux hook for lockdown.  If the lockdown module is also
      enabled, then a denial by the lockdown module will take precedence over
      SELinux, so SELinux can only further restrict lockdown decisions.
      The SELinux hook only distinguishes at the granularity of integrity
      versus confidentiality similar to the lockdown module, but includes the
      full lockdown reason as part of the audit record as a hint in diagnosing
      what triggered the denial.  To support this auditing, move the
      lockdown_reasons[] string array from being private to the lockdown
      module to the security framework so that it can be used by the lsm audit
      code and so that it is always available even when the lockdown module
      is disabled.
      
      Note that the SELinux implementation allows the integrity and
      confidentiality reasons to be controlled independently from one another.
      Thus, in an SELinux policy, one could allow operations that specify
      an integrity reason while blocking operations that specify a
      confidentiality reason. The SELinux hook implementation is
      stricter than the lockdown module in validating the provided reason value.
      
      Sample AVC audit output from denials:
      avc:  denied  { integrity } for pid=3402 comm="fwupd"
       lockdown_reason="/dev/mem,kmem,port" scontext=system_u:system_r:fwupd_t:s0
       tcontext=system_u:system_r:fwupd_t:s0 tclass=lockdown permissive=0
      
      avc:  denied  { confidentiality } for pid=4628 comm="cp"
       lockdown_reason="/proc/kcore access"
       scontext=unconfined_u:unconfined_r:test_lockdown_integrity_t:s0-s0:c0.c1023
       tcontext=unconfined_u:unconfined_r:test_lockdown_integrity_t:s0-s0:c0.c1023
       tclass=lockdown permissive=0
      
      Signed-off-by: default avatarStephen Smalley <sds@tycho.nsa.gov>
      Reviewed-by: default avatarJames Morris <jamorris@linux.microsoft.com>
      [PM: some merge fuzz do the the perf hooks]
      Signed-off-by: default avatarPaul Moore <paul@paul-moore.com>
      59438b46
  15. Jun 19, 2019
  16. Feb 21, 2019
    • Al Viro's avatar
      missing barriers in some of unix_sock ->addr and ->path accesses · ae3b5641
      Al Viro authored
      
      Several u->addr and u->path users are not holding any locks in
      common with unix_bind().  unix_state_lock() is useless for those
      purposes.
      
      u->addr is assign-once and *(u->addr) is fully set up by the time
      we set u->addr (all under unix_table_lock).  u->path is also
      set in the same critical area, also before setting u->addr, and
      any unix_sock with ->path filled will have non-NULL ->addr.
      
      So setting ->addr with smp_store_release() is all we need for those
      "lockless" users - just have them fetch ->addr with smp_load_acquire()
      and don't even bother looking at ->path if they see NULL ->addr.
      
      Users of ->addr and ->path fall into several classes now:
          1) ones that do smp_load_acquire(u->addr) and access *(u->addr)
      and u->path only if smp_load_acquire() has returned non-NULL.
          2) places holding unix_table_lock.  These are guaranteed that
      *(u->addr) is seen fully initialized.  If unix_sock is in one of the
      "bound" chains, so's ->path.
          3) unix_sock_destructor() using ->addr is safe.  All places
      that set u->addr are guaranteed to have seen all stores *(u->addr)
      while holding a reference to u and unix_sock_destructor() is called
      when (atomic) refcount hits zero.
          4) unix_release_sock() using ->path is safe.  unix_bind()
      is serialized wrt unix_release() (normally - by struct file
      refcount), and for the instances that had ->path set by unix_bind()
      unix_release_sock() comes from unix_release(), so they are fine.
      Instances that had it set in unix_stream_connect() either end up
      attached to a socket (in unix_accept()), in which case the call
      chain to unix_release_sock() and serialization are the same as in
      the previous case, or they never get accept'ed and unix_release_sock()
      is called when the listener is shut down and its queue gets purged.
      In that case the listener's queue lock provides the barriers needed -
      unix_stream_connect() shoves our unix_sock into listener's queue
      under that lock right after having set ->path and eventual
      unix_release_sock() caller picks them from that queue under the
      same lock right before calling unix_release_sock().
          5) unix_find_other() use of ->path is pointless, but safe -
      it happens with successful lookup by (abstract) name, so ->path.dentry
      is guaranteed to be NULL there.
      
      earlier-variant-reviewed-by: default avatar"Paul E. McKenney" <paulmck@linux.ibm.com>
      Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      ae3b5641
  17. May 14, 2018
  18. Aug 17, 2017
  19. May 23, 2017
  20. Sep 19, 2016
    • Vivek Goyal's avatar
      lsm,audit,selinux: Introduce a new audit data type LSM_AUDIT_DATA_FILE · 43af5de7
      Vivek Goyal authored
      
      Right now LSM_AUDIT_DATA_PATH type contains "struct path" in union "u"
      of common_audit_data. This information is used to print path of file
      at the same time it is also used to get to dentry and inode. And this
      inode information is used to get to superblock and device and print
      device information.
      
      This does not work well for layered filesystems like overlay where dentry
      contained in path is overlay dentry and not the real dentry of underlying
      file system. That means inode retrieved from dentry is also overlay
      inode and not the real inode.
      
      SELinux helpers like file_path_has_perm() are doing checks on inode
      retrieved from file_inode(). This returns the real inode and not the
      overlay inode. That means we are doing check on real inode but for audit
      purposes we are printing details of overlay inode and that can be
      confusing while debugging.
      
      Hence, introduce a new type LSM_AUDIT_DATA_FILE which carries file
      information and inode retrieved is real inode using file_inode(). That
      way right avc denied information is given to user.
      
      For example, following is one example avc before the patch.
      
        type=AVC msg=audit(1473360868.399:214): avc:  denied  { read open } for
          pid=1765 comm="cat"
          path="/root/.../overlay/container1/merged/readfile"
          dev="overlay" ino=21443
          scontext=unconfined_u:unconfined_r:test_overlay_client_t:s0:c10,c20
          tcontext=unconfined_u:object_r:test_overlay_files_ro_t:s0
          tclass=file permissive=0
      
      It looks as follows after the patch.
      
        type=AVC msg=audit(1473360017.388:282): avc:  denied  { read open } for
          pid=2530 comm="cat"
          path="/root/.../overlay/container1/merged/readfile"
          dev="dm-0" ino=2377915
          scontext=unconfined_u:unconfined_r:test_overlay_client_t:s0:c10,c20
          tcontext=unconfined_u:object_r:test_overlay_files_ro_t:s0
          tclass=file permissive=0
      
      Notice that now dev information points to "dm-0" device instead of
      "overlay" device. This makes it clear that check failed on underlying
      inode and not on the overlay inode.
      
      Signed-off-by: default avatarVivek Goyal <vgoyal@redhat.com>
      [PM: slight tweaks to the description to make checkpatch.pl happy]
      Signed-off-by: default avatarPaul Moore <paul@paul-moore.com>
      43af5de7
  21. Aug 30, 2016
  22. Aug 08, 2016
  23. Jul 13, 2015
  24. May 29, 2015
  25. Apr 15, 2015
    • David Howells's avatar
      VFS: security/: d_backing_inode() annotations · c6f493d6
      David Howells authored and Al Viro's avatar Al Viro committed
      
      most of the ->d_inode uses there refer to the same inode IO would
      go to, i.e. d_backing_inode()
      
      Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
      Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
      c6f493d6
    • Richard Guy Briggs's avatar
      lsm: copy comm before calling audit_log to avoid race in string printing · 5deeb5ce
      Richard Guy Briggs authored
      
      When task->comm is passed directly to audit_log_untrustedstring() without
      getting a copy or using the task_lock, there is a race that could happen that
      would output a NULL (\0) in the middle of the output string that would
      effectively truncate the rest of the report text after the comm= field in the
      audit log message, losing fields.
      
      Using get_task_comm() to get a copy while acquiring the task_lock to prevent
      this and to prevent the result from being a mixture of old and new values of
      comm would incur potentially unacceptable overhead, considering that the value
      can be influenced by userspace and therefore untrusted anyways.
      
      Copy the value before passing it to audit_log_untrustedstring() ensures that a
      local copy is used to calculate the length *and* subsequently printed.  Even if
      this value contains a mix of old and new values, it will only calculate and
      copy up to the first NULL, preventing the rest of the audit log message being
      truncated.
      
      Use a second local copy of comm to avoid a race between the first and second
      calls to audit_log_untrustedstring() with comm.
      
      Reported-by: default avatarTetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
      Signed-off-by: default avatarRichard Guy Briggs <rgb@redhat.com>
      Signed-off-by: default avatarJames Morris <james.l.morris@oracle.com>
      5deeb5ce
  26. Mar 20, 2014
  27. Nov 05, 2013
  28. Oct 09, 2013
    • Eric Dumazet's avatar
      net: fix build errors if ipv6 is disabled · c2bb06db
      Eric Dumazet authored
      
      CONFIG_IPV6=n is still a valid choice ;)
      
      It appears we can remove dead code.
      
      Reported-by: default avatarWu Fengguang <fengguang.wu@intel.com>
      Signed-off-by: default avatarEric Dumazet <edumazet@google.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      c2bb06db
    • Eric Dumazet's avatar
      ipv6: make lookups simpler and faster · efe4208f
      Eric Dumazet authored
      
      TCP listener refactoring, part 4 :
      
      To speed up inet lookups, we moved IPv4 addresses from inet to struct
      sock_common
      
      Now is time to do the same for IPv6, because it permits us to have fast
      lookups for all kind of sockets, including upcoming SYN_RECV.
      
      Getting IPv6 addresses in TCP lookups currently requires two extra cache
      lines, plus a dereference (and memory stall).
      
      inet6_sk(sk) does the dereference of inet_sk(__sk)->pinet6
      
      This patch is way bigger than its IPv4 counter part, because for IPv4,
      we could add aliases (inet_daddr, inet_rcv_saddr), while on IPv6,
      it's not doable easily.
      
      inet6_sk(sk)->daddr becomes sk->sk_v6_daddr
      inet6_sk(sk)->rcv_saddr becomes sk->sk_v6_rcv_saddr
      
      And timewait socket also have tw->tw_v6_daddr & tw->tw_v6_rcv_saddr
      at the same offset.
      
      We get rid of INET6_TW_MATCH() as INET6_MATCH() is now the generic
      macro.
      
      Signed-off-by: default avatarEric Dumazet <edumazet@google.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      efe4208f
  29. Apr 09, 2012
  30. Apr 03, 2012
  31. Mar 21, 2012
  32. Jan 17, 2012
Loading