CM10DNA/android_kernel_htc_dlx — pull request #7 by crpalmer (2013-04-07 10:02:27+00:00)
Title: cgroup: Add generic cgroup subsystem permission checks

This should fix the following error that appears a lot in the logcat:

W/SchedPolicy( 540): add_tid_to_cgroup failed to write '1265' (Permission denied); policy=0
W/System.err( 540): java.lang.SecurityException: No permission to set to given group
W/System.err( 540): at android.os.Process.setProcessGroup(Native Method)
W/System.err( 540): at com.android.server.am.ActivityManagerService.updateOomAdjLocked(ActivityManagerService.java)
W/System.err( 540): at com.android.server.am.ActivityManagerService.updateOomAdjLocked(ActivityManagerService.java)
W/System.err( 540): at com.android.server.am.ActivityManagerService.removeContentProvider(ActivityManagerService.java)
W/System.err( 540): at android.app.ActivityManagerNative.onTransact(ActivityManagerNative.java)
W/System.err( 540): at com.android.server.am.ActivityManagerService.onTransact(ActivityManagerService.java)
W/System.err( 540): at android.os.Binder.execTransact(Binder.java)
W/System.err( 540): at dalvik.system.NativeStart.run(Native Method)
W/ActivityManager( 540): Failed setting process group of 1265 to 0

---

Rather than using explicit euid == 0 checks when trying to move
tasks into a cgroup via CFS, move permission checks into each
specific cgroup subsystem. If a subsystem does not specify a
'allow_attach' handler, then we fall back to doing our checks
the old way.

Use the 'allow_attach' handler for the 'cpu' cgroup to allow
non-root processes to add arbitrary processes to a 'cpu' cgroup
if it has the CAP_SYS_NICE capability set.

This version of the patch adds a 'allow_attach' handler instead
of reusing the 'can_attach' handler. If the 'can_attach' handler
is reused, a new cgroup that implements 'can_attach' but not
the permission checks could end up with no permission checks
at all.

Change-Id: Icfa950aa9321d1ceba362061d32dc7dfa2c64f0c
Original-Author: San Mehat
Signed-off-by: Colin Cross