Commit f64d04c0 authored by Michael Holzheu's avatar Michael Holzheu Committed by Martin Schwidefsky

[S390] s390dbf: Add description for usage of "%s" in sprintf events

Using "%s" in sprintf event functions is dangerous. This patch adds a short
description for this issue to the s390 debug feature documentation.
Signed-off-by: default avatarMichael Holzheu <holzheu@linux.vnet.ibm.com>
Signed-off-by: default avatarMartin Schwidefsky <schwidefsky@de.ibm.com>
parent 0c88ee5b
...@@ -495,6 +495,13 @@ and for each vararg a long value. So e.g. for a debug entry with a format ...@@ -495,6 +495,13 @@ and for each vararg a long value. So e.g. for a debug entry with a format
string plus two varargs one would need to allocate a (3 * sizeof(long)) string plus two varargs one would need to allocate a (3 * sizeof(long))
byte data area in the debug_register() function. byte data area in the debug_register() function.
IMPORTANT: Using "%s" in sprintf event functions is dangerous. You can only
use "%s" in the sprintf event functions, if the memory for the passed string is
available as long as the debug feature exists. The reason behind this is that
due to performance considerations only a pointer to the string is stored in
the debug feature. If you log a string that is freed afterwards, you will get
an OOPS when inspecting the debug feature, because then the debug feature will
access the already freed memory.
NOTE: If using the sprintf view do NOT use other event/exception functions NOTE: If using the sprintf view do NOT use other event/exception functions
than the sprintf-event and -exception functions. than the sprintf-event and -exception functions.
......
...@@ -167,6 +167,10 @@ debug_text_event(debug_info_t* id, int level, const char* txt) ...@@ -167,6 +167,10 @@ debug_text_event(debug_info_t* id, int level, const char* txt)
return debug_event_common(id,level,txt,strlen(txt)); return debug_event_common(id,level,txt,strlen(txt));
} }
/*
* IMPORTANT: Use "%s" in sprintf format strings with care! Only pointers are
* stored in the s390dbf. See Documentation/s390/s390dbf.txt for more details!
*/
extern debug_entry_t * extern debug_entry_t *
debug_sprintf_event(debug_info_t* id,int level,char *string,...) debug_sprintf_event(debug_info_t* id,int level,char *string,...)
__attribute__ ((format(printf, 3, 4))); __attribute__ ((format(printf, 3, 4)));
...@@ -206,7 +210,10 @@ debug_text_exception(debug_info_t* id, int level, const char* txt) ...@@ -206,7 +210,10 @@ debug_text_exception(debug_info_t* id, int level, const char* txt)
return debug_exception_common(id,level,txt,strlen(txt)); return debug_exception_common(id,level,txt,strlen(txt));
} }
/*
* IMPORTANT: Use "%s" in sprintf format strings with care! Only pointers are
* stored in the s390dbf. See Documentation/s390/s390dbf.txt for more details!
*/
extern debug_entry_t * extern debug_entry_t *
debug_sprintf_exception(debug_info_t* id,int level,char *string,...) debug_sprintf_exception(debug_info_t* id,int level,char *string,...)
__attribute__ ((format(printf, 3, 4))); __attribute__ ((format(printf, 3, 4)));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment