Skip to content
Snippets Groups Projects
  1. Nov 14, 2023
    • Paul Moore's avatar
      audit: don't WARN_ON_ONCE(!current->mm) in audit_exe_compare() · 969d90ec
      Paul Moore authored
      
      eBPF can end up calling into the audit code from some odd places, and
      some of these places don't have @current set properly so we end up
      tripping the `WARN_ON_ONCE(!current->mm)` near the top of
      `audit_exe_compare()`.  While the basic `!current->mm` check is good,
      the `WARN_ON_ONCE()` results in some scary console messages so let's
      drop that and just do the regular `!current->mm` check to avoid
      problems.
      
      Cc: <stable@vger.kernel.org>
      Fixes: 47846d51 ("audit: don't take task_lock() in audit_exe_compare() code path")
      Reported-by: default avatarArtem Savkov <asavkov@redhat.com>
      Signed-off-by: default avatarPaul Moore <paul@paul-moore.com>
      969d90ec
  2. Oct 26, 2023
    • Paul Moore's avatar
      audit: don't take task_lock() in audit_exe_compare() code path · 47846d51
      Paul Moore authored
      
      The get_task_exe_file() function locks the given task with task_lock()
      which when used inside audit_exe_compare() can cause deadlocks on
      systems that generate audit records when the task_lock() is held. We
      resolve this problem with two changes: ignoring those cases where the
      task being audited is not the current task, and changing our approach
      to obtaining the executable file struct to not require task_lock().
      
      With the intent of the audit exe filter being to filter on audit events
      generated by processes started by the specified executable, it makes
      sense that we would only want to use the exe filter on audit records
      associated with the currently executing process, e.g. @current.  If
      we are asked to filter records using a non-@current task_struct we can
      safely ignore the exe filter without negatively impacting the admin's
      expectations for the exe filter.
      
      Knowing that we only have to worry about filtering the currently
      executing task in audit_exe_compare() we can do away with the
      task_lock() and call get_mm_exe_file() with @current->mm directly.
      
      Cc: <stable@vger.kernel.org>
      Fixes: 5efc2443 ("audit: fix exe_file access in audit_exe_compare")
      Reported-by: default avatarAndreas Steinmetz <anstein99@googlemail.com>
      Reviewed-by: default avatarJohn Johansen <john.johanse@canonical.com>
      Reviewed-by: default avatarMateusz Guzik <mjguzik@gmail.com>
      Signed-off-by: default avatarPaul Moore <paul@paul-moore.com>
      47846d51
  3. Sep 01, 2022
  4. Apr 25, 2022
  5. Oct 27, 2021
  6. Sep 20, 2021
    • Paul Moore's avatar
      audit: add filtering for io_uring records · 67daf270
      Paul Moore authored
      
      This patch adds basic audit io_uring filtering, using as much of the
      existing audit filtering infrastructure as possible.  In order to do
      this we reuse the audit filter rule's syscall mask for the io_uring
      operation and we create a new filter for io_uring operations as
      AUDIT_FILTER_URING_EXIT/audit_filter_list[7].
      
      Thanks to Richard Guy Briggs for his review, feedback, and work on
      the corresponding audit userspace changes.
      
      Acked-by: default avatarRichard Guy Briggs <rgb@redhat.com>
      Signed-off-by: default avatarPaul Moore <paul@paul-moore.com>
      67daf270
  7. Dec 03, 2020
    • Amir Goldstein's avatar
      fsnotify: generalize handle_inode_event() · 950cc0d2
      Amir Goldstein authored and Jan Kara's avatar Jan Kara committed
      The handle_inode_event() interface was added as (quoting comment):
      "a simple variant of handle_event() for groups that only have inode
      marks and don't have ignore mask".
      
      In other words, all backends except fanotify.  The inotify backend
      also falls under this category, but because it required extra arguments
      it was left out of the initial pass of backends conversion to the
      simple interface.
      
      This results in code duplication between the generic helper
      fsnotify_handle_event() and the inotify_handle_event() callback
      which also happen to be buggy code.
      
      Generalize the handle_inode_event() arguments and add the check for
      FS_EXCL_UNLINK flag to the generic helper, so inotify backend could
      be converted to use the simple interface.
      
      Link: https://lore.kernel.org/r/20201202120713.702387-2-amir73il@gmail.com
      
      
      CC: stable@vger.kernel.org
      Fixes: b9a1b977 ("fsnotify: create method handle_inode_event() in fsnotify_operations")
      Signed-off-by: default avatarAmir Goldstein <amir73il@gmail.com>
      Signed-off-by: default avatarJan Kara <jack@suse.cz>
      950cc0d2
  8. Jul 27, 2020
    • Amir Goldstein's avatar
      fsnotify: create method handle_inode_event() in fsnotify_operations · b9a1b977
      Amir Goldstein authored and Jan Kara's avatar Jan Kara committed
      The method handle_event() grew a lot of complexity due to the design of
      fanotify and merging of ignore masks.
      
      Most backends do not care about this complex functionality, so we can hide
      this complexity from them.
      
      Introduce a method handle_inode_event() that serves those backends and
      passes a single inode mark and less arguments.
      
      This change converts all backends except fanotify and inotify to use the
      simplified handle_inode_event() method.  In pricipal, inotify could have
      also used the new method, but that would require passing more arguments
      on the simple helper (data, data_type, cookie), so we leave it with the
      handle_event() method.
      
      Link: https://lore.kernel.org/r/20200722125849.17418-9-amir73il@gmail.com
      
      
      Suggested-by: default avatarJan Kara <jack@suse.cz>
      Signed-off-by: default avatarAmir Goldstein <amir73il@gmail.com>
      Signed-off-by: default avatarJan Kara <jack@suse.cz>
      b9a1b977
    • Amir Goldstein's avatar
      audit: do not set FS_EVENT_ON_CHILD in audit marks mask · 7dbe6080
      Amir Goldstein authored and Jan Kara's avatar Jan Kara committed
      The audit group marks mask does not contain any events possible on
      a child so setting the flag FS_EVENT_ON_CHILD in the mask is counter
      productive.
      
      It may lead to the undesired outcome of setting the dentry flag
      DCACHE_FSNOTIFY_PARENT_WATCHED on a directory inode even though it is
      not watching children, because the audit mark contribute the flag
      FS_EVENT_ON_CHILD to the inode's fsnotify_mask and another mark could
      be contributing an event that is possible on child to the inode's mask.
      
      Furthermore in the following patches we want to use FS_EVENT_ON_CHILD
      for non-dir inodes for other purposes so stop using the flag.
      
      Link: https://lore.kernel.org/r/20200722125849.17418-4-amir73il@gmail.com
      
      
      Signed-off-by: default avatarAmir Goldstein <amir73il@gmail.com>
      Signed-off-by: default avatarJan Kara <jack@suse.cz>
      7dbe6080
    • Amir Goldstein's avatar
      fsnotify: pass dir argument to handle_event() callback · b54cecf5
      Amir Goldstein authored and Jan Kara's avatar Jan Kara committed
      
      The 'inode' argument to handle_event(), sometimes referred to as
      'to_tell' is somewhat obsolete.
      It is a remnant from the times when a group could only have an inode mark
      associated with an event.
      
      We now pass an iter_info array to the callback, with all marks associated
      with an event.
      
      Most backends ignore this argument, with two exceptions:
      1. dnotify uses it for sanity check that event is on directory
      2. fanotify uses it to report fid of directory on directory entry
         modification events
      
      Remove the 'inode' argument and add a 'dir' argument.
      The callback function signature is deliberately changed, because
      the meaning of the argument has changed and the arguments have
      been documented.
      
      The 'dir' argument is set to when 'file_name' is specified and it is
      referring to the directory that the 'file_name' entry belongs to.
      
      Signed-off-by: default avatarAmir Goldstein <amir73il@gmail.com>
      Signed-off-by: default avatarJan Kara <jack@suse.cz>
      b54cecf5
  9. Mar 23, 2020
  10. Feb 10, 2020
    • Steve Grubb's avatar
      audit: CONFIG_CHANGE don't log internal bookkeeping as an event · 70b3eeed
      Steve Grubb authored
      
      Common Criteria calls out for any action that modifies the audit trail to
      be recorded. That usually is interpreted to mean insertion or removal of
      rules. It is not required to log modification of the inode information
      since the watch is still in effect. Additionally, if the rule is a never
      rule and the underlying file is one they do not want events for, they
      get an event for this bookkeeping update against their wishes.
      
      Since no device/inode info is logged at insertion and no device/inode
      information is logged on update, there is nothing meaningful being
      communicated to the admin by the CONFIG_CHANGE updated_rules event. One
      can assume that the rule was not "modified" because it is still watching
      the intended target. If the device or inode cannot be resolved, then
      audit_panic is called which is sufficient.
      
      The correct resolution is to drop logging config_update events since
      the watch is still in effect but just on another unknown inode.
      
      Signed-off-by: default avatarSteve Grubb <sgrubb@redhat.com>
      Signed-off-by: default avatarPaul Moore <paul@paul-moore.com>
      70b3eeed
  11. Nov 10, 2019
  12. May 30, 2019
  13. Apr 29, 2019
  14. Apr 26, 2019
  15. Jan 18, 2019
  16. Nov 26, 2018
  17. Nov 19, 2018
  18. Jul 18, 2018
    • Ronny Chevalier's avatar
      audit: fix use-after-free in audit_add_watch · baa2a4fd
      Ronny Chevalier authored
      
      audit_add_watch stores locally krule->watch without taking a reference
      on watch. Then, it calls audit_add_to_parent, and uses the watch stored
      locally.
      
      Unfortunately, it is possible that audit_add_to_parent updates
      krule->watch.
      When it happens, it also drops a reference of watch which
      could free the watch.
      
      How to reproduce (with KASAN enabled):
      
          auditctl -w /etc/passwd -F success=0 -k test_passwd
          auditctl -w /etc/passwd -F success=1 -k test_passwd2
      
      The second call to auditctl triggers the use-after-free, because
      audit_to_parent updates krule->watch to use a previous existing watch
      and drops the reference to the newly created watch.
      
      To fix the issue, we grab a reference of watch and we release it at the
      end of the function.
      
      Signed-off-by: default avatarRonny Chevalier <ronny.chevalier@hp.com>
      Reviewed-by: default avatarRichard Guy Briggs <rgb@redhat.com>
      Signed-off-by: default avatarPaul Moore <paul@paul-moore.com>
      baa2a4fd
  19. Jun 28, 2018
  20. May 18, 2018
  21. May 14, 2018
  22. Aug 15, 2017
    • Jan Kara's avatar
      audit: Receive unmount event · b5fed474
      Jan Kara authored
      
      Although audit_watch_handle_event() can handle FS_UNMOUNT event, it is
      not part of AUDIT_FS_WATCH mask and thus such event never gets to
      audit_watch_handle_event(). Thus fsnotify marks are deleted by fsnotify
      subsystem on unmount without audit being notified about that which leads
      to a strange state of existing audit rules with dead fsnotify marks.
      
      Add FS_UNMOUNT to the mask of events to be received so that audit can
      clean up its state accordingly.
      
      Signed-off-by: default avatarJan Kara <jack@suse.cz>
      Signed-off-by: default avatarPaul Moore <paul@paul-moore.com>
      b5fed474
    • Jan Kara's avatar
      audit: Fix use after free in audit_remove_watch_rule() · d76036ab
      Jan Kara authored
      
      audit_remove_watch_rule() drops watch's reference to parent but then
      continues to work with it. That is not safe as parent can get freed once
      we drop our reference. The following is a trivial reproducer:
      
      mount -o loop image /mnt
      touch /mnt/file
      auditctl -w /mnt/file -p wax
      umount /mnt
      auditctl -D
      <crash in fsnotify_destroy_mark()>
      
      Grab our own reference in audit_remove_watch_rule() earlier to make sure
      mark does not get freed under us.
      
      CC: stable@vger.kernel.org
      Reported-by: default avatarTony Jones <tonyj@suse.de>
      Signed-off-by: default avatarJan Kara <jack@suse.cz>
      Tested-by: default avatarTony Jones <tonyj@suse.de>
      Signed-off-by: default avatarPaul Moore <paul@paul-moore.com>
      d76036ab
  23. May 02, 2017
  24. Apr 10, 2017
  25. Dec 05, 2016
  26. Dec 04, 2016
  27. Nov 20, 2016
  28. Aug 31, 2016
  29. Apr 10, 2016
  30. Feb 08, 2016
  31. Jan 22, 2016
    • Al Viro's avatar
      wrappers for ->i_mutex access · 5955102c
      Al Viro authored
      
      parallel to mutex_{lock,unlock,trylock,is_locked,lock_nested},
      inode_foo(inode) being mutex_foo(&inode->i_mutex).
      
      Please, use those for access to ->i_mutex; over the coming cycle
      ->i_mutex will become rwsem, with ->lookup() done with it held
      only shared.
      
      Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
      5955102c
Loading