Commit f64d04c042193183c6dad98944ae2861b998e8b7

Authored by Michael Holzheu
Committed by Martin Schwidefsky
1 parent 0c88ee5b75

[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: Michael Holzheu <holzheu@linux.vnet.ibm.com>
Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>

Showing 2 changed files with 15 additions and 1 deletions Side-by-side Diff

Documentation/s390/s390dbf.txt
... ... @@ -495,6 +495,13 @@
495 495 string plus two varargs one would need to allocate a (3 * sizeof(long))
496 496 byte data area in the debug_register() function.
497 497  
  498 +IMPORTANT: Using "%s" in sprintf event functions is dangerous. You can only
  499 +use "%s" in the sprintf event functions, if the memory for the passed string is
  500 +available as long as the debug feature exists. The reason behind this is that
  501 +due to performance considerations only a pointer to the string is stored in
  502 +the debug feature. If you log a string that is freed afterwards, you will get
  503 +an OOPS when inspecting the debug feature, because then the debug feature will
  504 +access the already freed memory.
498 505  
499 506 NOTE: If using the sprintf view do NOT use other event/exception functions
500 507 than the sprintf-event and -exception functions.
arch/s390/include/asm/debug.h
... ... @@ -167,6 +167,10 @@
167 167 return debug_event_common(id,level,txt,strlen(txt));
168 168 }
169 169  
  170 +/*
  171 + * IMPORTANT: Use "%s" in sprintf format strings with care! Only pointers are
  172 + * stored in the s390dbf. See Documentation/s390/s390dbf.txt for more details!
  173 + */
170 174 extern debug_entry_t *
171 175 debug_sprintf_event(debug_info_t* id,int level,char *string,...)
172 176 __attribute__ ((format(printf, 3, 4)));
... ... @@ -206,7 +210,10 @@
206 210 return debug_exception_common(id,level,txt,strlen(txt));
207 211 }
208 212  
209   -
  213 +/*
  214 + * IMPORTANT: Use "%s" in sprintf format strings with care! Only pointers are
  215 + * stored in the s390dbf. See Documentation/s390/s390dbf.txt for more details!
  216 + */
210 217 extern debug_entry_t *
211 218 debug_sprintf_exception(debug_info_t* id,int level,char *string,...)
212 219 __attribute__ ((format(printf, 3, 4)));