24 Aug, 2020

1 commit

  • Replace the existing /* fall through */ comments and its variants with
    the new pseudo-keyword macro fallthrough[1]. Also, remove unnecessary
    fall-through markings when it is the case.

    [1] https://www.kernel.org/doc/html/v5.7/process/deprecated.html?highlight=fallthrough#implicit-switch-case-fall-through

    Signed-off-by: Gustavo A. R. Silva

    Gustavo A. R. Silva
     

23 Apr, 2020

1 commit

  • If audit_list_rules_send() fails when trying to create a new thread
    to send the rules it also fails to cleanup properly, leaking a
    reference to a net structure. This patch fixes the error patch and
    renames audit_send_list() to audit_send_list_thread() to better
    match its cousin, audit_send_reply_thread().

    Reported-by: teroincn@gmail.com
    Reviewed-by: Richard Guy Briggs
    Signed-off-by: Paul Moore

    Paul Moore
     

23 Feb, 2020

1 commit

  • Commit 219ca39427bf ("audit: use union for audit_field values since
    they are mutually exclusive") combined a number of separate fields in
    the audit_field struct into a single union. Generally this worked
    just fine because they are generally mutually exclusive.
    Unfortunately in audit_data_to_entry() the overlap can be a problem
    when a specific error case is triggered that causes the error path
    code to attempt to cleanup an audit_field struct and the cleanup
    involves attempting to free a stored LSM string (the lsm_str field).
    Currently the code always has a non-NULL value in the
    audit_field.lsm_str field as the top of the for-loop transfers a
    value into audit_field.val (both .lsm_str and .val are part of the
    same union); if audit_data_to_entry() fails and the audit_field
    struct is specified to contain a LSM string, but the
    audit_field.lsm_str has not yet been properly set, the error handling
    code will attempt to free the bogus audit_field.lsm_str value that
    was set with audit_field.val at the top of the for-loop.

    This patch corrects this by ensuring that the audit_field.val is only
    set when needed (it is cleared when the audit_field struct is
    allocated with kcalloc()). It also corrects a few other issues to
    ensure that in case of error the proper error code is returned.

    Cc: stable@vger.kernel.org
    Fixes: 219ca39427bf ("audit: use union for audit_field values since they are mutually exclusive")
    Reported-by: syzbot+1f4d90ead370d72e450b@syzkaller.appspotmail.com
    Signed-off-by: Paul Moore

    Paul Moore
     

09 Jul, 2019

1 commit

  • Pull audit updates from Paul Moore:
    "This pull request is a bit early, but with some vacation time coming
    up I wanted to send this out now just in case the remote Internet Gods
    decide not to smile on me once the merge window opens. The patchset
    for v5.3 is pretty minor this time, the highlights include:

    - When the audit daemon is sent a signal, ensure we deliver
    information about the sender even when syscall auditing is not
    enabled/supported.

    - Add the ability to filter audit records based on network address
    family.

    - Tighten the audit field filtering restrictions on string based
    fields.

    - Cleanup the audit field filtering verification code.

    - Remove a few BUG() calls from the audit code"

    * tag 'audit-pr-20190702' of git://git.kernel.org/pub/scm/linux/kernel/git/pcmoore/audit:
    audit: remove the BUG() calls in the audit rule comparison functions
    audit: enforce op for string fields
    audit: add saddr_fam filter field
    audit: re-structure audit field valid checks
    audit: deliver signal_info regarless of syscall

    Linus Torvalds
     

31 May, 2019

2 commits

  • Based on 1 normalized pattern(s):

    this program is free software you can redistribute it and or modify
    it under the terms of the gnu general public license as published by
    the free software foundation either version 2 of the license or at
    your option any later version this program is distributed in the
    hope that it will be useful but without any warranty without even
    the implied warranty of merchantability or fitness for a particular
    purpose see the gnu general public license for more details you
    should have received a copy of the gnu general public license along
    with this program if not write to the free software foundation inc
    59 temple place suite 330 boston ma 02111 1307 usa

    extracted by the scancode license scanner the SPDX license identifier

    GPL-2.0-or-later

    has been chosen to replace the boilerplate/reference in 1334 file(s).

    Signed-off-by: Thomas Gleixner
    Reviewed-by: Allison Randal
    Reviewed-by: Richard Fontana
    Cc: linux-spdx@vger.kernel.org
    Link: https://lkml.kernel.org/r/20190527070033.113240726@linutronix.de
    Signed-off-by: Greg Kroah-Hartman

    Thomas Gleixner
     
  • The audit_data_to_entry() function ensures that the operator is valid
    so we can get rid of these BUG() calls. We keep the "return 0" just
    so the system behaves in a sane-ish manner should something go
    horribly wrong.

    Signed-off-by: Paul Moore
    Acked-by: Richard Guy Briggs

    Paul Moore
     

24 May, 2019

2 commits

  • Provide a method to filter out sockaddr and bind calls by network
    address family.

    Existing SOCKADDR records are listed for any network activity.
    Implement the AUDIT_SADDR_FAM field selector to be able to classify or
    limit records to specific network address families, such as AF_INET or
    AF_INET6.

    An example of a network record that is unlikely to be useful and flood
    the logs:

    type=SOCKADDR msg=audit(07/27/2017 12:18:27.019:845) : saddr={ fam=local
    path=/var/run/nscd/socket }
    type=SYSCALL msg=audit(07/27/2017 12:18:27.019:845) : arch=x86_64
    syscall=connect success=no exit=ENOENT(No such file or directory) a0=0x3
    a1=0x7fff229c4980 a2=0x6e a3=0x6 items=1 ppid=3301 pid=6145 auid=sgrubb
    uid=sgrubb gid=sgrubb euid=sgrubb suid=sgrubb fsuid=sgrubb egid=sgrubb
    sgid=sgrubb fsgid=sgrubb tty=pts3 ses=4 comm=bash exe=/usr/bin/bash
    subj=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023
    key=network-test

    Please see the audit-testsuite PR at
    https://github.com/linux-audit/audit-testsuite/pull/87
    Please see the github issue
    https://github.com/linux-audit/audit-kernel/issues/64
    Please see the github issue for the accompanying userspace support
    https://github.com/linux-audit/audit-userspace/issues/93

    Signed-off-by: Richard Guy Briggs
    [PM: merge fuzz in auditfilter.c]
    Signed-off-by: Paul Moore

    Richard Guy Briggs
     
  • Multiple checks were being done in one switch case statement that
    started to cause some redundancies and awkward exceptions. Separate the
    valid field and op check from the select valid values checks.

    Enforce the elimination of meaningless bitwise and greater/lessthan
    checks on string fields and other fields with unrelated scalar values.

    Please see the github issue
    https://github.com/linux-audit/audit-kernel/issues/73

    Signed-off-by: Richard Guy Briggs
    Signed-off-by: Paul Moore

    Richard Guy Briggs
     

08 May, 2019

1 commit

  • Pull misc dcache updates from Al Viro:
    "Most of this pile is putting name length into struct name_snapshot and
    making use of it.

    The beginning of this series ("ovl_lookup_real_one(): don't bother
    with strlen()") ought to have been split in two (separate switch of
    name_snapshot to struct qstr from overlayfs reaping the trivial
    benefits of that), but I wanted to avoid a rebase - by the time I'd
    spotted that it was (a) in -next and (b) close to 5.1-final ;-/"

    * 'work.dcache' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs:
    audit_compare_dname_path(): switch to const struct qstr *
    audit_update_watch(): switch to const struct qstr *
    inotify_handle_event(): don't bother with strlen()
    fsnotify: switch send_to_group() and ->handle_event to const struct qstr *
    fsnotify(): switch to passing const struct qstr * for file_name
    switch fsnotify_move() to passing const struct qstr * for old_name
    ovl_lookup_real_one(): don't bother with strlen()
    sysv: bury the broken "quietly truncate the long filenames" logics
    nsfs: unobfuscate
    unexport d_alloc_pseudo()

    Linus Torvalds
     

29 Apr, 2019

1 commit


22 Apr, 2019

1 commit

  • In audit_rule_change(), audit_data_to_entry() is firstly invoked to
    translate the payload data to the kernel's rule representation. In
    audit_data_to_entry(), depending on the audit field type, an audit tree may
    be created in audit_make_tree(), which eventually invokes kmalloc() to
    allocate the tree. Since this tree is a temporary tree, it will be then
    freed in the following execution, e.g., audit_add_rule() if the message
    type is AUDIT_ADD_RULE or audit_del_rule() if the message type is
    AUDIT_DEL_RULE. However, if the message type is neither AUDIT_ADD_RULE nor
    AUDIT_DEL_RULE, i.e., the default case of the switch statement, this
    temporary tree is not freed.

    To fix this issue, only allocate the tree when the type is AUDIT_ADD_RULE
    or AUDIT_DEL_RULE.

    Signed-off-by: Wenwen Wang
    Reviewed-by: Richard Guy Briggs
    Signed-off-by: Paul Moore

    Wenwen Wang
     

09 Apr, 2019

1 commit

  • The original conditions that led to the use of list_empty() to optimize
    list_for_each_entry_rcu() in auditfilter.c and auditsc.c code have been
    removed without removing the list_empty() call, but this code example
    has been copied several times. Remove the unnecessary list_empty()
    calls.

    Please see upstream github issue
    https://github.com/linux-audit/audit-kernel/issues/112

    Signed-off-by: Richard Guy Briggs
    Signed-off-by: Paul Moore

    Richard Guy Briggs
     

13 Feb, 2019

1 commit

  • In preparation to enabling -Wimplicit-fallthrough, mark switch
    cases where we are expecting to fall through.

    This patch fixes the following warning:

    kernel/auditfilter.c: In function ‘audit_krule_to_data’:
    kernel/auditfilter.c:668:7: warning: this statement may fall through [-Wimplicit-fallthrough=]
    if (krule->pflags & AUDIT_LOGINUID_LEGACY && !f->val) {
    ^
    kernel/auditfilter.c:674:3: note: here
    default:
    ^~~~~~~

    Warning level 3 was used: -Wimplicit-fallthrough=3

    Notice that, in this particular case, the code comment is modified
    in accordance with what GCC is expecting to find.

    This patch is part of the ongoing efforts to enable
    -Wimplicit-fallthrough.

    Signed-off-by: Gustavo A. R. Silva
    Signed-off-by: Paul Moore

    Gustavo A. R. Silva
     

01 Feb, 2019

1 commit

  • The audit_rule_match() struct audit_context *actx parameter is not used
    by any in-tree consumers (selinux, apparmour, integrity, smack).

    The audit context is an internal audit structure that should only be
    accessed by audit accessor functions.

    It was part of commit 03d37d25e0f9 ("LSM/Audit: Introduce generic
    Audit LSM hooks") but appears to have never been used.

    Remove it.

    Please see the github issue
    https://github.com/linux-audit/audit-kernel/issues/107

    Signed-off-by: Richard Guy Briggs
    [PM: fixed the referenced commit title]
    Signed-off-by: Paul Moore

    Richard Guy Briggs
     

19 Jan, 2019

1 commit

  • Tie syscall information to all CONFIG_CHANGE calls since they are all a
    result of user actions.

    Exclude user records from syscall context:
    Since the function audit_log_common_recv_msg() is shared by a number of
    AUDIT_CONFIG_CHANGE and the entire range of AUDIT_USER_* record types,
    and since the AUDIT_CONFIG_CHANGE message type has been converted to a
    syscall accompanied record type, special-case the AUDIT_USER_* range of
    messages so they remain standalone records.

    See: https://github.com/linux-audit/audit-kernel/issues/59
    See: https://github.com/linux-audit/audit-kernel/issues/50

    Signed-off-by: Richard Guy Briggs
    [PM: fix line lengths in kernel/audit.c]
    Signed-off-by: Paul Moore

    Richard Guy Briggs
     

19 Jun, 2018

2 commits

  • The AUDIT_FILTER_TYPE name is vague and misleading due to not describing
    where or when the filter is applied and obsolete due to its available
    filter fields having been expanded.

    Userspace has already renamed it from AUDIT_FILTER_TYPE to
    AUDIT_FILTER_EXCLUDE without checking if it already exists. The
    userspace maintainer assures that as long as it is set to the same value
    it will not be a problem since the userspace code does not treat
    compiler warnings as errors. If this policy changes then checks if it
    already exists can be added at the same time.

    See: https://github.com/linux-audit/audit-kernel/issues/89

    Signed-off-by: Richard Guy Briggs
    Signed-off-by: Paul Moore

    Richard Guy Briggs
     
  • This patch removes the restriction of the AUDIT_EXE field to only
    SYSCALL filter and teaches audit_filter to recognize this field.

    This makes it possible to write rule lists such as:

    auditctl -a exit,always [some general rule]
    # Filter out events with executable name /bin/exe1 or /bin/exe2:
    auditctl -a exclude,always -F exe=/bin/exe1
    auditctl -a exclude,always -F exe=/bin/exe2

    See: https://github.com/linux-audit/audit-kernel/issues/54

    Signed-off-by: Ondrej Mosnacek
    Reviewed-by: Richard Guy Briggs
    Signed-off-by: Paul Moore

    Ondrej Mosnáček
     

19 May, 2018

1 commit


24 Apr, 2018

1 commit

  • Current implementation of auditing by executable name only implements
    the 'equal' operator. This patch extends it to also support the 'not
    equal' operator.

    See: https://github.com/linux-audit/audit-kernel/issues/53

    Signed-off-by: Ondrej Mosnacek
    Reviewed-by: Richard Guy Briggs
    Signed-off-by: Paul Moore

    Ondrej Mosnáček
     

16 Feb, 2018

1 commit

  • The audit entry filter has been long deprecated with userspace support
    finally removed in audit-v2.6.7 and plans to remove kernel support have
    existed since kernel-v2.6.31.
    Remove it.

    Since removing the audit entry filter, test for early return before
    setting up any context state.

    Passes audit-testsuite.

    See: https://github.com/linux-audit/audit-kernel/issues/6

    Signed-off-by: Richard Guy Briggs
    Signed-off-by: Paul Moore

    Richard Guy Briggs
     

15 Feb, 2018

1 commit

  • A bug was introduced in 8fae47705685fcaa75a1fe4c8c3e18300a702979
    ("audit: add support for session ID user filter")
    See: https://github.com/linux-audit/audit-kernel/issues/4

    When setting a session ID filter, the session ID filter field overwrote
    the quick pointer reference to the arch field, potentially causing the
    arch field to be misinterpreted.

    Passes audit-testsuite.

    Signed-off-by: Richard Guy Briggs
    Signed-off-by: Paul Moore

    Richard Guy Briggs
     

11 Nov, 2017

1 commit

  • Tracefs or debugfs were causing hundreds to thousands of PATH records to
    be associated with the init_module and finit_module SYSCALL records on a
    few modules when the following rule was in place for startup:
    -a always,exit -F arch=x86_64 -S init_module -F key=mod-load

    Provide a method to ignore these large number of PATH records from
    overwhelming the logs if they are not of interest. Introduce a new
    filter list "AUDIT_FILTER_FS", with a new field type AUDIT_FSTYPE,
    which keys off the filesystem 4-octet hexadecimal magic identifier to
    filter specific filesystem PATH records.

    An example rule would look like:
    -a never,filesystem -F fstype=0x74726163 -F key=ignore_tracefs
    -a never,filesystem -F fstype=0x64626720 -F key=ignore_debugfs

    Arguably the better way to address this issue is to disable tracefs and
    debugfs on boot from production systems.

    See: https://github.com/linux-audit/audit-kernel/issues/16
    See: https://github.com/linux-audit/audit-userspace/issues/8
    Test case: https://github.com/linux-audit/audit-testsuite/issues/42

    Signed-off-by: Richard Guy Briggs
    [PM: fixed the whitespace damage in kernel/auditsc.c]
    Signed-off-by: Paul Moore

    Richard Guy Briggs
     

02 May, 2017

2 commits


30 Nov, 2016

1 commit

  • Define AUDIT_SESSIONID in the uapi and add support for specifying user
    filters based on the session ID. Also add the new session ID filter
    to the feature bitmap so userspace knows it is available.

    https://github.com/linux-audit/audit-kernel/issues/4
    RFE: add a session ID filter to the kernel's user filter

    Signed-off-by: Richard Guy Briggs
    [PM: combine multiple patches from Richard into this one]
    Signed-off-by: Paul Moore

    Richard Guy Briggs
     

21 Nov, 2016

1 commit

  • The AUDIT_CONFIG_CHANGE events sometimes use a op= field. The current
    code logs the value of the field with quotes. This field is documented
    to not be encoded, so it should not have quotes.

    Signed-off-by: Steve Grubb
    Reviewed-by: Richard Guy Briggs
    [PM: reformatted commit description to make checkpatch.pl happy]
    Signed-off-by: Paul Moore

    Steve Grubb
     

27 Jun, 2016

1 commit

  • RFE: add additional fields for use in audit filter exclude rules
    https://github.com/linux-audit/audit-kernel/issues/5

    Re-factor and combine audit_filter_type() with audit_filter_user() to
    use audit_filter_user_rules() to enable the exclude filter to
    additionally filter on PID, UID, GID, AUID, LOGINUID_SET, SUBJ_*.

    The process of combining the similar audit_filter_user() and
    audit_filter_type() functions, required inverting the meaning and
    including the ALWAYS action of the latter.

    Include audit_filter_user_rules() into audit_filter(), removing
    unneeded logic in the process.

    Keep the check to quit early if the list is empty.

    Signed-off-by: Richard Guy Briggs
    [PM: checkpatch.pl fixes - whitespace damage, wrapped description]
    Signed-off-by: Paul Moore

    Richard Guy Briggs
     

17 Jun, 2016

1 commit


01 Jun, 2016

1 commit


09 Feb, 2016

1 commit


04 Nov, 2015

1 commit


07 Aug, 2015

2 commits

  • This adds the ability audit the actions of a not-yet-running process.

    This patch implements the ability to filter on the executable path. Instead of
    just hard coding the ino and dev of the executable we care about at the moment
    the rule is inserted into the kernel, use the new audit_fsnotify
    infrastructure to manage this dynamically. This means that if the filename
    does not yet exist but the containing directory does, or if the inode in
    question is unlinked and creat'd (aka updated) the rule will just continue to
    work. If the containing directory is moved or deleted or the filesystem is
    unmounted, the rule is deleted automatically. A future enhancement would be to
    have the rule survive across directory disruptions.

    This is a heavily modified version of a patch originally submitted by Eric
    Paris with some ideas from Peter Moody.

    Cc: Peter Moody
    Cc: Eric Paris
    Signed-off-by: Richard Guy Briggs
    [PM: minor whitespace clean to satisfy ./scripts/checkpatch]
    Signed-off-by: Paul Moore

    Richard Guy Briggs
     
  • This is to be used to audit by executable path rules, but audit watches should
    be able to share this code eventually.

    At the moment the audit watch code is a lot more complex. That code only
    creates one fsnotify watch per parent directory. That 'audit_parent' in
    turn has a list of 'audit_watches' which contain the name, ino, dev of
    the specific object we care about. This just creates one fsnotify watch
    per object we care about. So if you watch 100 inodes in /etc this code
    will create 100 fsnotify watches on /etc. The audit_watch code will
    instead create 1 fsnotify watch on /etc (the audit_parent) and then 100
    individual watches chained from that fsnotify mark.

    We should be able to convert the audit_watch code to do one fsnotify
    mark per watch and simplify things/remove a whole lot of code. After
    that conversion we should be able to convert the audit_fsnotify code to
    support that hierarchy if the optimization is necessary.

    Move the access to the entry for audit_match_signal() to the beginning of
    the audit_del_rule() function in case the entry found is the same one passed
    in. This will enable it to be used by audit_autoremove_mark_rule(),
    kill_rules() and audit_remove_parent_watches().

    This is a heavily modified and merged version of two patches originally
    submitted by Eric Paris.

    Cc: Peter Moody
    Cc: Eric Paris
    Signed-off-by: Richard Guy Briggs
    [PM: added a space after a declaration to keep ./scripts/checkpatch happy]
    Signed-off-by: Paul Moore

    Richard Guy Briggs
     

06 Aug, 2015

1 commit

  • Move the access to the entry for audit_match_signal() to earlier in the
    function in case the entry found is the same one passed in. This will enable
    it to be used by audit_remove_mark_rule().

    Signed-off-by: Richard Guy Briggs
    [PM: tweaked subject line as it no longer made sense after multiple revs]
    Signed-off-by: Paul Moore

    Richard Guy Briggs
     

05 Aug, 2015

2 commits


12 Feb, 2015

1 commit

  • Pull audit fix from Paul Moore:
    "Just one patch from the audit tree for v3.20, and a very minor one at
    that.

    The patch simply removes an old, unused field from the audit_krule
    structure, a private audit-only struct. In audit related news, we did
    a proper overhaul of the audit pathname code and removed the nasty
    getname()/putname() hacks for audit, you should see those patches in
    Al's vfs tree if you haven't already.

    That's it for audit this time, let's hope for a quiet -rcX series"

    * 'upstream' of git://git.infradead.org/users/pcmoore/audit:
    audit: remove vestiges of vers_ops

    Linus Torvalds
     

20 Jan, 2015

1 commit


24 Dec, 2014

2 commits

  • Pull audit fixes from Paul Moore:
    "Four patches to fix various problems with the audit subsystem, all are
    fairly small and straightforward.

    One patch fixes a problem where we weren't using the correct gfp
    allocation flags (GFP_KERNEL regardless of context, oops), one patch
    fixes a problem with old userspace tools (this was broken for a
    while), one patch fixes a problem where we weren't recording pathnames
    correctly, and one fixes a problem with PID based filters.

    In general I don't think there is anything controversial with this
    patchset, and it fixes some rather unfortunate bugs; the allocation
    flag one can be particularly scary looking for users"

    * 'upstream' of git://git.infradead.org/users/pcmoore/audit:
    audit: restore AUDIT_LOGINUID unset ABI
    audit: correctly record file names with different path name types
    audit: use supplied gfp_mask from audit_buffer in kauditd_send_multicast_skb
    audit: don't attempt to lookup PIDs when changing PID filtering audit rules

    Linus Torvalds
     
  • A regression was caused by commit 780a7654cee8:
    audit: Make testing for a valid loginuid explicit.
    (which in turn attempted to fix a regression caused by e1760bd)

    When audit_krule_to_data() fills in the rules to get a listing, there was a
    missing clause to convert back from AUDIT_LOGINUID_SET to AUDIT_LOGINUID.

    This broke userspace by not returning the same information that was sent and
    expected.

    The rule:
    auditctl -a exit,never -F auid=-1
    gives:
    auditctl -l
    LIST_RULES: exit,never f24=0 syscall=all
    when it should give:
    LIST_RULES: exit,never auid=-1 (0xffffffff) syscall=all

    Tag it so that it is reported the same way it was set. Create a new
    private flags audit_krule field (pflags) to store it that won't interact with
    the public one from the API.

    Cc: stable@vger.kernel.org # v3.10-rc1+
    Signed-off-by: Richard Guy Briggs
    Signed-off-by: Paul Moore

    Richard Guy Briggs