aboutsummaryrefslogtreecommitdiffstats
path: root/kernel
diff options
context:
space:
mode:
authorKawai, Hidehiro <hidehiro.kawai.ez@hitachi.com>2007-07-19 04:48:27 -0400
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-07-19 13:04:46 -0400
commit6c5d523826dc639df709ed0f88c5d2ce25379652 (patch)
treeef2fa8cb30266b3a9b047902794e78c583b099da /kernel
parent76fdbb25f963de5dc1e308325f0578a2f92b1c2d (diff)
coredump masking: reimplementation of dumpable using two flags
This patch changes mm_struct.dumpable to a pair of bit flags. set_dumpable() converts three-value dumpable to two flags and stores it into lower two bits of mm_struct.flags instead of mm_struct.dumpable. get_dumpable() behaves in the opposite way. [akpm@linux-foundation.org: export set_dumpable] Signed-off-by: Hidehiro Kawai <hidehiro.kawai.ez@hitachi.com> Cc: Alan Cox <alan@lxorguk.ukuu.org.uk> Cc: David Howells <dhowells@redhat.com> Cc: Hugh Dickins <hugh@veritas.com> Cc: Nick Piggin <nickpiggin@yahoo.com.au> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'kernel')
-rw-r--r--kernel/ptrace.c2
-rw-r--r--kernel/sys.c24
2 files changed, 13 insertions, 13 deletions
diff --git a/kernel/ptrace.c b/kernel/ptrace.c
index 4a1745f1dad..82a558b655d 100644
--- a/kernel/ptrace.c
+++ b/kernel/ptrace.c
@@ -142,7 +142,7 @@ static int may_attach(struct task_struct *task)
142 return -EPERM; 142 return -EPERM;
143 smp_rmb(); 143 smp_rmb();
144 if (task->mm) 144 if (task->mm)
145 dumpable = task->mm->dumpable; 145 dumpable = get_dumpable(task->mm);
146 if (!dumpable && !capable(CAP_SYS_PTRACE)) 146 if (!dumpable && !capable(CAP_SYS_PTRACE))
147 return -EPERM; 147 return -EPERM;
148 148
diff --git a/kernel/sys.c b/kernel/sys.c
index d40e40a9446..08562f41976 100644
--- a/kernel/sys.c
+++ b/kernel/sys.c
@@ -1036,7 +1036,7 @@ asmlinkage long sys_setregid(gid_t rgid, gid_t egid)
1036 return -EPERM; 1036 return -EPERM;
1037 } 1037 }
1038 if (new_egid != old_egid) { 1038 if (new_egid != old_egid) {
1039 current->mm->dumpable = suid_dumpable; 1039 set_dumpable(current->mm, suid_dumpable);
1040 smp_wmb(); 1040 smp_wmb();
1041 } 1041 }
1042 if (rgid != (gid_t) -1 || 1042 if (rgid != (gid_t) -1 ||
@@ -1066,13 +1066,13 @@ asmlinkage long sys_setgid(gid_t gid)
1066 1066
1067 if (capable(CAP_SETGID)) { 1067 if (capable(CAP_SETGID)) {
1068 if (old_egid != gid) { 1068 if (old_egid != gid) {
1069 current->mm->dumpable = suid_dumpable; 1069 set_dumpable(current->mm, suid_dumpable);
1070 smp_wmb(); 1070 smp_wmb();
1071 } 1071 }
1072 current->gid = current->egid = current->sgid = current->fsgid = gid; 1072 current->gid = current->egid = current->sgid = current->fsgid = gid;
1073 } else if ((gid == current->gid) || (gid == current->sgid)) { 1073 } else if ((gid == current->gid) || (gid == current->sgid)) {
1074 if (old_egid != gid) { 1074 if (old_egid != gid) {
1075 current->mm->dumpable = suid_dumpable; 1075 set_dumpable(current->mm, suid_dumpable);
1076 smp_wmb(); 1076 smp_wmb();
1077 } 1077 }
1078 current->egid = current->fsgid = gid; 1078 current->egid = current->fsgid = gid;
@@ -1103,7 +1103,7 @@ static int set_user(uid_t new_ruid, int dumpclear)
1103 switch_uid(new_user); 1103 switch_uid(new_user);
1104 1104
1105 if (dumpclear) { 1105 if (dumpclear) {
1106 current->mm->dumpable = suid_dumpable; 1106 set_dumpable(current->mm, suid_dumpable);
1107 smp_wmb(); 1107 smp_wmb();
1108 } 1108 }
1109 current->uid = new_ruid; 1109 current->uid = new_ruid;
@@ -1159,7 +1159,7 @@ asmlinkage long sys_setreuid(uid_t ruid, uid_t euid)
1159 return -EAGAIN; 1159 return -EAGAIN;
1160 1160
1161 if (new_euid != old_euid) { 1161 if (new_euid != old_euid) {
1162 current->mm->dumpable = suid_dumpable; 1162 set_dumpable(current->mm, suid_dumpable);
1163 smp_wmb(); 1163 smp_wmb();
1164 } 1164 }
1165 current->fsuid = current->euid = new_euid; 1165 current->fsuid = current->euid = new_euid;
@@ -1209,7 +1209,7 @@ asmlinkage long sys_setuid(uid_t uid)
1209 return -EPERM; 1209 return -EPERM;
1210 1210
1211 if (old_euid != uid) { 1211 if (old_euid != uid) {
1212 current->mm->dumpable = suid_dumpable; 1212 set_dumpable(current->mm, suid_dumpable);
1213 smp_wmb(); 1213 smp_wmb();
1214 } 1214 }
1215 current->fsuid = current->euid = uid; 1215 current->fsuid = current->euid = uid;
@@ -1254,7 +1254,7 @@ asmlinkage long sys_setresuid(uid_t ruid, uid_t euid, uid_t suid)
1254 } 1254 }
1255 if (euid != (uid_t) -1) { 1255 if (euid != (uid_t) -1) {
1256 if (euid != current->euid) { 1256 if (euid != current->euid) {
1257 current->mm->dumpable = suid_dumpable; 1257 set_dumpable(current->mm, suid_dumpable);
1258 smp_wmb(); 1258 smp_wmb();
1259 } 1259 }
1260 current->euid = euid; 1260 current->euid = euid;
@@ -1304,7 +1304,7 @@ asmlinkage long sys_setresgid(gid_t rgid, gid_t egid, gid_t sgid)
1304 } 1304 }
1305 if (egid != (gid_t) -1) { 1305 if (egid != (gid_t) -1) {
1306 if (egid != current->egid) { 1306 if (egid != current->egid) {
1307 current->mm->dumpable = suid_dumpable; 1307 set_dumpable(current->mm, suid_dumpable);
1308 smp_wmb(); 1308 smp_wmb();
1309 } 1309 }
1310 current->egid = egid; 1310 current->egid = egid;
@@ -1350,7 +1350,7 @@ asmlinkage long sys_setfsuid(uid_t uid)
1350 uid == current->suid || uid == current->fsuid || 1350 uid == current->suid || uid == current->fsuid ||
1351 capable(CAP_SETUID)) { 1351 capable(CAP_SETUID)) {
1352 if (uid != old_fsuid) { 1352 if (uid != old_fsuid) {
1353 current->mm->dumpable = suid_dumpable; 1353 set_dumpable(current->mm, suid_dumpable);
1354 smp_wmb(); 1354 smp_wmb();
1355 } 1355 }
1356 current->fsuid = uid; 1356 current->fsuid = uid;
@@ -1379,7 +1379,7 @@ asmlinkage long sys_setfsgid(gid_t gid)
1379 gid == current->sgid || gid == current->fsgid || 1379 gid == current->sgid || gid == current->fsgid ||
1380 capable(CAP_SETGID)) { 1380 capable(CAP_SETGID)) {
1381 if (gid != old_fsgid) { 1381 if (gid != old_fsgid) {
1382 current->mm->dumpable = suid_dumpable; 1382 set_dumpable(current->mm, suid_dumpable);
1383 smp_wmb(); 1383 smp_wmb();
1384 } 1384 }
1385 current->fsgid = gid; 1385 current->fsgid = gid;
@@ -2176,14 +2176,14 @@ asmlinkage long sys_prctl(int option, unsigned long arg2, unsigned long arg3,
2176 error = put_user(current->pdeath_signal, (int __user *)arg2); 2176 error = put_user(current->pdeath_signal, (int __user *)arg2);
2177 break; 2177 break;
2178 case PR_GET_DUMPABLE: 2178 case PR_GET_DUMPABLE:
2179 error = current->mm->dumpable; 2179 error = get_dumpable(current->mm);
2180 break; 2180 break;
2181 case PR_SET_DUMPABLE: 2181 case PR_SET_DUMPABLE:
2182 if (arg2 < 0 || arg2 > 1) { 2182 if (arg2 < 0 || arg2 > 1) {
2183 error = -EINVAL; 2183 error = -EINVAL;
2184 break; 2184 break;
2185 } 2185 }
2186 current->mm->dumpable = arg2; 2186 set_dumpable(current->mm, arg2);
2187 break; 2187 break;
2188 2188
2189 case PR_SET_UNALIGN: 2189 case PR_SET_UNALIGN: