makedumpfile: Read and process filter commands from config file.
Subsystems (3)
PATCH v2 5/8 makedumpfile: Read and process filter commands from config file.
From: Mahesh Salgaonkar <[email protected]>
This patch enables to makedumpfile to read and process filter commands from specified config file. It builds a list of filter info consisting of memory address (paddr) and size to be filtered out. This list is used during read_pfn() function to filter out user specified kernel data from vmcore before writing it to compressed DUMPFILE. The filtered memory locations are filled with 'X' (0x58) character.
The filter command syntax is:
erase <Symbol>[.member[...]] [size <SizeValue>[K|M]] erase <Symbol>[.member[...]] [size <SizeSymbol>] erase <Symbol>[.member[...]] [nullify]
Below are the examples how filter commands in config file look like:
erase modules
erase cred_jar.name size 10
erase vmlist.addr nullify
This is useful feature for the customers who wants to erase the customer sensitive data like security keys, in DUMPFILE before sending it to support team for analysis.
The man page for makedumpfile.conf(8) has been introduced that describes the config file format and erase command syntax.
Change in v2:
- Renamed filter.conf file to makedumpfile.conf
- Added cleanup routine clear_filter_info() to freeup memory allocated during gather_filter_info().
- Modified gather_filter_info() function to return error if process_config_file() can't open configuration file.
---
Makefile | 8 makedumpfile.c | 863 +++++++++++++++++++++++++++++++++++++++++++++++++++ makedumpfile.conf | 82 +++++ makedumpfile.conf.8 | 213 +++++++++++++ makedumpfile.h | 60 ++++ 5 files changed, 1225 insertions(+), 1 deletions(-) create mode 100644 makedumpfile.conf create mode 100644 makedumpfile.conf.8
Makefile +7 -1
@@ -37,12 +37,18 @@ makedumpfile: $(SRC) $(OBJ_ARCH) grep -v "^.TH MAKEDUMPFILE 8" makedumpfile.8 >> temp.8 mv temp.8 makedumpfile.8 gzip -c ./makedumpfile.8 > ./makedumpfile.8.gz + echo .TH FILTER.CONF 8 \"$(DATE)\" \"makedumpfile v$(VERSION)\" \"Linux System Administrator\'s Manual\" > temp.8 + grep -v "^.TH FILTER.CONF 8" makedumpfile.conf.8 >> temp.8 + mv temp.8 makedumpfile.conf.8 + gzip -c ./makedumpfile.conf.8 > ./makedumpfile.conf.8.gz clean: - rm -f $(OBJ) $(OBJ_ARCH) makedumpfile makedumpfile.8.gz + rm -f $(OBJ) $(OBJ_ARCH) makedumpfile makedumpfile.8.gz makedumpfile.conf.8.gz install: cp makedumpfile ${DESTDIR}/bin cp makedumpfile-R.pl ${DESTDIR}/bin cp makedumpfile.8.gz ${DESTDIR}/usr/share/man/man8 + cp makedumpfile.conf.8.gz ${DESTDIR}/usr/share/man/man8 + cp makedumpfile.conf ${DESTDIR}/etc/makedumpfile.conf.sample
makedumpfile.c +863 -0
921 lines not on this page · raw message
makedumpfile.conf new file +82 -0
82 lines not on this page · raw message
makedumpfile.conf.8 new file +213 -0
213 lines not on this page · raw message
makedumpfile.h +60 -0
72 lines not on this page · raw message
_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
Hi Mahesh,
Quoted 13 lines · On Wed, 18 May 2011 01:34:15 +0530 Mahesh J Salgaonkar…
This patch enables to makedumpfile to read and process filter commands from specified config file. It builds a list of filter info consisting of memory address (paddr) and size to be filtered out. This list is used during
read_pfn()function to filter out user specified kernel data from vmcore before writing it to compressed DUMPFILE. The filtered memory locations are filled with 'X' (0x58) character.The filter command syntax is:
erase <Symbol>[.member[...]] [size <SizeValue>[K|M]] erase <Symbol>[.member[...]] [size <SizeSymbol>] erase <Symbol>[.member[...]] [nullify]
Quoted 5 lines
Below are the examples how filter commands in config file look like:
erase modules
erase cred_jar.name size 10
erase vmlist.addr nullify
Thank you for the work.
I tested this feature by the above example, and confirmed the feature works fine. Nice work :-)
There are some comments in the below lines.
Can you check them ?
Quoted 79 lines
makedumpfile.c +79
-0+/* +* Read the non-terminal's which are in the form of <Symbol>[.member[...]] +*/ +struct config_entry * +create_config_entry (const char *token,unsigned short flag,int line) +{ +struct config_entry *ce =NULL , *ptr, *prev_ce; +char *str, *cur, *next; +long len; +int depth =0 ; + +if (!token) +return NULL ; + + cur = str =strdup (token); + prev_ce = ptr =NULL ; +while (cur !=NULL ) { +if ((next =strchr (cur,'.' )) !=NULL ) { + *next++ ='\0' ; + } +if (!strlen (cur)) { + cur = next; +continue ; + } + +if ((ptr =calloc (1 ,sizeof (struct config_entry ))) ==NULL ) { +ERRMSG ("Can't allocate memory for config_entry\n" ); + goto err_out; + } + ptr->line = line; + ptr->flag |= flag; +if (depth ==0 ) { +/* First node is always a symbol name */ + ptr->flag |=SYMBOL_ENTRY ; + } +if (flag &FILTER_ENTRY ) { + ptr->name =strdup (cur); + } +if (flag &SIZE_ENTRY ) { +char ch ='\0' ; +int n =0 ; +/* See if absolute length is provided */ +if ((depth ==0 ) && + ((n =sscanf (cur,"%zd%c" , &len, &ch)) >0 )) { +if (len <0 ) { +ERRMSG ("Config error at %d: size " +"value must be positive.\n" , + line); + goto err_out; + } + ptr->size = len; + ptr->flag |=ENTRY_RESOLVED ; +if (n ==2 ) { +/* Handle suffix. +* K = Kilobytes +* M = Megabytes +*/ +switch (ch) { +case 'M' : +case 'm' : + ptr->size *=1024 ; +case 'K' : +case 'k' : + ptr->size *=1024 ; +break ; + } + } + } +else + ptr->name =strdup (cur); + } +if (prev_ce) { + prev_ce->next = ptr; + prev_ce = ptr; + } +else + ce = prev_ce = ptr; + cur = next; + depth++;
makedumpfile.c load_module_symbols(void) · line 7907
Quoted 10 lines
makedumpfile.c +10
-0+ ptr =NULL ; + } +free (str); +return ce; + +err_out: +if (ce) +free_config_entry (ce); +if (ptr) +free_config_entry (ptr);
"free(str);" is necessary.
Quoted 2 lines
(quoted diff) +2
-0+ return NULL; +}
[..]
Quoted 24 lines
makedumpfile.c +24
-0+/* +* read filter config file and return each string token. If the parameter +* expected_token is non-NULL, then return the current token if it matches +* with expected_token otherwise save the current token and return NULL. +* At start of every module section filter_config.new_section is set to 1 and +* subsequent function invocations return NULL untill filter_config.new_section +* is reset to 0 by passing @flag = CONFIG_NEW_CMD (0x02). +* +* Parameters: +* @expected_token INPUT +* Token string to match with currnet token. +* =NULL - return the current available token. +* +* @flag INPUT +* =0x01 - Skip to next module section. +* =0x02 - Treat the next token as next filter command and reset. +* +* @line OUTPUT +* Line number of current token in filter config file. +* +* @cur_mod OUTPUT +* Points to current module section name on non-NULL return value. +* +* @eof OUTPUT
makedumpfile.c load_module_symbols(void) · line 7952
Quoted 10 lines
makedumpfile.c +10
-0+* set to -1 when end of file is reached. +* set to -2 when end of section is reached. +*/ +static char * +get_config_token (char *expected_token,unsigned char flag,int *line, +char **cur_mod,int *eof) +{ +char *p; +struct filter_config *fc = &filter_config; +int skip = flag &CONFIG_SKIP_SECTION ;
CONFIG_SKIP_SECTION is used only here, and we need to fix get_config() for the readability. Please check my comment in get_config().
[..]
Quoted 4 lines
makedumpfile.c +4
-0+/* +* Configuration file 'makedumpfile.conf' contains filter commands. +* Every individual filter command is considered as a config entry. A config +* entry can be provided on a single line or multiple lines.
makedumpfile.c load_module_symbols(void) · line 8116
Quoted 10 lines
makedumpfile.c +10
-0+*/ +struct config * +get_config (int skip) +{ +struct config *config; +char *token =NULL ; +static int line_count =0 ; +char *cur_module =NULL ; +int eof =0 ; +unsigned char flag =CONFIG_NEW_CMD | skip;
We need to change the above:
unsigned char flag = CONFIG_NEW_CMD; if (skip) flag |= CONFIG_SKIP_SECTION;
Quoted 16 lines
makedumpfile.c +16
-0+ +if ((config =calloc (1 ,sizeof (struct config ))) ==NULL ) +return NULL ; + +if (get_config_token ("erase" , flag, &line_count, &cur_module, &eof)) { +if (cur_module) + config->module_name =strdup (cur_module); + +if (!read_filter_entry (config, line_count)) + goto err_out; + } +else { +if (!eof) { + token =get_config_token (NULL ,0 , &line_count, +NULL ,NULL ); + ERRMSG("Config error at %d: Invalid token '%s'.\n",
makedumpfile.c load_module_symbols(void) · line 8142
Quoted 10 lines
makedumpfile.c +10
-0+ line_count, token); + } + goto err_out; + } +return config; +err_out: +if (config) +free_config (config); +return NULL ; +}
BTW makedumpfile.c has become a large file which is bigger than 10KLine, and I will separate it to some files for the maintenance.
Thanks
Ken'ichi Ohmichi
_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
Hi Mahesh,
Quoted 3 lines · On Thu, 11 Aug 2011 11:07:16 +0900 "Ken'ichi Ohmichi"…
BTW
makedumpfile.chas become a large file which is bigger than 10KLine, and I will separate it to some files for the maintenance.
To shrink makedumpfile.c file, I made a prototype patch.
(commit 40f5724152047a12e4ac9db51d9f9e00e7a79ebe of filter-out-devel branch) And I'd like to see your opinion.
You added sym_in_module() call into get_symbol_addr() to look for module symbol. And I will move the call to resolve_config_entry() because I guess sym_in_module() is used only for resolve_config_entry():
@@ -8448,13 +7326,21 @@ resolve_config_entry(struct config_entry *ce, unsigned long long base_addr,
char *base_struct_name)
{
char buf[BUFSIZE + 1];+ unsigned long long symbol;
if (ce->flag & SYMBOL_ENTRY) {
/* find the symbol info */
if (!ce->name)
return FALSE;- ce->sym_addr = get_symbol_addr(ce->name);
+ /*
+ * If we are looking for module symbol then traverse through
+ * mod_st.modules for symbol lookup
+ */
+ if (sym_in_module(ce->name, &symbol))
+ ce->sym_addr = symbol;
+ else
+ ce->sym_addr = get_symbol_addr(ce->name);
if (!ce->sym_addr) {
ERRMSG("Config error at %d: Can't find symbol '%s'.\n",
ce->line, ce->name);---
Thanks
Ken'ichi Ohmichi
_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
Hi Mahesh,
Quoted 26 lines · On Thu, 11 Aug 2011 14:17:51 +0900 "Ken'ichi Ohmichi"…
Quoted 3 lines
BTW
makedumpfile.chas become a large file which is bigger than 10KLine, and I will separate it to some files for the maintenance.To shrink
makedumpfile.cfile, I made a prototype patch.
(commit40f5724152047a12e4ac9db51d9f9e00e7a79ebeof filter-out-devel branch) And I'd like to see your opinion.You added
sym_in_module()call intoget_symbol_addr()to look for module symbol. And I will move the call toresolve_config_entry()because I guesssym_in_module()is used only forresolve_config_entry():(quoted diff) +3
-1@@ -8448,13 +7326,21 @@ resolve_config_entry(struct config_entry *ce, unsigned long long base_addr, char *base_struct_name) { char buf[BUFSIZE + 1]; + unsigned long long symbol; if (ce->flag & SYMBOL_ENTRY) { /* find the symbol info */ if (!ce->name) return FALSE; - ce->sym_addr = get_symbol_addr(ce->name); + /* + * If we are looking for module symbol then traverse through
Review resolve_config_entry(struct config_entry *ce, unsigned long long base_addr,
Quoted 10 lines
(quoted diff) +6
-1+ * mod_st.modules for symbol lookup + */ + if (sym_in_module(ce->name, &symbol)) + ce->sym_addr = symbol; + else + ce->sym_addr = get_symbol_addr(ce->name); if (!ce->sym_addr) { ERRMSG("Config error at %d: Can't find symbol '%s'.\n", ce->line, ce->name); ---
Sorry, the above mail is not clear.
My question is,
Do you think this change is right ?
Thanks
Ken'ichi Ohmichi
_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
Quoted 37 lines · Ken'ichi Ohmichi
Hi Mahesh,
Quoted 32 lines · On Thu, 11 Aug 2011 14:17:51 +0900 "Ken'ichi Ohmichi"…
Quoted 3 lines
BTW
makedumpfile.chas become a large file which is bigger than 10KLine, and I will separate it to some files for the maintenance.To shrink
makedumpfile.cfile, I made a prototype patch.
(commit40f5724152047a12e4ac9db51d9f9e00e7a79ebeof filter-out-devel branch) And I'd like to see your opinion.You added
sym_in_module()call intoget_symbol_addr()to look for module symbol. And I will move the call toresolve_config_entry()because I guesssym_in_module()is used only forresolve_config_entry():(quoted diff) +9
-1@@ -8448,13 +7326,21 @@ resolve_config_entry(struct config_entry *ce, unsigned long long base_addr, char *base_struct_name) { char buf[BUFSIZE + 1]; + unsigned long long symbol; if (ce->flag & SYMBOL_ENTRY) { /* find the symbol info */ if (!ce->name) return FALSE; - ce->sym_addr = get_symbol_addr(ce->name); + /* + * If we are looking for module symbol then traverse through + * mod_st.modules for symbol lookup + */ + if (sym_in_module(ce->name, &symbol)) + ce->sym_addr = symbol; + else + ce->sym_addr = get_symbol_addr(ce->name);
Quoted 8 lines
Review resolve_config_entry(struct config_entry *ce, unsigned long long base_addr,
Quoted 4 lines
(quoted diff) +0
-1if (!ce->sym_addr) { ERRMSG("Config error at %d: Can't find symbol '%s'.\n", ce->line, ce->name); ---Sorry, the above mail is not clear.
My question is,
Do you think this change is right ?
My intention was to hide it under get_symbol_addr(). But yes, since it's only used by resolve_config_entry() we can safely move it there.
Thanks,
-Mahesh.
Signature · 6 lines
Mahesh J Salgaonkar _______________________________________________ kexec mailing list [email protected] http://lists.infradead.org/mailman/listinfo/kexec
Hi Mahesh,
Quoted 41 lines · On Thu, 11 Aug 2011 17:21:24 +0530 Mahesh J Salgaonkar…
Quoted 32 lines
Quoted 32 lines
Quoted 3 lines
BTW
makedumpfile.chas become a large file which is bigger than 10KLine, and I will separate it to some files for the maintenance.To shrink
makedumpfile.cfile, I made a prototype patch.
(commit40f5724152047a12e4ac9db51d9f9e00e7a79ebeof filter-out-devel branch) And I'd like to see your opinion.You added
sym_in_module()call intoget_symbol_addr()to look for module symbol. And I will move the call toresolve_config_entry()because I guesssym_in_module()is used only forresolve_config_entry():(quoted diff) +9
-1@@ -8448,13 +7326,21 @@ resolve_config_entry(struct config_entry *ce, unsigned long long base_addr, char *base_struct_name) { char buf[BUFSIZE + 1]; + unsigned long long symbol; if (ce->flag & SYMBOL_ENTRY) { /* find the symbol info */ if (!ce->name) return FALSE; - ce->sym_addr = get_symbol_addr(ce->name); + /* + * If we are looking for module symbol then traverse through + * mod_st.modules for symbol lookup + */ + if (sym_in_module(ce->name, &symbol)) + ce->sym_addr = symbol; + else + ce->sym_addr = get_symbol_addr(ce->name);Quoted 8 lines
Review resolve_config_entry(struct config_entry *ce, unsigned long long base_addr,
Quoted 4 lines
(quoted diff) +0
-1if (!ce->sym_addr) { ERRMSG("Config error at %d: Can't find symbol '%s'.\n", ce->line, ce->name); ---Sorry, the above mail is not clear.
My question is,
Do you think this change is right ?
Quoted 2 lines
My intention was to hide it under
get_symbol_addr(). But yes, since it's only used byresolve_config_entry()we can safely move it there.
Thank you for checkint it.
makedumpfile.c file has been shrunk from 10KLines to 9KLines, and I will make the file small more.
Thanks
Ken'ichi Ohmichi
_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
Quoted 6 lines · Ken'ichi Ohmichi
Hi Mahesh,
Quoted 1 line · On Thu, 11 Aug 2011 11:07:16 +0900 "Ken'ichi Ohmichi"…
Quoted 7 lines
Quoted 2 lines
BTW
makedumpfile.chas become a large file which is bigger than 10KLine, and I will separate it to some files for the maintenance.To shrink
makedumpfile.cfile, I made a prototype patch.
(commit40f5724152047a12e4ac9db51d9f9e00e7a79ebeof filter-out-devel branch) And I'd like to see your opinion.
I like the idea. The prototype patch looks good. I think we can even separate out the module symbol load/clean up functions including all associated functions out of makedumpfile.c. What do you think?
Thanks,
-Mahesh.
Signature · 6 lines
Mahesh J Salgaonkar _______________________________________________ kexec mailing list [email protected] http://lists.infradead.org/mailman/listinfo/kexec
Hi Mahesh,
Quoted 4 lines · On Thu, 11 Aug 2011 17:33:48 +0530 Mahesh J Salgaonkar…
Quoted 4 lines
Quoted 3 lines
BTW
makedumpfile.chas become a large file which is bigger than 10KLine, and I will separate it to some files for the maintenance.
Quoted 8 lines
Quoted 4 lines
To shrink
makedumpfile.cfile, I made a prototype patch.
(commit40f5724152047a12e4ac9db51d9f9e00e7a79ebeof filter-out-devel branch) And I'd like to see your opinion.I like the idea. The prototype patch looks good. I think we can even separate out the module symbol load/clean up functions including all associated functions out of
makedumpfile.c. What do you think?
Yes.
I think it is a good direction that we separete out the module symbol load code, which is added by you, from makedumpfile.c.
And I will try it.
Thanks
Ken'ichi Ohmichi
_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
Hi Ken'ichi,
Quoted 20 lines · Ken'ichi Ohmichi
Hi Mahesh,
Quoted 15 lines · On Wed, 18 May 2011 01:34:15 +0530 Mahesh J Salgaonkar…
This patch enables to makedumpfile to read and process filter commands from specified config file. It builds a list of filter info consisting of memory address (paddr) and size to be filtered out. This list is used during
read_pfn()function to filter out user specified kernel data from vmcore before writing it to compressed DUMPFILE. The filtered memory locations are filled with 'X' (0x58) character.The filter command syntax is:
erase <Symbol>[.member[...]] [size <SizeValue>[K|M]] erase <Symbol>[.member[...]] [size <SizeSymbol>] erase <Symbol>[.member[...]] [nullify]Below are the examples how filter commands in config file look like:
Quoted 7 lines
Quoted 3 lines
erase modules
erase cred_jar.name size 10
erase vmlist.addr nullifyThank you for the work.
I tested this feature by the above example, and confirmed the feature works fine. Nice work :-)
Thanks :-)
Quoted 87 lines
There are some comments in the below lines.
Can you check them ?Quoted 83 lines
makedumpfile.c +83
-0+/* +* Read the non-terminal's which are in the form of <Symbol>[.member[...]] +*/ +struct config_entry * +create_config_entry (const char *token,unsigned short flag,int line) +{ +struct config_entry *ce =NULL , *ptr, *prev_ce; +char *str, *cur, *next; +long len; +int depth =0 ; + +if (!token) +return NULL ; + + cur = str =strdup (token); + prev_ce = ptr =NULL ; +while (cur !=NULL ) { +if ((next =strchr (cur,'.' )) !=NULL ) { + *next++ ='\0' ; + } +if (!strlen (cur)) { + cur = next; +continue ; + } + +if ((ptr =calloc (1 ,sizeof (struct config_entry ))) ==NULL ) { +ERRMSG ("Can't allocate memory for config_entry\n" ); + goto err_out; + } + ptr->line = line; + ptr->flag |= flag; +if (depth ==0 ) { +/* First node is always a symbol name */ + ptr->flag |=SYMBOL_ENTRY ; + } +if (flag &FILTER_ENTRY ) { + ptr->name =strdup (cur); + } +if (flag &SIZE_ENTRY ) { +char ch ='\0' ; +int n =0 ; +/* See if absolute length is provided */ +if ((depth ==0 ) && + ((n =sscanf (cur,"%zd%c" , &len, &ch)) >0 )) { +if (len <0 ) { +ERRMSG ("Config error at %d: size " +"value must be positive.\n" , + line); + goto err_out; + } + ptr->size = len; + ptr->flag |=ENTRY_RESOLVED ; +if (n ==2 ) { +/* Handle suffix. +* K = Kilobytes +* M = Megabytes +*/ +switch (ch) { +case 'M' : +case 'm' : + ptr->size *=1024 ; +case 'K' : +case 'k' : + ptr->size *=1024 ; +break ; + } + } + } +else + ptr->name =strdup (cur); + } +if (prev_ce) { + prev_ce->next = ptr; + prev_ce = ptr; + } +else + ce = prev_ce = ptr; + cur = next; + depth++; + ptr =NULL ; + } +free (str); +return ce;
Quoted 9 lines
makedumpfile.c load_module_symbols(void) · line 7907
Quoted 6 lines
makedumpfile.c +6
-0+ +err_out: +if (ce) +free_config_entry (ce); +if (ptr) +free_config_entry (ptr);"free(str);" is necessary.
Nice catch. Agree.
Quoted 62 lines
Quoted 2 lines
(quoted diff) +2
-0+ return NULL; +}[..]
Quoted 24 lines
makedumpfile.c +24
-0+/* +* read filter config file and return each string token. If the parameter +* expected_token is non-NULL, then return the current token if it matches +* with expected_token otherwise save the current token and return NULL. +* At start of every module section filter_config.new_section is set to 1 and +* subsequent function invocations return NULL untill filter_config.new_section +* is reset to 0 by passing @flag = CONFIG_NEW_CMD (0x02). +* +* Parameters: +* @expected_token INPUT +* Token string to match with currnet token. +* =NULL - return the current available token. +* +* @flag INPUT +* =0x01 - Skip to next module section. +* =0x02 - Treat the next token as next filter command and reset. +* +* @line OUTPUT +* Line number of current token in filter config file. +* +* @cur_mod OUTPUT +* Points to current module section name on non-NULL return value. +* +* @eof OUTPUT makedumpfile.c load_module_symbols(void) · line 7952
Quoted 10 lines
makedumpfile.c +10
-0+* set to -1 when end of file is reached. +* set to -2 when end of section is reached. +*/ +static char * +get_config_token (char *expected_token,unsigned char flag,int *line, +char **cur_mod,int *eof) +{ +char *p; +struct filter_config *fc = &filter_config; +int skip = flag &CONFIG_SKIP_SECTION ;
CONFIG_SKIP_SECTIONis used only here, and we need to fixget_config()for the readability. Please check my comment inget_config().[..]
Quoted 4 lines
makedumpfile.c +4
-0+/* +* Configuration file 'makedumpfile.conf' contains filter commands. +* Every individual filter command is considered as a config entry. A config +* entry can be provided on a single line or multiple lines. makedumpfile.c load_module_symbols(void) · line 8116
Quoted 10 lines
makedumpfile.c +10
-0+*/ +struct config * +get_config (int skip) +{ +struct config *config; +char *token =NULL ; +static int line_count =0 ; +char *cur_module =NULL ; +int eof =0 ; +unsigned char flag =CONFIG_NEW_CMD | skip;We need to change the above:
Quoted 4 lines
unsigned char flag = CONFIG_NEW_CMD; if (skip) flag |= CONFIG_SKIP_SECTION;
Agree.
Thanks,
-Mahesh.
_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
Hi Mahesh,
Thank you for checking the above also.
commit 92d2934f9e1694e7195d93f9816fbea8a657f05f fixes them.
Thanks
Ken'ichi Ohmichi
Quoted 202 lines · On Thu, 11 Aug 2011 17:03:06 +0530 Mahesh Jagannath Salgaonkar…
Hi Ken'ichi,
Quoted 20 lines · Ken'ichi Ohmichi
Hi Mahesh,
Quoted 15 lines · On Wed, 18 May 2011 01:34:15 +0530 Mahesh J Salgaonkar…
This patch enables to makedumpfile to read and process filter commands from specified config file. It builds a list of filter info consisting of memory address (paddr) and size to be filtered out. This list is used during
read_pfn()function to filter out user specified kernel data from vmcore before writing it to compressed DUMPFILE. The filtered memory locations are filled with 'X' (0x58) character.The filter command syntax is:
erase <Symbol>[.member[...]] [size <SizeValue>[K|M]] erase <Symbol>[.member[...]] [size <SizeSymbol>] erase <Symbol>[.member[...]] [nullify]Below are the examples how filter commands in config file look like:
Quoted 7 lines
Quoted 3 lines
erase modules
erase cred_jar.name size 10
erase vmlist.addr nullifyThank you for the work.
I tested this feature by the above example, and confirmed the feature works fine. Nice work :-)Thanks :-)
Quoted 87 lines
There are some comments in the below lines.
Can you check them ?Quoted 83 lines
makedumpfile.c +83
-0+/* +* Read the non-terminal's which are in the form of <Symbol>[.member[...]] +*/ +struct config_entry * +create_config_entry (const char *token,unsigned short flag,int line) +{ +struct config_entry *ce =NULL , *ptr, *prev_ce; +char *str, *cur, *next; +long len; +int depth =0 ; + +if (!token) +return NULL ; + + cur = str =strdup (token); + prev_ce = ptr =NULL ; +while (cur !=NULL ) { +if ((next =strchr (cur,'.' )) !=NULL ) { + *next++ ='\0' ; + } +if (!strlen (cur)) { + cur = next; +continue ; + } + +if ((ptr =calloc (1 ,sizeof (struct config_entry ))) ==NULL ) { +ERRMSG ("Can't allocate memory for config_entry\n" ); + goto err_out; + } + ptr->line = line; + ptr->flag |= flag; +if (depth ==0 ) { +/* First node is always a symbol name */ + ptr->flag |=SYMBOL_ENTRY ; + } +if (flag &FILTER_ENTRY ) { + ptr->name =strdup (cur); + } +if (flag &SIZE_ENTRY ) { +char ch ='\0' ; +int n =0 ; +/* See if absolute length is provided */ +if ((depth ==0 ) && + ((n =sscanf (cur,"%zd%c" , &len, &ch)) >0 )) { +if (len <0 ) { +ERRMSG ("Config error at %d: size " +"value must be positive.\n" , + line); + goto err_out; + } + ptr->size = len; + ptr->flag |=ENTRY_RESOLVED ; +if (n ==2 ) { +/* Handle suffix. +* K = Kilobytes +* M = Megabytes +*/ +switch (ch) { +case 'M' : +case 'm' : + ptr->size *=1024 ; +case 'K' : +case 'k' : + ptr->size *=1024 ; +break ; + } + } + } +else + ptr->name =strdup (cur); + } +if (prev_ce) { + prev_ce->next = ptr; + prev_ce = ptr; + } +else + ce = prev_ce = ptr; + cur = next; + depth++; + ptr =NULL ; + } +free (str); +return ce;Quoted 9 lines
makedumpfile.c load_module_symbols(void) · line 7907
Quoted 6 lines
makedumpfile.c +6
-0+ +err_out: +if (ce) +free_config_entry (ce); +if (ptr) +free_config_entry (ptr);"free(str);" is necessary.
Nice catch. Agree.
Quoted 62 lines
Quoted 2 lines
(quoted diff) +2
-0+ return NULL; +}[..]
Quoted 24 lines
makedumpfile.c +24
-0+/* +* read filter config file and return each string token. If the parameter +* expected_token is non-NULL, then return the current token if it matches +* with expected_token otherwise save the current token and return NULL. +* At start of every module section filter_config.new_section is set to 1 and +* subsequent function invocations return NULL untill filter_config.new_section +* is reset to 0 by passing @flag = CONFIG_NEW_CMD (0x02). +* +* Parameters: +* @expected_token INPUT +* Token string to match with currnet token. +* =NULL - return the current available token. +* +* @flag INPUT +* =0x01 - Skip to next module section. +* =0x02 - Treat the next token as next filter command and reset. +* +* @line OUTPUT +* Line number of current token in filter config file. +* +* @cur_mod OUTPUT +* Points to current module section name on non-NULL return value. +* +* @eof OUTPUT makedumpfile.c load_module_symbols(void) · line 7952
Quoted 10 lines
makedumpfile.c +10
-0+* set to -1 when end of file is reached. +* set to -2 when end of section is reached. +*/ +static char * +get_config_token (char *expected_token,unsigned char flag,int *line, +char **cur_mod,int *eof) +{ +char *p; +struct filter_config *fc = &filter_config; +int skip = flag &CONFIG_SKIP_SECTION ;
CONFIG_SKIP_SECTIONis used only here, and we need to fixget_config()for the readability. Please check my comment inget_config().[..]
Quoted 4 lines
makedumpfile.c +4
-0+/* +* Configuration file 'makedumpfile.conf' contains filter commands. +* Every individual filter command is considered as a config entry. A config +* entry can be provided on a single line or multiple lines. makedumpfile.c load_module_symbols(void) · line 8116
Quoted 10 lines
makedumpfile.c +10
-0+*/ +struct config * +get_config (int skip) +{ +struct config *config; +char *token =NULL ; +static int line_count =0 ; +char *cur_module =NULL ; +int eof =0 ; +unsigned char flag =CONFIG_NEW_CMD | skip;We need to change the above:
Quoted 4 lines
unsigned char flag = CONFIG_NEW_CMD; if (skip) flag |= CONFIG_SKIP_SECTION;Agree.
Quoted 7 lines
Thanks,
-Mahesh._______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec