]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
dtrace: Ensure that provider names are unique in the context of a PID
authorKris Van Hees <kris.van.hees@oracle.com>
Mon, 30 Sep 2013 13:19:20 +0000 (09:19 -0400)
committerKris Van Hees <kris.van.hees@oracle.com>
Mon, 30 Sep 2013 13:30:56 +0000 (09:30 -0400)
Orabug: 17476663

Signed-off-by: Kris Van Hees <kris.van.hees@oracle.com>
dtrace/dtrace_dof.c
dtrace/fasttrap_dev.c

index 08a2e43639a02099032fcf0060cf4d399d3ad8c2..ea9cfd1cebb0d620f6e61f88a3bb2a18368fede6 100644 (file)
@@ -1729,8 +1729,19 @@ static void dtrace_helper_provide_one(dof_helper_t *dhp, dof_sec_t *sec,
        dt_dbg_dof("    Creating provider %s for PID %d\n",
                   strtab + prov->dofpv_name, pid);
 
-       if ((parg = mops->dtms_provide_pid(meta->dtm_arg, &dhpv, pid)) == NULL)
+       /*
+        * This used to just 'return;' when parg is NULL, but that causes the
+        * cleanup code (dtrace_helper_provider_remove[_one]) to make a call
+        * to dtms_remove_pid() for a provider that never got created.
+        *
+        * If we fail to provide this provider, mark it as something to ignore,
+        * so we don't try to process it during cleanup.
+        */
+       parg = mops->dtms_provide_pid(meta->dtm_arg, &dhpv, pid);
+       if (parg == NULL) {
+               sec->dofs_type = DOF_SECT_NONE;
                return;
+       }
 
        meta->dtm_count++;
 
index bbcded659bd46a94deaa706b365f1124a6dad701..8325f08ed69115cbc23ee01122680b0af53c9ba7 100644 (file)
@@ -37,6 +37,8 @@
 #include "dtrace_dev.h"
 #include "fasttrap_impl.h"
 
+#define FIX_FORCE_UNIQUE_PROVNAME_PER_PID
+
 #define FASTTRAP_MAX_DEFAULT   250000
 static uint32_t                        fasttrap_max;
 static uint64_t                        fasttrap_pid_count;
@@ -1169,9 +1171,18 @@ static fasttrap_provider_t *fasttrap_provider_lookup(pid_t pid,
        for (fp = bucket->ftb_data; fp != NULL; fp = fp->ftp_next) {
                if (fp->ftp_pid == pid && strcmp(fp->ftp_name, name) == 0 &&
                    !fp->ftp_retired) {
+#ifdef FIX_FORCE_UNIQUE_PROVNAME_PER_PID
+                       /*
+                        * We disallow multiple providers with the same name
+                        * for a given PID.
+                        */
+                       mutex_unlock(&bucket->ftb_mtx);
+                       return NULL;
+#else
                        mutex_lock(&fp->ftp_mtx);
                        mutex_unlock(&bucket->ftb_mtx);
                        return fp;
+#endif
                }
        }