lkml.org 
[lkml]   [2018]   [Apr]   [10]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: s390: defective uses of va_arg in __debug_sprintf_event
On Fri 2018-04-06 12:08:43, Joe Perches wrote:
> And I found this when looking at another defect
> in debug_sprintf_event where a %p<foo> extension
> is unintentionally used via a string concatenation.
> as pointed out by Rasmus Villemoes
> ---
> arch/s390/kernel/perf_cpum_sf.c | 4 +---
> 1 file changed, 1 insertion(+), 3 deletions(-)
>
> diff --git a/arch/s390/kernel/perf_cpum_sf.c b/arch/s390/kernel/perf_cpum_sf.c
> index 1c9ddd7aa5ec..1c449a6f841a 100644
> --- a/arch/s390/kernel/perf_cpum_sf.c
> +++ b/arch/s390/kernel/perf_cpum_sf.c
> @@ -212,9 +212,7 @@ static int realloc_sampling_buffer(struct sf_buffer *sfb,
> * the sampling buffer origin.
> */
> if (sfb->sdbt != get_next_sdbt(tail)) {
> - debug_sprintf_event(sfdbg, 3, "realloc_sampling_buffer: "
> - "sampling buffer is not linked: origin=%p"
> - "tail=%p\n",
> + debug_sprintf_event(sfdbg, 3, "realloc_sampling_buffer: sampling buffer is not linked: origin=%p tail=%p\n",
> (void *) sfb->sdbt, (void *) tail);
> return -EINVAL;
> }

This concatenation fix is correct. %p has many possible specifiers.
The code takes a simple approach and substitute "%ptail" with the
pointer value. See the following code in vsnprintf():

case FORMAT_TYPE_PTR:
str = pointer(fmt, str, end, va_arg(args, void *),
spec);
while (isalnum(*fmt))
fmt++;
break;

We might debate if vsprintf() should handle this better. Anyway, there
is a missing space in the above debug_sprintf_event() call.

Joe, are you going to send this as a separate patch, your SOB, ...?

Best Regards,
Petr

\
 
 \ /
  Last update: 2018-04-10 16:36    [W:0.037 / U:0.600 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site