lkml.org 
[lkml]   [2010]   [Aug]   [23]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRe: [RFC PATCH v3] core_pattern: fix long parameters was truncated by core_pattern handler
Date
> On Fri, Aug 20, 2010 at 05:35:58PM +0800, Xiaotian Feng wrote:
> > We met a parameter truncated issue, consider following:
> > > echo "|/root/core_pattern_pipe_test %p /usr/libexec/blah-blah-blah \
> > %s %c %p %u %g 11 12345678901234567890123456789012345678 %t" > \
> > /proc/sys/kernel/core_pattern
> >
> > This is okay because the strings is less than CORENAME_MAX_SIZE.
> > "cat /proc/sys/kernel/core_pattern" shows the whole string. but
> > after we run core_pattern_pipe_test in man page, we found last
> > parameter was truncated like below:
> > argc[10]=<12807486>
> >
> > The root cause is core_pattern allows % specifiers, which need to be
> > replaced during parse time, but the replace may expand the strings
> > to larger than CORENAME_MAX_SIZE. So if the last parameter is %
> > specifiers, the replace code is using snprintf(out_ptr, out_end - out_ptr, ...),
> > this will write out of corename array.
> >
> > Changes since v2:
> > Introduced generic function cn_printf and make format_corename remember the time
> > has been expanded.
> >
> > Changes since v1:
> > This patch allocates corename at runtime, if the replace doesn't have enough
> > memory, expand the corename dynamically.
> >
> > Signed-off-by: Xiaotian Feng <dfeng@redhat.com>
> > Cc: Alexander Viro <viro@zeniv.linux.org.uk>
> > Cc: Andrew Morton <akpm@linux-foundation.org>
> > Cc: Oleg Nesterov <oleg@redhat.com>
> > Cc: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
> > Cc: Neil Horman <nhorman@tuxdriver.com>
> > Cc: Roland McGrath <roland@redhat.com>
> > ---
> > fs/exec.c | 180 ++++++++++++++++++++++++++++++++++++++++--------------------
> > 1 files changed, 120 insertions(+), 60 deletions(-)
> >
> This looks alot cleaner. Thanks!
> Reviewed-by: Neil Horman <nhorman@tuxdriver.com>
>

Unfortunatelly, I have no time to review deeply this one. but I see my test
works. Also, I'd like to say I like this one.

Thanks.





\
 
 \ /
  Last update: 2010-08-24 01:05    [W:0.113 / U:0.080 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site