Backport: PR_{GET,SET}_NO_NEW_PRIVS to prevent execve from granting privs

Original message:

Add PR_{GET,SET}_NO_NEW_PRIVS to prevent execve from granting privs

With this set, a lot of dangerous operations (chroot, unshare, etc)
become a lot less dangerous because there is no possibility of
subverting privileged binaries.

This patch completely breaks apparmor.  Someone who understands (and
uses) apparmor should fix it or at least give me a hint.

Signed-off-by: Andy Lutomirski <luto@amacapital.net>

Change-Id: I370e8cc0fd6046c0b733c35447698e4e4531454f
(cherry picked from commit d803f7a504a0522ab4d81a6e37b50d3df8985da6)
backport uhid driver from linux 3.8

the userspace HID driver is needed by the JB bluetooth stack to process input
from bluetooth keyboards.

Change-Id: I60d4bd309a23dfd1558d985fa76d9699f33103ed
netfilter: xt_qtaguid: update to msm-3.4

AU_LINUX_ANDROID_JB_MR2.04.03.00.110.011
Preserve compatibility with 2.6.35 kernel.

psyke83: cleaned up some whitespace differences

Change-Id: I8912242c95270f21b0d21dc859c56f0d0342d8c0
binfmt_elf.c: use get_random_int() to fix entropy depleting.

Usually the entropy pool depletes very fast and stays in the 100-200 range.
After this patch, the entropy stays in the 600-1000 range without the risk of
depleting in normal workloads.

Change-Id: Ice0d0f14691046249d7b4a4d31af98ab80c6306b
backport lowmemorykiller from CAF msm-3.4

this improves low memory behaviour greatly due to accounting for
lowmem_reserve as well as shmem pages.

Change-Id: I351dda49be388a98edfe6cc31ae4f2667c77429c
(cherry picked from commit a64a14050e32fa79905903cf76c62be5b360c8eb)
lowmemorykiller: skip already freed memory

Change-Id: I1cb221ff7dad399b3b57817706812561f67c6707
staging: android: lowmemorykiller: implement task's adj rbtree

Based on the current LMK implementation, LMK has to scan all processes to
select the correct task to kill during low memory.
The basic idea for the optimization is to :
queue all tasks with oom_score_adj priority, and then LMK just selects the
proper task from the queue(rbtree) to kill.

performance improvement:
the current implementation: average time to find a task to kill : 1004us
the optimized implementation: average time to find a task to kill: 43us

squished another 3 commits:

staging: android: lowmemorykiller: select a new task to kill
Under certain circumstances, a process may take time to handle a SIGKILL.
When lowmemkiller is called again shortly after, it would pick the same
process to kill over and over, so that we cann't get free memory for long time.

Solution is to check fatal_signal_pending() on the selected task, and if it's
already pending, select a new task to kill.

staging: android: lmk: skip if killed by lmk
A task can be selected to kill when it's already exiting. Sending
signal to the task at that state won't set TIF_SIGPENDING for it.
After that, every task including threads in the exiting task itself
running into lmk will compete for the mutex, then spend some time
waiting for the exiting task to release memory or try to send signal
to the same task again.
We want the exiting task to exit as early as possible but it's slowed
down greatly by the mutex and waiting. Skip lmk if current thread
group leader is exiting and is killed by lmk. Also delegate TIF_MEMDIE
to current task.

staging: android: lmk: check TIF directly
When trying to fix that lmk can't kill an exiting task
(commit 895304e
(CR) staging: android: lmk: skip if killed by lmk),
additional check was added for the TIF_MEMDIE flag.
However the task lock has already been taken when examining
the task. The same helper function which tries to grab the
task lock again will be deadlocked.
Change to check the thread flag of thread group leader directly.

Change-Id: Ibbb99cbd36e27a546195b4d4bed59b3829e6b7b0
memcg: res_counter_read_u64(): fix potential races on 32-bit machines

res_counter_read_u64 reads u64 value without lock.  It's dangerous in a
32bit environment.  Add locking.

Signed-off-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Cc: Greg Thelen <gthelen@google.com>
Cc: Johannes Weiner <hannes@cmpxchg.org>
Cc: David Rientjes <rientjes@google.com>
Cc: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
Cc: Minchan Kim <minchan.kim@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

Change-Id: I8f92ec62f2552798237c7d7709547f00c0bce292