diff options
author | Mike Chan | 2008-04-24 12:22:26 -0500 |
---|---|---|
committer | Arve Hjønnevåg | 2013-02-19 17:49:12 -0600 |
commit | a45703b6c9e8f9ea93cee430f39acae8970f9a3b (patch) | |
tree | a279a3fdcbba502c8c3028a1c9d7b779afa4cdfc /fs | |
parent | 2b545a8bed2054f1e7d6e4f9de5730c049208213 (diff) | |
download | kernel-common-a45703b6c9e8f9ea93cee430f39acae8970f9a3b.tar.gz kernel-common-a45703b6c9e8f9ea93cee430f39acae8970f9a3b.tar.xz kernel-common-a45703b6c9e8f9ea93cee430f39acae8970f9a3b.zip |
Grants system server access to /proc/<pid>/oom_adj for Android applications.
Signed-off-by: Brian Swetland <swetland@google.com>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/proc/base.c | 37 |
1 files changed, 36 insertions, 1 deletions
diff --git a/fs/proc/base.c b/fs/proc/base.c index 9b43ff77a51..7855743502b 100644 --- a/fs/proc/base.c +++ b/fs/proc/base.c | |||
@@ -137,6 +137,12 @@ struct pid_entry { | |||
137 | NULL, &proc_single_file_operations, \ | 137 | NULL, &proc_single_file_operations, \ |
138 | { .proc_show = show } ) | 138 | { .proc_show = show } ) |
139 | 139 | ||
140 | /* ANDROID is for special files in /proc. */ | ||
141 | #define ANDROID(NAME, MODE, OTYPE) \ | ||
142 | NOD(NAME, (S_IFREG|(MODE)), \ | ||
143 | &proc_##OTYPE##_inode_operations, \ | ||
144 | &proc_##OTYPE##_operations, {}) | ||
145 | |||
140 | /* | 146 | /* |
141 | * Count the number of hardlinks for the pid_entry table, excluding the . | 147 | * Count the number of hardlinks for the pid_entry table, excluding the . |
142 | * and .. links. | 148 | * and .. links. |
@@ -967,6 +973,35 @@ out: | |||
967 | return err < 0 ? err : count; | 973 | return err < 0 ? err : count; |
968 | } | 974 | } |
969 | 975 | ||
976 | static int oom_adjust_permission(struct inode *inode, int mask) | ||
977 | { | ||
978 | uid_t uid; | ||
979 | struct task_struct *p; | ||
980 | |||
981 | p = get_proc_task(inode); | ||
982 | if(p) { | ||
983 | uid = task_uid(p); | ||
984 | put_task_struct(p); | ||
985 | } | ||
986 | |||
987 | /* | ||
988 | * System Server (uid == 1000) is granted access to oom_adj of all | ||
989 | * android applications (uid > 10000) as and services (uid >= 1000) | ||
990 | */ | ||
991 | if (p && (current_fsuid() == 1000) && (uid >= 1000)) { | ||
992 | if (inode->i_mode >> 6 & mask) { | ||
993 | return 0; | ||
994 | } | ||
995 | } | ||
996 | |||
997 | /* Fall back to default. */ | ||
998 | return generic_permission(inode, mask); | ||
999 | } | ||
1000 | |||
1001 | static const struct inode_operations proc_oom_adj_inode_operations = { | ||
1002 | .permission = oom_adjust_permission, | ||
1003 | }; | ||
1004 | |||
970 | static const struct file_operations proc_oom_adj_operations = { | 1005 | static const struct file_operations proc_oom_adj_operations = { |
971 | .read = oom_adj_read, | 1006 | .read = oom_adj_read, |
972 | .write = oom_adj_write, | 1007 | .write = oom_adj_write, |
@@ -2559,7 +2594,7 @@ static const struct pid_entry tgid_base_stuff[] = { | |||
2559 | REG("cgroup", S_IRUGO, proc_cgroup_operations), | 2594 | REG("cgroup", S_IRUGO, proc_cgroup_operations), |
2560 | #endif | 2595 | #endif |
2561 | INF("oom_score", S_IRUGO, proc_oom_score), | 2596 | INF("oom_score", S_IRUGO, proc_oom_score), |
2562 | REG("oom_adj", S_IRUGO|S_IWUSR, proc_oom_adj_operations), | 2597 | ANDROID("oom_adj", S_IRUGO|S_IWUSR, oom_adj), |
2563 | REG("oom_score_adj", S_IRUGO|S_IWUSR, proc_oom_score_adj_operations), | 2598 | REG("oom_score_adj", S_IRUGO|S_IWUSR, proc_oom_score_adj_operations), |
2564 | #ifdef CONFIG_AUDITSYSCALL | 2599 | #ifdef CONFIG_AUDITSYSCALL |
2565 | REG("loginuid", S_IWUSR|S_IRUGO, proc_loginuid_operations), | 2600 | REG("loginuid", S_IWUSR|S_IRUGO, proc_loginuid_operations), |