]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
dtrace: ensure pdata and sdt_tab handling works on module reload
authorKris Van Hees <kris.van.hees@oracle.com>
Mon, 23 May 2016 17:38:49 +0000 (10:38 -0700)
committerNick Alcock <nick.alcock@oracle.com>
Mon, 23 May 2016 21:52:40 +0000 (22:52 +0100)
The handling of the sdt_tab member in pdata caused crashes when the sdt
module was unloaded and then reloaded.  This member holds the trampolines
for SDT probe points in kernel modules, and is allocated when a module is
loaded and resides in modules-only address space).  This memory block was
incorrectly free'd from the sdt module code when sdt was unloaded.

This commit also adds verification that the anticipated trampoline max
size as used in the kernel is sufficient for what the sdt module needs.

This commit also adds verification (at runtime, with an assert) that the
reserved allocation to hold the pdata for a module is of a sufficient
size.

Orabug: 23331667
Signed-off-by: Kris Van Hees <kris.van.hees@oracle.com>
Acked-by: Nick Alcock <nick.alcock@oracle.com>
dtrace/dtrace_dev.c
dtrace/sdt_sparc64.c

index f512c3a30ef81d091b79ea8cf00b3274e1f7cae0..8d79da22d46b8415c8ffe51a48a9cc1f707c4d93 100644 (file)
@@ -21,7 +21,7 @@
  *
  * CDDL HEADER END
  *
- * Copyright 2010-2014 Oracle, Inc.  All rights reserved.
+ * Copyright 2010-2016 Oracle, Inc.  All rights reserved.
  * Use is subject to license terms.
  */
 
@@ -1385,6 +1385,12 @@ int dtrace_dev_init(void)
        int                     rc = 0;
        struct cred             *cred;
 
+       /*
+        * Sanity check to ensure that the memory allocated by the kernel is
+        * sufficient for what PDATA needs.
+        */
+       ASSERT(sizeof(dtrace_module_t) < DTRACE_PDATA_SIZE);
+
        /*
         * Register the device for the DTrace core.
         */
index 44d50f38b397fed099574e3ab20ce29a7501dd77..8fe02a0b08b655089e80f5c29186079e6224e0be 100644 (file)
@@ -21,7 +21,7 @@
  *
  * CDDL HEADER END
  *
- * Copyright 2010, 2011, 2012 Oracle, Inc.  All rights reserved.
+ * Copyright 2010-2016 Oracle, Inc.  All rights reserved.
  * Use is subject to license terms.
  */
 
@@ -61,7 +61,9 @@
  *     ret
  *      restore
  */
-#define SDT_TRAMP_SIZE         11
+#if SDT_TRAMP_SIZE < 11
+# error SDT_TRAMP_SIZE is less than the required 11 instructions.
+#endif
 
 #define SA(x)                  ((long)ALIGN((x), 4))
 #define MINFRAME               STACKFRAME_SZ
@@ -162,10 +164,6 @@ int sdt_provide_module_arch(void *arg, struct module *mp)
 
 void sdt_cleanup_module(void *dmy, struct module *mp)
 {
-       if (PDATA(mp)->sdt_tab) {
-               vfree(PDATA(mp)->sdt_tab);
-               PDATA(mp)->sdt_tab = NULL;
-       }
 }
 
 void sdt_enable_arch(sdt_probe_t *sdp, dtrace_id_t id, void *arg)
@@ -183,15 +181,6 @@ int sdt_dev_init_arch(void)
        return 0;
 }
 
-static void module_del_sdt_tab(void *dmy, struct module *mp)
-{
-       if (PDATA(mp)->sdt_tab) {
-               vfree(PDATA(mp)->sdt_tab);
-               PDATA(mp)->sdt_tab = NULL;
-       }
-}
-
 void sdt_dev_exit_arch(void)
 {
-       dtrace_for_each_module(module_del_sdt_tab, NULL);
 }