mirror of
https://github.com/followmsi/android_kernel_google_msm.git
synced 2024-11-06 23:17:41 +00:00
Grants system server access to /proc/<pid>/oom_adj for Android applications.
Signed-off-by: Brian Swetland <swetland@google.com>
(cherry picked from commit f371eddcad
)
This commit is contained in:
parent
c519917200
commit
e89b006a72
1 changed files with 36 additions and 1 deletions
|
@ -137,6 +137,12 @@ struct pid_entry {
|
|||
|
||||
static int proc_fd_permission(struct inode *inode, int mask);
|
||||
|
||||
/* ANDROID is for special files in /proc. */
|
||||
#define ANDROID(NAME, MODE, OTYPE) \
|
||||
NOD(NAME, (S_IFREG|(MODE)), \
|
||||
&proc_##OTYPE##_inode_operations, \
|
||||
&proc_##OTYPE##_operations, {})
|
||||
|
||||
/*
|
||||
* Count the number of hardlinks for the pid_entry table, excluding the .
|
||||
* and .. links.
|
||||
|
@ -969,6 +975,35 @@ out:
|
|||
return err < 0 ? err : count;
|
||||
}
|
||||
|
||||
static int oom_adjust_permission(struct inode *inode, int mask)
|
||||
{
|
||||
uid_t uid;
|
||||
struct task_struct *p;
|
||||
|
||||
p = get_proc_task(inode);
|
||||
if(p) {
|
||||
uid = task_uid(p);
|
||||
put_task_struct(p);
|
||||
}
|
||||
|
||||
/*
|
||||
* System Server (uid == 1000) is granted access to oom_adj of all
|
||||
* android applications (uid > 10000) as and services (uid >= 1000)
|
||||
*/
|
||||
if (p && (current_fsuid() == 1000) && (uid >= 1000)) {
|
||||
if (inode->i_mode >> 6 & mask) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/* Fall back to default. */
|
||||
return generic_permission(inode, mask);
|
||||
}
|
||||
|
||||
static const struct inode_operations proc_oom_adjust_inode_operations = {
|
||||
.permission = oom_adjust_permission,
|
||||
};
|
||||
|
||||
static const struct file_operations proc_oom_adjust_operations = {
|
||||
.read = oom_adjust_read,
|
||||
.write = oom_adjust_write,
|
||||
|
@ -3008,7 +3043,7 @@ static const struct pid_entry tgid_base_stuff[] = {
|
|||
REG("cgroup", S_IRUGO, proc_cgroup_operations),
|
||||
#endif
|
||||
INF("oom_score", S_IRUGO, proc_oom_score),
|
||||
REG("oom_adj", S_IRUGO|S_IWUSR, proc_oom_adjust_operations),
|
||||
ANDROID("oom_adj",S_IRUGO|S_IWUSR, oom_adjust),
|
||||
REG("oom_score_adj", S_IRUGO|S_IWUSR, proc_oom_score_adj_operations),
|
||||
#ifdef CONFIG_AUDITSYSCALL
|
||||
REG("loginuid", S_IWUSR|S_IRUGO, proc_loginuid_operations),
|
||||
|
|
Loading…
Reference in a new issue