Skip to content
  1. Nov 12, 2018
    • Jan Kara's avatar
      audit: Allocate fsnotify mark independently of chunk · 5f516130
      Jan Kara authored
      
      
      Allocate fsnotify mark independently instead of embedding it inside
      chunk. This will allow us to just replace chunk attached to mark when
      growing / shrinking chunk instead of replacing mark attached to inode
      which is a more complex operation.
      
      Reviewed-by: default avatarRichard Guy Briggs <rgb@redhat.com>
      Signed-off-by: default avatarJan Kara <jack@suse.cz>
      Signed-off-by: default avatarPaul Moore <paul@paul-moore.com>
      5f516130
    • Jan Kara's avatar
      audit: Provide helper for dropping mark's chunk reference · a8375713
      Jan Kara authored
      
      
      Provide a helper function audit_mark_put_chunk() for dropping mark's
      reference (which has to happen only after RCU grace period expires).
      Currently that happens only from a single place but in later patches we
      introduce more callers.
      
      Reviewed-by: default avatarRichard Guy Briggs <rgb@redhat.com>
      Signed-off-by: default avatarJan Kara <jack@suse.cz>
      Signed-off-by: default avatarPaul Moore <paul@paul-moore.com>
      a8375713
    • Jan Kara's avatar
      audit: Remove pointless check in insert_hash() · 8cd0feb5
      Jan Kara authored
      
      
      The audit_tree_group->mark_mutex is held all the time while we create
      the fsnotify mark, add it to the inode, and insert chunk into the hash.
      Hence mark cannot get detached during this time and so the check whether
      the mark is attached in insert_hash() is pointless.
      
      Reviewed-by: default avatarRichard Guy Briggs <rgb@redhat.com>
      Signed-off-by: default avatarJan Kara <jack@suse.cz>
      Signed-off-by: default avatarPaul Moore <paul@paul-moore.com>
      8cd0feb5
    • Jan Kara's avatar
      audit: Factor out chunk replacement code · d31b326d
      Jan Kara authored
      
      
      Chunk replacement code is very similar for the cases where we grow or
      shrink chunk. Factor the code out into a common helper function.
      
      Signed-off-by: default avatarJan Kara <jack@suse.cz>
      Reviewed-by: default avatarRichard Guy Briggs <rgb@redhat.com>
      Signed-off-by: default avatarPaul Moore <paul@paul-moore.com>
      d31b326d
    • Jan Kara's avatar
      audit: Make hash table insertion safe against concurrent lookups · 1635e572
      Jan Kara authored
      
      
      Currently, the audit tree code does not make sure that when a chunk is
      inserted into the hash table, it is fully initialized. So in theory a
      user of RCU lookup could see uninitialized structure in the hash table
      and crash. Add appropriate barriers between initialization of the
      structure and its insertion into hash table.
      
      Reviewed-by: default avatarRichard Guy Briggs <rgb@redhat.com>
      Signed-off-by: default avatarJan Kara <jack@suse.cz>
      Signed-off-by: default avatarPaul Moore <paul@paul-moore.com>
      1635e572
    • Jan Kara's avatar
      audit: Embed key into chunk · 8d20d6e9
      Jan Kara authored
      
      
      Currently chunk hash key (which is in fact pointer to the inode) is
      derived as chunk->mark.conn->obj. It is tricky to make this dereference
      reliable for hash table lookups only under RCU as mark can get detached
      from the connector and connector gets freed independently of the
      running lookup. Thus there is a possible use after free / NULL ptr
      dereference issue:
      
      CPU1					CPU2
      					untag_chunk()
      					  ...
      audit_tree_lookup()
        list_for_each_entry_rcu(p, list, hash) {
      					  list_del_rcu(&chunk->hash);
      					  fsnotify_destroy_mark(entry);
      					  fsnotify_put_mark(entry)
          chunk_to_key(p)
            if (!chunk->mark.connector)
      					    ...
      					    hlist_del_init_rcu(&mark->obj_list);
      					    if (hlist_empty(&conn->list)) {
      					      inode = fsnotify_detach_connector_from_object(conn);
      					    mark->connector = NULL;
      					    ...
      					    frees connector from workqueue
            chunk->mark.connector->obj
      
      This race is probably impossible to hit in practice as the race window
      on CPU1 is very narrow and CPU2 has a lot of code to execute. Still it's
      better to have this fixed. Since the inode the chunk is attached to is
      constant during chunk's lifetime it is easy to cache the key in the
      chunk itself and thus avoid these issues.
      
      Reviewed-by: default avatarRichard Guy Briggs <rgb@redhat.com>
      Signed-off-by: default avatarJan Kara <jack@suse.cz>
      Signed-off-by: default avatarPaul Moore <paul@paul-moore.com>
      8d20d6e9
    • Jan Kara's avatar
      audit: Fix possible tagging failures · b1e4603b
      Jan Kara authored
      
      
      Audit tree code is replacing marks attached to inodes in non-atomic way.
      Thus fsnotify_find_mark() in tag_chunk() may find a mark that belongs to
      a chunk that is no longer valid one and will soon be destroyed. Tags
      added to such chunk will be simply lost.
      
      Fix the problem by making sure old mark is marked as going away (through
      fsnotify_detach_mark()) before dropping mark_mutex and thus in an atomic
      way wrt tag_chunk(). Note that this does not fix the problem completely
      as if tag_chunk() finds a mark that is going away, it fails with
      -ENOENT. But at least the failure is not silent and currently there's no
      way to search for another fsnotify mark attached to the inode. We'll fix
      this problem in later patch.
      
      Reviewed-by: default avatarRichard Guy Briggs <rgb@redhat.com>
      Signed-off-by: default avatarJan Kara <jack@suse.cz>
      Signed-off-by: default avatarPaul Moore <paul@paul-moore.com>
      b1e4603b
    • Jan Kara's avatar
      audit: Fix possible spurious -ENOSPC error · a5789b07
      Jan Kara authored
      
      
      When an inode is tagged with a tree, tag_chunk() checks whether there is
      audit_tree_group mark attached to the inode and adds one if not. However
      nothing protects another tag_chunk() to add the mark between we've
      checked and try to add the fsnotify mark thus resulting in an error from
      fsnotify_add_mark() and consequently an ENOSPC error from tag_chunk().
      
      Fix the problem by holding mark_mutex over the whole check-insert code
      sequence.
      
      Reviewed-by: default avatarRichard Guy Briggs <rgb@redhat.com>
      Signed-off-by: default avatarJan Kara <jack@suse.cz>
      Signed-off-by: default avatarPaul Moore <paul@paul-moore.com>
      a5789b07
    • Jan Kara's avatar
      audit_tree: Remove mark->lock locking · 9f16d2e6
      Jan Kara authored
      
      
      Currently, audit_tree code uses mark->lock to protect against detaching
      of mark from an inode. In most places it however also uses
      mark->group->mark_mutex (as we need to atomically replace attached
      marks) and this provides protection against mark detaching as well. So
      just remove protection with mark->lock from audit tree code and replace
      it with mark->group->mark_mutex protection in all the places. It
      simplifies the code and gets rid of some ugly catches like calling
      fsnotify_add_mark_locked() with mark->lock held (which cannot sleep only
      because we hold a reference to another mark attached to the same inode).
      
      Reviewed-by: default avatarRichard Guy Briggs <rgb@redhat.com>
      Signed-off-by: default avatarJan Kara <jack@suse.cz>
      Signed-off-by: default avatarPaul Moore <paul@paul-moore.com>
      9f16d2e6
  2. Nov 06, 2018
    • Richard Guy Briggs's avatar
      audit: print empty EXECVE args · ea956d8b
      Richard Guy Briggs authored
      Empty executable arguments were being skipped when printing out the list
      of arguments in an EXECVE record, making it appear they were somehow
      lost.  Include empty arguments as an itemized empty string.
      
      Reproducer:
      	autrace /bin/ls "" "/etc"
      	ausearch --start recent -m execve -i | grep EXECVE
      	type=EXECVE msg=audit(10/03/2018 13:04:03.208:1391) : argc=3 a0=/bin/ls a2=/etc
      
      With fix:
      	type=EXECVE msg=audit(10/03/2018 21:51:38.290:194) : argc=3 a0=/bin/ls a1= a2=/etc
      	type=EXECVE msg=audit(1538617898.290:194): argc=3 a0="/bin/ls" a1="" a2="/etc"
      
      Passes audit-testsuite.  GH issue tracker at
      https://github.com/linux-audit/audit-kernel/issues/99
      
      
      
      Signed-off-by: default avatarRichard Guy Briggs <rgb@redhat.com>
      [PM: cleaned up the commit metadata]
      Signed-off-by: default avatarPaul Moore <paul@paul-moore.com>
      ea956d8b
  3. Nov 05, 2018
    • Linus Torvalds's avatar
      Linux 4.20-rc1 · 65102238
      Linus Torvalds authored
      65102238
    • Linus Torvalds's avatar
      Merge tag 'tags/upstream-4.20-rc1' of git://git.infradead.org/linux-ubifs · 42bd06e9
      Linus Torvalds authored
      Pull UBIFS updates from Richard Weinberger:
      
       - Full filesystem authentication feature, UBIFS is now able to have the
         whole filesystem structure authenticated plus user data encrypted and
         authenticated.
      
       - Minor cleanups
      
      * tag 'tags/upstream-4.20-rc1' of git://git.infradead.org/linux-ubifs: (26 commits)
        ubifs: Remove unneeded semicolon
        Documentation: ubifs: Add authentication whitepaper
        ubifs: Enable authentication support
        ubifs: Do not update inode size in-place in authenticated mode
        ubifs: Add hashes and HMACs to default filesystem
        ubifs: authentication: Authenticate super block node
        ubifs: Create hash for default LPT
        ubfis: authentication: Authenticate master node
        ubifs: authentication: Authenticate LPT
        ubifs: Authenticate replayed journal
        ubifs: Add auth nodes to garbage collector journal head
        ubifs: Add authentication nodes to journal
        ubifs: authentication: Add hashes to index nodes
        ubifs: Add hashes to the tree node cache
        ubifs: Create functions to embed a HMAC in a node
        ubifs: Add helper functions for authentication support
        ubifs: Add separate functions to init/crc a node
        ubifs: Format changes for authentication support
        ubifs: Store read superblock node
        ubifs: Drop write_node
        ...
      42bd06e9
    • Linus Torvalds's avatar
      Merge tag 'nfs-for-4.20-2' of git://git.linux-nfs.org/projects/trondmy/linux-nfs · 4710e789
      Linus Torvalds authored
      Pull NFS client bugfixes from Trond Myklebust:
       "Highlights include:
      
        Bugfix:
         - Fix build issues on architectures that don't provide 64-bit cmpxchg
      
        Cleanups:
         - Fix a spelling mistake"
      
      * tag 'nfs-for-4.20-2' of git://git.linux-nfs.org/projects/trondmy/linux-nfs:
        NFS: fix spelling mistake, EACCESS -> EACCES
        SUNRPC: Use atomic(64)_t for seq_send(64)
      4710e789
    • Linus Torvalds's avatar
      Merge branch 'timers-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip · 35e74524
      Linus Torvalds authored
      Pull more timer updates from Thomas Gleixner:
       "A set of commits for the new C-SKY architecture timers"
      
      * 'timers-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
        dt-bindings: timer: gx6605s SOC timer
        clocksource/drivers/c-sky: Add gx6605s SOC system timer
        dt-bindings: timer: C-SKY Multi-processor timer
        clocksource/drivers/c-sky: Add C-SKY SMP timer
      35e74524
    • Linus Torvalds's avatar
      Merge tag 'ntb-4.20' of git://github.com/jonmason/ntb · 04578e84
      Linus Torvalds authored
      Pull NTB updates from Jon Mason:
       "Fairly minor changes and bug fixes:
      
        NTB IDT thermal changes and hook into hwmon, ntb_netdev clean-up of
        private struct, and a few bug fixes"
      
      * tag 'ntb-4.20' of git://github.com/jonmason/ntb:
        ntb: idt: Alter the driver info comments
        ntb: idt: Discard temperature sensor IRQ handler
        ntb: idt: Add basic hwmon sysfs interface
        ntb: idt: Alter temperature read method
        ntb_netdev: Simplify remove with client device drvdata
        NTB: transport: Try harder to alloc an aligned MW buffer
        ntb: ntb_transport: Mark expected switch fall-throughs
        ntb: idt: Set PCIe bus address to BARLIMITx
        NTB: ntb_hw_idt: replace IS_ERR_OR_NULL with regular NULL checks
        ntb: intel: fix return value for ndev_vec_mask()
        ntb_netdev: fix sleep time mismatch
      04578e84
  4. Nov 04, 2018