1. 13 3月, 2020 13 次提交
  2. 12 3月, 2020 1 次提交
  3. 11 3月, 2020 9 次提交
  4. 10 3月, 2020 1 次提交
  5. 09 3月, 2020 12 次提交
  6. 07 3月, 2020 3 次提交
  7. 06 3月, 2020 1 次提交
    • M
      virthread: Free thread name only after worker has finished · 9b3b93c5
      Michal Privoznik 提交于
      When spawning a thread via our virThread APIs we let pthread
      spawn this helper thread which sets couple of thread local
      variables (e.g. thread job name or thread worker name) and as of
      v6.1.0-40-gc85256b3 it also sets pthread name (which is then
      visible in `ps' output for instance). Only after these steps the
      intended function is called. However, just before calling it we
      free the buffer that holds the thread name which results in
      invalid memory reads:
      
      ==47027== Invalid read of size 1
      ==47027==    at 0x48389C2: strlen (vg_replace_strmem.c:459)
      ==47027==    by 0x58BB3D6: __vfprintf_internal (vfprintf-internal.c:1645)
      ==47027==    by 0x58CE6E0: __vasprintf_internal (vasprintf.c:57)
      ==47027==    by 0x574BA28: g_vasprintf (in /usr/lib64/libglib-2.0.so.0.6000.7)
      ==47027==    by 0x57240CC: g_strdup_vprintf (in /usr/lib64/libglib-2.0.so.0.6000.7)
      ==47027==    by 0x48E0EFA: vir_g_strdup_vprintf (glibcompat.c:209)
      ==47027==    by 0x493AA05: virLogVMessage (virlog.c:573)
      ==47027==    by 0x493A8FE: virLogMessage (virlog.c:513)
      ==47027==    by 0x4992FC7: virThreadJobClear (virthreadjob.c:121)
      ==47027==    by 0x4992844: virThreadHelper (virthread.c:237)
      ==47027==    by 0x5817496: start_thread (pthread_create.c:486)
      ==47027==    by 0x59563CE: clone (clone.S:95)
      
      The problem is that neither virThreadJobSetWorker() nor
      virThreadJobSet() create a copy of passed name. They just set a
      thread local variable to point to the buffer which is then
      freed. Moving the free towards the end of the wrapper function
      solves the issue.
      Signed-off-by: NMichal Privoznik <mprivozn@redhat.com>
      Reviewed-by: NDaniel P. Berrangé <berrange@redhat.com>
      9b3b93c5