forked from mirrors/linux
		
	dyndbg: refine export, rename to dynamic_debug_exec_queries()
commit4c0d77828d("dyndbg: export ddebug_exec_queries") had a few problems: - broken non DYNAMIC_DEBUG_CORE configs, sparse warning - the exported function modifies query string, breaks on RO strings. - func name follows internal convention, shouldn't be exposed as is. 1st is fixed in header with ifdefd function prototype or stub defn. Also remove an obsolete HAVE-symbol ifdef-comment, and add others. Fix others by wrapping existing internal function with a new one, named in accordance with module-prefix naming convention, before export hits v5.9.0. In new function, copy query string to a local buffer, so users can pass hard-coded/RO queries, and internal function can be used unchanged. Fixes:4c0d77828d("dyndbg: export ddebug_exec_queries") Signed-off-by: Jim Cromie <jim.cromie@gmail.com> Link: https://lore.kernel.org/r/20200831182210.850852-3-jim.cromie@gmail.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
		
							parent
							
								
									b52a95eac1
								
							
						
					
					
						commit
						a2d375eda7
					
				
					 2 changed files with 41 additions and 6 deletions
				
			
		|  | @ -49,6 +49,10 @@ struct _ddebug { | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| #if defined(CONFIG_DYNAMIC_DEBUG_CORE) | #if defined(CONFIG_DYNAMIC_DEBUG_CORE) | ||||||
|  | 
 | ||||||
|  | /* exported for module authors to exercise >control */ | ||||||
|  | int dynamic_debug_exec_queries(const char *query, const char *modname); | ||||||
|  | 
 | ||||||
| int ddebug_add_module(struct _ddebug *tab, unsigned int n, | int ddebug_add_module(struct _ddebug *tab, unsigned int n, | ||||||
| 				const char *modname); | 				const char *modname); | ||||||
| extern int ddebug_remove_module(const char *mod_name); | extern int ddebug_remove_module(const char *mod_name); | ||||||
|  | @ -105,7 +109,7 @@ void __dynamic_ibdev_dbg(struct _ddebug *descriptor, | ||||||
| 	static_branch_unlikely(&descriptor.key.dd_key_false) | 	static_branch_unlikely(&descriptor.key.dd_key_false) | ||||||
| #endif | #endif | ||||||
| 
 | 
 | ||||||
| #else /* !HAVE_JUMP_LABEL */ | #else /* !CONFIG_JUMP_LABEL */ | ||||||
| 
 | 
 | ||||||
| #define _DPRINTK_KEY_INIT | #define _DPRINTK_KEY_INIT | ||||||
| 
 | 
 | ||||||
|  | @ -117,7 +121,7 @@ void __dynamic_ibdev_dbg(struct _ddebug *descriptor, | ||||||
| 	unlikely(descriptor.flags & _DPRINTK_FLAGS_PRINT) | 	unlikely(descriptor.flags & _DPRINTK_FLAGS_PRINT) | ||||||
| #endif | #endif | ||||||
| 
 | 
 | ||||||
| #endif | #endif /* CONFIG_JUMP_LABEL */ | ||||||
| 
 | 
 | ||||||
| #define __dynamic_func_call(id, fmt, func, ...) do {	\ | #define __dynamic_func_call(id, fmt, func, ...) do {	\ | ||||||
| 	DEFINE_DYNAMIC_DEBUG_METADATA(id, fmt);		\ | 	DEFINE_DYNAMIC_DEBUG_METADATA(id, fmt);		\ | ||||||
|  | @ -172,10 +176,11 @@ void __dynamic_ibdev_dbg(struct _ddebug *descriptor, | ||||||
| 				   KERN_DEBUG, prefix_str, prefix_type,	\ | 				   KERN_DEBUG, prefix_str, prefix_type,	\ | ||||||
| 				   rowsize, groupsize, buf, len, ascii) | 				   rowsize, groupsize, buf, len, ascii) | ||||||
| 
 | 
 | ||||||
| #else | #else /* !CONFIG_DYNAMIC_DEBUG_CORE */ | ||||||
| 
 | 
 | ||||||
| #include <linux/string.h> | #include <linux/string.h> | ||||||
| #include <linux/errno.h> | #include <linux/errno.h> | ||||||
|  | #include <linux/printk.h> | ||||||
| 
 | 
 | ||||||
| static inline int ddebug_add_module(struct _ddebug *tab, unsigned int n, | static inline int ddebug_add_module(struct _ddebug *tab, unsigned int n, | ||||||
| 				    const char *modname) | 				    const char *modname) | ||||||
|  | @ -210,6 +215,13 @@ static inline int ddebug_dyndbg_module_param_cb(char *param, char *val, | ||||||
| 		print_hex_dump(KERN_DEBUG, prefix_str, prefix_type,	\ | 		print_hex_dump(KERN_DEBUG, prefix_str, prefix_type,	\ | ||||||
| 				rowsize, groupsize, buf, len, ascii);	\ | 				rowsize, groupsize, buf, len, ascii);	\ | ||||||
| 	} while (0) | 	} while (0) | ||||||
| #endif | 
 | ||||||
|  | static inline int dynamic_debug_exec_queries(const char *query, const char *modname) | ||||||
|  | { | ||||||
|  | 	pr_warn("kernel not built with CONFIG_DYNAMIC_DEBUG_CORE\n"); | ||||||
|  | 	return 0; | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | #endif /* !CONFIG_DYNAMIC_DEBUG_CORE */ | ||||||
| 
 | 
 | ||||||
| #endif | #endif | ||||||
|  |  | ||||||
|  | @ -525,7 +525,7 @@ static int ddebug_exec_query(char *query_string, const char *modname) | ||||||
|    last error or number of matching callsites.  Module name is either |    last error or number of matching callsites.  Module name is either | ||||||
|    in param (for boot arg) or perhaps in query string. |    in param (for boot arg) or perhaps in query string. | ||||||
| */ | */ | ||||||
| int ddebug_exec_queries(char *query, const char *modname) | static int ddebug_exec_queries(char *query, const char *modname) | ||||||
| { | { | ||||||
| 	char *split; | 	char *split; | ||||||
| 	int i, errs = 0, exitcode = 0, rc, nfound = 0; | 	int i, errs = 0, exitcode = 0, rc, nfound = 0; | ||||||
|  | @ -557,7 +557,30 @@ int ddebug_exec_queries(char *query, const char *modname) | ||||||
| 		return exitcode; | 		return exitcode; | ||||||
| 	return nfound; | 	return nfound; | ||||||
| } | } | ||||||
| EXPORT_SYMBOL_GPL(ddebug_exec_queries); | 
 | ||||||
|  | /**
 | ||||||
|  |  * dynamic_debug_exec_queries - select and change dynamic-debug prints | ||||||
|  |  * @query: query-string described in admin-guide/dynamic-debug-howto | ||||||
|  |  * @modname: string containing module name, usually &module.mod_name | ||||||
|  |  * | ||||||
|  |  * This uses the >/proc/dynamic_debug/control reader, allowing module | ||||||
|  |  * authors to modify their dynamic-debug callsites. The modname is | ||||||
|  |  * canonically struct module.mod_name, but can also be null or a | ||||||
|  |  * module-wildcard, for example: "drm*". | ||||||
|  |  */ | ||||||
|  | int dynamic_debug_exec_queries(const char *query, const char *modname) | ||||||
|  | { | ||||||
|  | 	int rc; | ||||||
|  | 	char *qry = kstrndup(query, PAGE_SIZE, GFP_KERNEL); | ||||||
|  | 
 | ||||||
|  | 	if (!query) | ||||||
|  | 		return -ENOMEM; | ||||||
|  | 
 | ||||||
|  | 	rc = ddebug_exec_queries(qry, modname); | ||||||
|  | 	kfree(qry); | ||||||
|  | 	return rc; | ||||||
|  | } | ||||||
|  | EXPORT_SYMBOL_GPL(dynamic_debug_exec_queries); | ||||||
| 
 | 
 | ||||||
| #define PREFIX_SIZE 64 | #define PREFIX_SIZE 64 | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
		Loading…
	
		Reference in a new issue
	
	 Jim Cromie
						Jim Cromie