|
|
f62d812 |
Allow threads other than the main thread to do introspection of files in
|
|
|
f62d812 |
proc without relying on read permissions. proc_pid_follow_link() calls
|
|
|
f62d812 |
proc_fd_access_allowed() which ultimately calls __ptrace_may_access().
|
|
|
f62d812 |
|
|
|
f62d812 |
Though this allows additional access to some proc files, we do not
|
|
|
f62d812 |
believe that this has any unintended security implications. However it
|
|
|
f62d812 |
probably needs to be looked at carefully.
|
|
|
f62d812 |
|
|
|
f62d812 |
The original problem was a thread of a process whose permissions were
|
|
|
f62d812 |
111 couldn't open its own /proc/self/exe This was interfering with a
|
|
|
f62d812 |
special purpose debugging tool. A simple reproducer is below.:
|
|
|
f62d812 |
|
|
|
f62d812 |
#include <pthread.h>
|
|
|
f62d812 |
#include <unistd.h>
|
|
|
f62d812 |
#include <stdio.h>
|
|
|
f62d812 |
#include <errno.h>
|
|
|
f62d812 |
#include <stdlib.h>
|
|
|
f62d812 |
#include <sys/types.h>
|
|
|
f62d812 |
|
|
|
f62d812 |
#define BUFSIZE 2048
|
|
|
f62d812 |
|
|
|
f62d812 |
void *thread_main(void *arg){
|
|
|
f62d812 |
char *str=(char*)arg;
|
|
|
f62d812 |
char buf[BUFSIZE];
|
|
|
f62d812 |
ssize_t len=readlink("/proc/self/exe", buf, BUFSIZE);
|
|
|
f62d812 |
if(len==-1)
|
|
|
f62d812 |
printf("/proc/self/exe in %s: %s\n", str,sys_errlist[errno]);
|
|
|
f62d812 |
else
|
|
|
f62d812 |
printf("/proc/self/exe in %s: OK\n", str);
|
|
|
f62d812 |
|
|
|
f62d812 |
return 0;
|
|
|
f62d812 |
}
|
|
|
f62d812 |
|
|
|
f62d812 |
int main(){
|
|
|
f62d812 |
pthread_t thread;
|
|
|
f62d812 |
|
|
|
f62d812 |
int retval=pthread_create( &thread, NULL, thread_main, "thread");
|
|
|
f62d812 |
if(retval!=0)
|
|
|
f62d812 |
exit(1);
|
|
|
f62d812 |
|
|
|
f62d812 |
thread_main("main");
|
|
|
f62d812 |
pthread_join(thread, NULL);
|
|
|
f62d812 |
|
|
|
f62d812 |
exit(0);
|
|
|
f62d812 |
}
|
|
|
f62d812 |
|
|
|
f62d812 |
Signed-off-by: Ben Woodard <woodard@redhat.com>
|
|
|
f62d812 |
Signed-off-by: Mark Grondona <mgrondona@llnl.gov>
|
|
|
f62d812 |
---
|
|
|
f62d812 |
kernel/ptrace.c | 2 +-
|
|
|
f62d812 |
1 file changed, 1 insertion(+), 1 deletion(-)
|
|
|
f62d812 |
|
|
|
f62d812 |
diff --git a/kernel/ptrace.c b/kernel/ptrace.c
|
|
|
f62d812 |
index acbd284..347c4c7 100644
|
|
|
f62d812 |
--- a/kernel/ptrace.c
|
|
|
f62d812 |
+++ b/kernel/ptrace.c
|
|
|
f62d812 |
diff -ruNp linux-3.8.4-103.fc17.noarch/kernel/ptrace.c linux-3.8.4-103.fc17.ptrace/kernel/ptrace.c
|
|
|
f62d812 |
--- linux-3.8.4-103.fc17.noarch/kernel/ptrace.c 2013-02-18 17:58:34.000000000 -0600
|
|
|
f62d812 |
+++ linux-3.8.4-103.fc17.ptrace/kernel/ptrace.c 2013-03-26 14:59:01.939396346 -0500
|
|
|
f62d812 |
@@ -234,7 +234,7 @@ static int __ptrace_may_access(struct ta
|
|
|
f62d812 |
*/
|
|
|
f62d812 |
int dumpable = 0;
|
|
|
f62d812 |
/* Don't let security modules deny introspection */
|
|
|
f62d812 |
- if (task == current)
|
|
|
f62d812 |
+ if (same_thread_group(task, current))
|
|
|
f62d812 |
return 0;
|
|
|
f62d812 |
rcu_read_lock();
|
|
|
f62d812 |
tcred = __task_cred(task);
|
|
|
f62d812 |
--
|
|
|
f62d812 |
1.8.1.4
|
|
|
f62d812 |
|
|
|
f62d812 |
--
|
|
|
f62d812 |
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
|
|
|
f62d812 |
the body of a message to majordomo@vger.kernel.org
|
|
|
f62d812 |
More majordomo info at http://vger.kernel.org/majordomo-info.html
|
|
|
f62d812 |
Please read the FAQ at http://www.tux.org/lkml/
|