From: Frank Ch. Eigler Date: Wed, 23 Dec 2009 02:53:39 +0000 (-0500) Subject: sdt.h semaphore: use get_user / put_user instead of __access_process_vm. X-Git-Tag: release-1.1~56^2~1 X-Git-Url: https://sourceware.org/git/?a=commitdiff_plain;h=93c8419165a7c651989cc344364b86695e1f142c;p=systemtap.git sdt.h semaphore: use get_user / put_user instead of __access_process_vm. * translate.cxx (translate_pass): Don't #include * tapsets.cxx, tapset-utrace.cxx: Replace __access_process_vm() calls with get_user() / put_user() respectively. --- diff --git a/tapset-utrace.cxx b/tapset-utrace.cxx index cc4f28061..e3a6fd5be 100644 --- a/tapset-utrace.cxx +++ b/tapset-utrace.cxx @@ -949,14 +949,14 @@ utrace_derived_probe_group::emit_module_decls (systemtap_session& s) s.op->newline(-1) << "}"; // Before writing to the semaphore, we need to check for VM_WRITE access. - s.op->newline() << "if (p->sdt_sem_address != 0) {"; + s.op->newline() << "if (p->sdt_sem_address) {"; s.op->newline(1) << "size_t sdt_semaphore;"; // XXX p could get registered to more than one task! s.op->newline() << "p->tsk = tsk;"; - s.op->newline() << "if (__access_process_vm (tsk, p->sdt_sem_address, &sdt_semaphore, sizeof (sdt_semaphore), 0) == sizeof (sdt_semaphore)) {"; + s.op->newline() << "if (get_user (sdt_semaphore, (unsigned short __user *) p->sdt_sem_address) == 0) {"; s.op->newline(1) << "sdt_semaphore ++;"; - s.op->newline() << "__access_process_vm (tsk, p->sdt_sem_address, &sdt_semaphore, sizeof (sdt_semaphore), 1);"; + s.op->newline() << "put_user (sdt_semaphore, (unsigned short __user *) p->sdt_sem_address);"; s.op->newline(-1) << "}"; s.op->newline(-1) << "}"; s.op->newline(-1) << "}"; @@ -1043,18 +1043,14 @@ utrace_derived_probe_group::emit_module_decls (systemtap_session& s) s.op->newline(-1) << "}"; s.op->newline(-1) << "}"; - s.op->newline() << "if (p->sdt_sem_address) {"; + s.op->newline() << "if (p->sdt_sem_address && (vm_flags & VM_WRITE)) {"; s.op->newline(1) << "unsigned short sdt_semaphore = 0;"; // NB: fixed size - s.op->newline() << "if (__access_process_vm (tsk, p->sdt_sem_address, &sdt_semaphore, sizeof (sdt_semaphore), 0) == sizeof (sdt_semaphore)) {"; - - s.op->newline(1) << "if (vm_flags & VM_WRITE) {"; - s.op->indent(1); - s.op->newline() << "sdt_semaphore ++;"; + s.op->newline() << "if (get_user (sdt_semaphore, (unsigned short __user *) p->sdt_sem_address) == 0) {"; + s.op->newline(1) << "sdt_semaphore ++;"; s.op->newline() << "#ifdef DEBUG_UTRACE"; s.op->newline() << "_stp_dbug (__FUNCTION__,__LINE__, \"+semaphore %#x @ %#lx\\n\", sdt_semaphore, p->sdt_sem_address);"; s.op->newline() << "#endif"; - s.op->newline() << "__access_process_vm (tsk, p->sdt_sem_address, &sdt_semaphore, sizeof (sdt_semaphore), 1);"; - s.op->newline(-1) << "}"; + s.op->newline() << "put_user (sdt_semaphore, (unsigned short __user *) p->sdt_sem_address);"; s.op->newline(-1) << "}"; s.op->newline(-1) << "}"; s.op->newline() << "return 0;"; @@ -1134,9 +1130,9 @@ utrace_derived_probe_group::emit_module_exit (systemtap_session& s) s.op->newline() << "if (p->sdt_sem_address) {"; s.op->newline(1) << "size_t sdt_semaphore;"; // XXX p could get registered to more than one task! - s.op->newline() << "if (__access_process_vm (p->tsk, p->sdt_sem_address, &sdt_semaphore, sizeof (sdt_semaphore), 0) == sizeof (sdt_semaphore)) {"; + s.op->newline() << "if (get_user (sdt_semaphore, (unsigned short __user *) p->sdt_sem_address) == 0) {"; s.op->newline(1) << "sdt_semaphore --;"; - s.op->newline() << "__access_process_vm (p->tsk, p->sdt_sem_address, &sdt_semaphore, sizeof (sdt_semaphore), 1);"; + s.op->newline() << "put_user (sdt_semaphore, (unsigned short __user *) p->sdt_sem_address);"; s.op->newline(-1) << "}"; s.op->newline(-1) << "}"; s.op->newline(-1) << "}"; diff --git a/tapsets.cxx b/tapsets.cxx index e14cc496b..bac477610 100644 --- a/tapsets.cxx +++ b/tapsets.cxx @@ -4869,11 +4869,11 @@ uprobe_derived_probe_group::emit_module_decls (systemtap_session& s) s.op->newline() << "if (sdt_sem_address[spec_index]) {"; s.op->newline(1) << "unsigned short sdt_semaphore = 0;"; // NB: fixed size - s.op->newline() << "if ( __access_process_vm (tsk, sdt_sem_address[spec_index], &sdt_semaphore, sizeof (sdt_semaphore), 0)) {"; + s.op->newline() << "if (get_user (sdt_semaphore, (unsigned short __user*) sdt_sem_address[spec_index]) == 0) {"; // We have an executable or a writeable segment of a .so s.op->newline(1) << "if (vm_flags == 0 || vm_flags & VM_WRITE) {"; s.op->newline(1) << "sdt_semaphore ++;"; - s.op->newline() << "__access_process_vm (tsk, sdt_sem_address[spec_index], &sdt_semaphore, sizeof (sdt_semaphore), 1);"; + s.op->newline() << "put_user (sdt_semaphore, (unsigned short __user*) sdt_sem_address[spec_index]);"; s.op->newline(-1) << "}"; s.op->newline(-1) << "}"; // sdt_sem_address // XXX: error handling in __access_process_vm! @@ -5139,13 +5139,13 @@ uprobe_derived_probe_group::emit_module_exit (systemtap_session& s) s.op->newline() << "#endif /* 2.6.31 */"; s.op->newline() << "if (tsk) {"; // just in case the thing exited while we weren't watching - s.op->newline(1) << "if (__access_process_vm (tsk, sdt_sem_address[sup->spec_index], &sdt_semaphore, sizeof (sdt_semaphore), 0)) {"; + s.op->newline(1) << "if (get_user (sdt_semaphore, (unsigned short __user*) sdt_sem_address[sup->spec_index]) == 0) {"; s.op->newline(1) << "sdt_semaphore --;"; s.op->newline() << "#ifdef DEBUG_UPROBES"; s.op->newline() << "_stp_dbug (__FUNCTION__,__LINE__, \"-semaphore %#x @ %#lx\\n\", sdt_semaphore, sdt_sem_address[sup->spec_index]);"; s.op->newline() << "#endif"; - s.op->newline() << "(void) __access_process_vm (tsk, sdt_sem_address[sup->spec_index], &sdt_semaphore, sizeof (sdt_semaphore), 1);"; - s.op->newline(-1) << "}"; // access_process_vm + s.op->newline() << "put_user (sdt_semaphore, (unsigned short __user*) sdt_sem_address[sup->spec_index]);"; + s.op->newline(-1) << "}"; // XXX: error handling in __access_process_vm! // XXX: need to analyze possibility of race condition s.op->newline(-1) << "}"; diff --git a/translate.cxx b/translate.cxx index 81b8bef51..88e69a666 100644 --- a/translate.cxx +++ b/translate.cxx @@ -5238,7 +5238,6 @@ translate_pass (systemtap_session& s) s.op->newline() << "#include "; // s.op->newline() << "#include "; s.op->newline() << "#include \"loc2c-runtime.h\" "; - s.op->newline() << "#include \"access_process_vm.h\" "; s.up->emit_common_header (); // context etc.