1. 12 Nov, 2018 12 commits
    • Jan Kara's avatar
      audit: Simplify locking around untag_chunk() · 8432c700
      Jan Kara authored
      untag_chunk() has to be called with hash_lock, it drops it and
      reacquires it when returning. The unlocking of hash_lock is thus hidden
      from the callers of untag_chunk() with is rather error prone. Reorganize
      the code so that untag_chunk() is called without hash_lock, only with
      mark reference preventing the chunk from going away.
      
      Since this requires some more code in the caller of untag_chunk() to
      assure forward progress, factor out loop pruning tree from all chunks
      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>
      8432c700
    • Jan Kara's avatar
      audit: Drop all unused chunk nodes during deletion · c22fcde7
      Jan Kara authored
      When deleting chunk from a tree, drop all unused nodes in a chunk
      instead of just the one used by the tree. This gets rid of possibly
      lingering unused nodes (created due to fallback path in untag_chunk())
      and also removes some special cases and will allow us to simplify
      locking in untag_chunk().
      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>
      c22fcde7
    • Jan Kara's avatar
      audit: Guarantee forward progress of chunk untagging · 49a4ee7d
      Jan Kara authored
      When removing chunk from a tree, we do shrink the chunk. This can fail
      for various reasons (due to races, ENOMEM, etc.) and in some cases we
      just bail from untag_chunk() relying on someone else to cleanup.
      Although this currently works, later we will need to add new failure
      situation which would break. Also this simplifies the code and will
      allow us to make locking around untag_chunk() less awkward.
      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>
      49a4ee7d
    • 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. 05 Nov, 2018 1 commit
    • 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/99Signed-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. 04 Nov, 2018 9 commits
    • 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
    • Linus Torvalds's avatar
      Merge branch 'sched-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip · 71e56028
      Linus Torvalds authored
      Pull scheduler fixes from Ingo Molnar:
       "A memory (under-)allocation fix and a comment fix"
      
      * 'sched-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
        sched/topology: Fix off by one bug
        sched/rt: Update comment in pick_next_task_rt()
      71e56028
    • Linus Torvalds's avatar
      Merge branch 'x86-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip · 601a8807
      Linus Torvalds authored
      Pull x86 fixes from Ingo Molnar:
       "A number of fixes and some late updates:
      
         - make in_compat_syscall() behavior on x86-32 similar to other
           platforms, this touches a number of generic files but is not
           intended to impact non-x86 platforms.
      
         - objtool fixes
      
         - PAT preemption fix
      
         - paravirt fixes/cleanups
      
         - cpufeatures updates for new instructions
      
         - earlyprintk quirk
      
         - make microcode version in sysfs world-readable (it is already
           world-readable in procfs)
      
         - minor cleanups and fixes"
      
      * 'x86-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
        compat: Cleanup in_compat_syscall() callers
        x86/compat: Adjust in_compat_syscall() to generic code under !COMPAT
        objtool: Support GCC 9 cold subfunction naming scheme
        x86/numa_emulation: Fix uniform-split numa emulation
        x86/paravirt: Remove unused _paravirt_ident_32
        x86/mm/pat: Disable preemption around __flush_tlb_all()
        x86/paravirt: Remove GPL from pv_ops export
        x86/traps: Use format string with panic() call
        x86: Clean up 'sizeof x' => 'sizeof(x)'
        x86/cpufeatures: Enumerate MOVDIR64B instruction
        x86/cpufeatures: Enumerate MOVDIRI instruction
        x86/earlyprintk: Add a force option for pciserial device
        objtool: Support per-function rodata sections
        x86/microcode: Make revision and processor flags world-readable
      601a8807
    • Linus Torvalds's avatar
      Merge branch 'perf-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip · 01897f3e
      Linus Torvalds authored
      Pull perf updates and fixes from Ingo Molnar:
       "These are almost all tooling updates: 'perf top', 'perf trace' and
        'perf script' fixes and updates, an UAPI header sync with the merge
        window versions, license marker updates, much improved Sparc support
        from David Miller, and a number of fixes"
      
      * 'perf-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: (66 commits)
        perf intel-pt/bts: Calculate cpumode for synthesized samples
        perf intel-pt: Insert callchain context into synthesized callchains
        perf tools: Don't clone maps from parent when synthesizing forks
        perf top: Start display thread earlier
        tools headers uapi: Update linux/if_link.h header copy
        tools headers uapi: Update linux/netlink.h header copy
        tools headers: Sync the various kvm.h header copies
        tools include uapi: Update linux/mmap.h copy
        perf trace beauty: Use the mmap flags table generated from headers
        perf beauty: Wire up the mmap flags table generator to the Makefile
        perf beauty: Add a generator for MAP_ mmap's flag constants
        tools include uapi: Update asound.h copy
        tools arch uapi: Update asm-generic/unistd.h and arm64 unistd.h copies
        tools include uapi: Update linux/fs.h copy
        perf callchain: Honour the ordering of PERF_CONTEXT_{USER,KERNEL,etc}
        perf cs-etm: Correct CPU mode for samples
        perf unwind: Take pgoff into account when reporting elf to libdwfl
        perf top: Do not use overwrite mode by default
        perf top: Allow disabling the overwrite mode
        perf trace: Beautify mount's first pathname arg
        ...
      01897f3e
    • Linus Torvalds's avatar
      Merge branch 'irq-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip · e9ebc215
      Linus Torvalds authored
      Pull irq fixes from Ingo Molnar:
       "An irqchip driver fix and a memory (over-)allocation fix"
      
      * 'irq-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
        irqchip/irq-mvebu-sei: Fix a NULL vs IS_ERR() bug in probe function
        irq/matrix: Fix memory overallocation
      e9ebc215
  4. 03 Nov, 2018 18 commits