workqueue: cond_resched() after processing each work item
This becomes dangerous when a self-requeueing work item which is
waiting for something to happen races against stop_machine.  Such
self-requeueing work item would requeue itself indefinitely hogging
the kworker and CPU it's running on while stop_machine would wait for
that CPU to enter stop_machine while preventing anything else from
happening on all other CPUs.  The two would deadlock.

Jamie Liu reports that this deadlock scenario exists around
scsi_requeue_run_queue() and libata port multiplier support, where one
port may exclude command processing from other ports.  With the right
timing, scsi_requeue_run_queue() can end up requeueing itself trying
to execute an IO which is asked to be retried while another device has
an exclusive access, which in turn can't make forward progress due to
stop_machine.

Fix it by invoking cond_resched() after executing each work item.
staging: android: ashmem: Avoid deadlock with mmap/shrink
Both ashmem_mmap and ashmem_shrink take the ashmem_lock. It may
be possible for ashmem_mmap to invoke ashmem_shrink:

-000|mutex_lock(lock = 0x0)
-001|ashmem_shrink(?, sc = 0x0) <--- try to take ashmem_mutex again
-002|shrink_slab(shrink = 0xDA5F1CC0, nr_pages_scanned = 0, lru_pages
-002|=
-002|124)
-003|try_to_free_pages(zonelist = 0x0, ?, ?, ?)
-004|__alloc_pages_nodemask(gfp_mask = 21200, order = 1, zonelist =
-004|0xC11D0940,
-005|new_slab(s = 0xE4841E80, ?, node = -1)
-006|__slab_alloc.isra.43.constprop.50(s = 0xE4841E80, gfpflags =
-006|2148925462, ad
-007|kmem_cache_alloc(s = 0xE4841E80, gfpflags = 208)
-008|shmem_alloc_inode(?)
-009|alloc_inode(sb = 0xE480E800)
-010|new_inode_pseudo(?)
-011|new_inode(?)
-012|shmem_get_inode(sb = 0xE480E800, dir = 0x0, ?, dev = 0, flags =
-012|187)
-013|shmem_file_setup(?, ?, flags = 187)
-014|ashmem_mmap(?, vma = 0xC5D64210) <---- Acquire ashmem_mutex
-015|mmap_region(file = 0xDF8E2C00, addr = 1772974080, len = 233472,
-015|flags = 57,
-016|sys_mmap_pgoff(addr = 0, len = 230400, prot = 3, flags = 1, fd =
-016|157, pgoff
-017|ret_fast_syscall(asm)
-->|exception
-018|NUR:0x40097508(asm)
---|end of frame

Avoid this deadlock by using mutex_trylock in ashmem_shrink; if the mutex
is already held, do not attempt to shrink.
sync: Fix a race condition between release_obj and print_obj
Before this change, a timeline would only be removed from the timeline
list *after* the sync driver had its release_obj() called. However, the
driver's release_obj() may free resources needed by print_obj().

Although the timeline list is locked when print_obj() is called, it is
not locked when release_obj() is called. If one CPU was in print_obj()
when another was in release_obj(), the print_obj() may make unsafe
accesses.

It is not actually necessary to hold the timeline list lock when calling
release_obj() if the call is made after the timeline is unlinked from
the list, since there is no possibility another thread could be in --
or enter -- print_obj() for that timeline.

This change moves the release_obj() call to after the timeline is
unlinked, preventing the above race from occurring.
sync: signal pt before sync_timeline object gets destroyed
There is a race condition

Assume we have *one* sync_fence object, with *one* sync_pt
which belongs to *one* sync_timeline, given this condition,
sync_timeline->kref will have two counts, one for sync_timeline
(implicit) and another for sync_pt.

Assume following is the situation on CPU

Theead-1 : (Thread which calls sync_timeline_destroy())
  -> (some function calls)
   -> sync_timeline_destory()
    -> sync_timeline_signal() (CPU is inside this
function after putting reference to sync_timeline)

At this time Thread-2 comes and does following

Thread-2 : (fclose on fence fd)
> sync_fence_release() -> because of fclose() on fence object
 -> sync_fence_free()
  -> sync_pt_free()
   -> kref_put(&pt->parent->kref, sync_timeline_free);
    -> sync_timeline_free() (CPU is inside this because
this time kref will be zero after _put)

Thread-2 will free sync_timeline object before Thread-1
has finished its work inside sync_timeline_signal.

With this change we signals all sync_pt before putting
reference to sync_timeline object.
hw_breakpoint: Add a missing variable definition
random: backport updates from Linux master (3.13-rc4)
lib, net: make isodigit() public and use itAndy Shevchenko
random: add debugging code to detect early use of get_random_bytes()Theodore Ts'o
random: initialize the last_time field in struct timer_rand_stateTheodore Ts'o
random: don't zap entropy count in rand_initialize()Theodore Ts'o
random: printk notifications for urandom pool initializationTheodore Ts'o
random: make add_timer_randomness() fill the nonblocking pool firstTheodore Ts'o
random: convert DEBUG_ENT to tracepointsTheodore Ts'o
random: push extra entropy to the output poolsTheodore Ts'o
random: drop trickle modeTheodore Ts'o
random: adjust the generator polynomials in the mixing function slightlyTheodore Ts'o
random: speed up the fast_mix function by a factor of fourTheodore Ts'o
random: cap the rate which the /dev/urandom pool gets reseededTheodore Ts'o
random: optimize the entropy_store structureTheodore Ts'o
random: optimize spinlock use in add_device_randomness()Theodore Ts'o
random: fix the tracepoint for get_random_bytes(_arch)Theodore Ts'o
random: account for entropy loss due to overwritesH. Peter Anvin
random: allow fractional bits to be trackedH. Peter Anvin
random: statically compute poolbitshift, poolbytes, poolbitsH. Peter Anvin
random: mix in architectural randomness earlier in extract_buf()Theodore Ts'o
random: allow architectures to optionally define random_get_entropy()Theodore Ts'o
random: run random_int_secret_init() run after all late_initcallsTheodore Ts'o
char: Convert use of typedef ctl_table to struct ctl_tableJoe Perches1
random: fix accounting race condition with lockless irq entropy_count updateJiri Kosina
drivers/char/random.c: fix priming of last_dataJarod Wilson
lib/string_helpers: introduce generic string_unescapeAndy Shevchenko
random: fix locking dependency with the tasklist_lockTheodore Ts'o
locking: Various static lock initializer fixesThomas Gleixner
random: prime last_data value per fips requirementsJarod Wilson
random: fix debug format stringsJiri Kosina
random: make it possible to enable debugging without rebuildJiri Kosina
random: mix in architectural randomness in extract_buf()H. Peter Anvin
random: Add comment to random_initialize()Tony Luck
random: add tracepoints for easier debugging and verificationTheodore Ts'o