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