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:26 +0000 (17:27 -0400)
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I19a9a31c386196899517899d861fe63611272139

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

index 367f7bd67ca04f7dbe89788417b8f807f5a60406..c786f5d312d644094da09479e61b9991a8e838f5 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 4eac2c1a14c62ed74a316a98ff4228f4478352da..98feb57bebde635fb11781209ca2871a8faafa0c 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 514d01626c99ccd0385073d0332d039d26acea39..ce7da2b481f36f59ec95e66e87273737a0f1e616 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 40998199a5bcfa9a85f3de78c2e3a0ae5fddec2e..2de24f9e07edc62daf1caae51824464f31eeb5ff 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 2ecc98f38bf706eea4ef476fc99c7b4ae85ae85e..282bd863e2cb849ec57ec4336c43539d7a495858 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>
index 08e8ccabff3eb910bf06b42f9c9fe54aa5cc55e3..c4ba01231766dd21e546d2ba90cd71d895590f5a 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 6ea9df189878bd48603dd86c3ab7bfa53d99a00e..d76a7881500f045e9deae61f9130dd3ce0c8d0be 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 e78d99bb199c18c83a7ec89923783059b0f8d60e..362054b162b9e80eab799ca9be66298a697bb068 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 646246621174011aea00ab8e6f353e101208b0c9..00d727cc3b0405713554275cd2997345cc7e0149 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 */
This page took 0.033927 seconds and 4 git commands to generate.