]> sourceware.org Git - systemtap.git/commitdiff
Fix PR19812 by translating vpid to host namespace pid.
authorMartin Cermak <mcermak@redhat.com>
Wed, 16 Mar 2016 13:26:10 +0000 (14:26 +0100)
committerMartin Cermak <mcermak@redhat.com>
Wed, 16 Mar 2016 13:26:10 +0000 (14:26 +0100)
Docker containers can use virtual pids, which need to get mapped to
host namespace pid in order to get the userspace probing working.

If the container is run with docker run --pid=host, then it uses
the host namespace pids and this translation is unnecessary.

runtime/transport/transport.c

index dc03ede91b23772ca9684898a74b3854b440383a..bbc61d25881dcac9e3d5925ddd72db97209c1002 100644 (file)
@@ -123,6 +123,10 @@ static struct timer_list _stp_ctl_work_timer;
 static void _stp_handle_start(struct _stp_msg_start *st)
 {
        int handle_startup;
+#if defined(CONFIG_USER_NS)
+       struct pid *_upid = NULL;
+       struct task_struct *_utask = NULL;
+#endif
 
         // protect against excessive or premature startup
        handle_startup = (! _stp_start_called && ! _stp_exit_called);
@@ -149,6 +153,30 @@ static void _stp_handle_start(struct _stp_msg_start *st)
 #endif
 
                _stp_target = st->target;
+
+#if defined(CONFIG_USER_NS)
+                rcu_read_lock();
+                _upid = find_vpid(_stp_target);
+                if (_upid)
+                {
+                    _utask = pid_task(_upid, PIDTYPE_PID);
+                    if (_utask)
+                    {
+                        #ifdef DEBUG_UPROBES
+                        _stp_dbug(__FUNCTION__,__LINE__, "translating vpid %d to pid %d\n", _stp_target, _utask->pid);
+                        #endif
+                        _stp_target = _utask->pid;
+                    }
+                }
+
+                #ifdef DEBUG_UPROBES
+                if (!_upid || !_utask)
+                    _stp_dbug(__FUNCTION__,__LINE__, "cannot map pid %d to host namespace pid\n", _stp_target);
+                #endif
+
+                rcu_read_unlock();
+#endif
+
                st->res = systemtap_module_init();
                if (st->res == 0) {
                        _stp_probes_started = 1;
This page took 0.028283 seconds and 5 git commands to generate.