Detect missing symbols used with kallsyms_lookup at compile time
authorMichael Jeanson <mjeanson@efficios.com>
Thu, 14 May 2020 17:47:35 +0000 (13:47 -0400)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Mon, 6 Jul 2020 21:27:07 +0000 (17:27 -0400)
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I19a9a31c386196899517899d861fe63611272139

include/wrapper/genhd.h
include/wrapper/irqdesc.h
include/wrapper/tracepoint.h
include/wrapper/uprobes.h
include/wrapper/vmalloc.h
include/wrapper/writeback.h
src/lttng-context-prio.c
src/wrapper/page_alloc.c
src/wrapper/splice.c

index 30fc5cea60ec75a8bb1b0cf38d7e0657d513e1fb..689803881dbb0f9a950c651d48aa4b9a11e83564 100644 (file)
@@ -32,6 +32,19 @@ struct class *wrapper_get_block_class(void)
        return ptr_block_class;
 }
 
+/*
+ * Canary function to check for 'block_class' at compile time.
+ *
+ * From 'include/linux/genhd.h':
+ *
+ *   extern struct class block_class;
+ */
+static inline
+struct class *__canary__get_block_class(void)
+{
+       return &block_class;
+}
+
 static inline
 struct device_type *wrapper_get_disk_type(void)
 {
@@ -45,6 +58,16 @@ struct device_type *wrapper_get_disk_type(void)
        return ptr_disk_type;
 }
 
+/*
+ * No canary for 'disk_type', it's only defined in 'block/genhd.c'.
+ *
+ * static inline
+ * struct device_type *__canary__get_disk_type(void)
+ * {
+ *     return &disk_type;
+ * }
+ */
+
 #else
 
 static inline
index d2032302dd922381f4bc596951d9e1165551772e..3c71c723a2b5085e0897cfbd1b4157879bb4584e 100644 (file)
 
 struct irq_desc *wrapper_irq_to_desc(unsigned int irq);
 
+/*
+ * Canary function to check for 'irq_to_desc()' at compile time.
+ *
+ * From 'include/linux/irqnr.h':
+ *
+ *   extern struct irq_desc *irq_to_desc(unsigned int irq);
+ */
+static inline
+struct irq_desc *__canary__irq_to_desc(unsigned int irq)
+{
+       return irq_to_desc(irq);
+}
+
 #endif /* _LTTNG_WRAPPER_IRQDESC_H */
index 880638b9d9f2ceb742b6618c4c07ed2d1e60d54e..9f631abdbd30010e56523e95c5dff8b143c43b57 100644 (file)
@@ -68,6 +68,17 @@ int wrapper_tracepoint_module_notify(struct notifier_block *nb,
        }
 }
 
+/*
+ * No canary for 'tracepoint_module_notify()', it's only defined in 'kernel/tracepoint.c'.
+ *
+ * static inline
+ * int __canary__tracepoint_module_notify(struct notifier_block *nb,
+ *             unsigned long val, struct module *mod)
+ * {
+ *     return tracepoint_module_notify(nb, val, mod);
+ * }
+ */
+
 #endif /* #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,15,0) && defined(CONFIG_MODULE_SIG)) */
 
 #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,15,0) && defined(CONFIG_MODULE_SIG) && defined(MODULE))
index d511850939a6212c9dfb28f8816bb14871aee9ab..8b745715ffcf17af51847f051b3f55a303f5e9c6 100644 (file)
@@ -52,6 +52,19 @@ int wrapper_uprobe_register(struct inode *inode, loff_t offset, struct uprobe_co
        }
 }
 
+/*
+ * Canary function to check for 'uprobe_register()' at compile time.
+ *
+ * From 'include/linux/uprobes.h':
+ *
+ *   extern int uprobe_register(struct inode *inode, loff_t offset, struct uprobe_consumer *uc);
+ */
+static inline
+int __canary__uprobe_register(struct inode *inode, loff_t offset, struct uprobe_consumer *uc)
+{
+       return uprobe_register(inode, offset, uc);
+}
+
 static inline
 void wrapper_uprobe_unregister(struct inode *inode, loff_t offset, struct uprobe_consumer *uc)
 {
@@ -66,6 +79,20 @@ void wrapper_uprobe_unregister(struct inode *inode, loff_t offset, struct uprobe
                 WARN_ON(1);
         }
 }
+
+/*
+ * Canary function to check for 'uprobe_unregister()' at compile time.
+ *
+ * From 'include/linux/uprobes.h':
+ *
+ *   extern void uprobe_unregister(struct inode *inode, loff_t offset, struct uprobe_consumer *uc);
+ */
+static inline
+int __canary__uprobe_unregister(struct inode *inode, loff_t offset, struct uprobe_consumer *uc)
+{
+       return uprobe_unregister(inode, offset, uc);
+}
+
 #endif
 #else
 /* Version <  3.5, before uprobe was added. */
index ff279bc1b7042fdb68abccf3844aa1010d2a215c..596fb9ed11a0885f3d9c388398dd607f1ec28ea1 100644 (file)
@@ -64,10 +64,23 @@ void wrapper_vmalloc_sync_mappings(void)
        }
 }
 
+/*
+ * Canary function to check for 'vmalloc_sync_mappings()' at compile time.
+ *
+ * From 'include/linux/vmalloc.h':
+ *
+ *   void vmalloc_sync_mappings(void);
+ */
+static inline
+void __canary__vmalloc_sync_mappings(void)
+{
+       vmalloc_sync_mappings();
+}
+
 #else /* #if (LINUX_VERSION_CODE >= KERNEL_VERSION(5,6,0)) */
 
 /*
- * Map vmalloc_sync_mappings to vmalloc_sync_all() on kernels before 5.7.
+ * Map vmalloc_sync_mappings to vmalloc_sync_all() on kernels before 5.6.
  */
 static inline
 void wrapper_vmalloc_sync_mappings(void)
@@ -89,6 +102,19 @@ void wrapper_vmalloc_sync_mappings(void)
        }
 }
 
+/*
+ * Canary function to check for 'vmalloc_sync_all()' at compile time.
+ *
+ * From 'include/linux/vmalloc.h':
+ *
+ *   void vmalloc_sync_all(void);
+ */
+static inline
+void __canary__vmalloc_sync_all(void)
+{
+       vmalloc_sync_all();
+}
+
 #endif /* #else #if (LINUX_VERSION_CODE >= KERNEL_VERSION(5,6,0)) */
 
 #else
@@ -204,6 +230,26 @@ void *__lttng_vmalloc_node_range(unsigned long size, unsigned long align,
        return __vmalloc(size, gfp_mask, prot);
 }
 
+/*
+ * Canary function to check for '__vmalloc_node_range()' at compile time.
+ *
+ * From 'include/linux/vmalloc.h':
+ *
+ *   extern void *__vmalloc_node_range(unsigned long size, unsigned long align,
+ *                           unsigned long start, unsigned long end, gfp_t gfp_mask,
+ *                           pgprot_t prot, unsigned long vm_flags, int node,
+ *                           const void *caller);
+ */
+static inline
+void *__canary____lttng_vmalloc_node_range(unsigned long size, unsigned long align,
+                       unsigned long start, unsigned long end, gfp_t gfp_mask,
+                       pgprot_t prot, unsigned long vm_flags, int node,
+                       const void *caller)
+{
+       return __vmalloc_node_range(size, align, start, end, gfp_mask, prot,
+                       vm_flags, node, caller);
+}
+
 /**
  * lttng_kvmalloc_node - attempt to allocate physically contiguous memory, but upon
  * failure, fall back to non-contiguous (vmalloc) allocation.
index e5f36c258534a211ba76d8b3a316c2dc4bdb3ce1..74b5482ca3b6957bc9b8fb17e250bb519e4619dd 100644 (file)
@@ -37,6 +37,20 @@ unsigned long wrapper_global_dirty_limit(void)
                return 0;
        }
 }
+
+/*
+ * Canary function to check for 'global_wb_domain' at compile time.
+ *
+ * From 'include/linux/writeback.h':
+ *
+ *   extern struct wb_domain global_wb_domain;
+ */
+static inline
+unsigned long __canary__global_wb_domain(void)
+{
+       return global_wb_domain.dirty_limit;
+}
+
 #else
 
 static unsigned long *global_dirty_limit_sym;
@@ -54,6 +68,20 @@ unsigned long wrapper_global_dirty_limit(void)
                return 0;
        }
 }
+
+/*
+ * Canary function to check for 'global_dirty_limit' at compile time.
+ *
+ * From 'include/linux/writeback.h':
+ *
+ *   extern unsigned long global_dirty_limit;
+ */
+static inline
+unsigned long __canary__global_dirty_limit(void)
+{
+       return global_dirty_limit;
+}
+
 #endif
 
 #else /* CONFIG_KALLSYMS_ALL */
index d300445546d443443f103a3f8607b96a3e6895ad..2a16ea87ce83f038c9c8f115b788a4f413c5754d 100644 (file)
@@ -29,6 +29,19 @@ int wrapper_task_prio_init(void)
        return 0;
 }
 
+/*
+ * Canary function to check for 'task_prio()' at compile time.
+ *
+ * From 'include/linux/sched.h':
+ *
+ *   extern int task_prio(const struct task_struct *p);
+ */
+__attribute__((unused)) static
+int __canary__task_prio(const struct task_struct *p)
+{
+       return task_prio(p);
+}
+
 static
 size_t prio_get_size(size_t offset)
 {
index 93504c993883244cb692ab192abef040148737d6..3994bf5730bd775bbe62f08a1c22c2b4c2cea134 100644 (file)
@@ -54,6 +54,25 @@ int wrapper_get_pfnblock_flags_mask_init(void)
 }
 EXPORT_SYMBOL_GPL(wrapper_get_pfnblock_flags_mask_init);
 
+/*
+ * Canary function to check for 'get_pfnblock_flags_mask()' at compile time.
+ *
+ * From 'include/linux/pageblock-flags.h':
+ *
+ *   unsigned long get_pfnblock_flags_mask(struct page *page,
+ *                                         unsigned long pfn,
+ *                                         unsigned long end_bitidx,
+ *                                         unsigned long mask);
+ */
+__attribute__((unused)) static
+unsigned long __canary__get_pfnblock_flags_mask(struct page *page,
+                                               unsigned long pfn,
+                                               unsigned long end_bitidx,
+                                               unsigned long mask)
+{
+       return get_pfnblock_flags_mask(page, pfn, end_bitidx, mask);
+}
+
 #else
 
 #include <linux/pageblock-flags.h>
index 33e3aaa53b9bb08fdd5857f16819e6775085e0ed..407c12db14fca8a3611ef74e901fd8771b5ec23e 100644 (file)
@@ -36,6 +36,21 @@ ssize_t wrapper_splice_to_pipe(struct pipe_inode_info *pipe,
        }
 }
 
+/*
+ * Canary function to check for 'splice_to_pipe()' at compile time.
+ *
+ * From 'include/linux/splice.h':
+ *
+ *   extern ssize_t splice_to_pipe(struct pipe_inode_info *,
+ *                                 struct splice_pipe_desc *spd);
+ */
+__attribute__((unused)) static
+ssize_t __canary__splice_to_pipe(struct pipe_inode_info *pipe,
+                               struct splice_pipe_desc *spd)
+{
+       return splice_to_pipe(pipe, spd);
+}
+
 #else
 
 #include <linux/fs.h>
This page took 0.02995 seconds and 4 git commands to generate.