Return-path: Received: from kirsty.vergenet.net ([202.4.237.240]) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1WNYZN-0002vq-Ts for kexec@lists.infradead.org; Wed, 12 Mar 2014 02:06:58 +0000 Date: Wed, 12 Mar 2014 11:06:33 +0900 From: Simon Horman Subject: Re: [PATCH v2] vmcore-dmesg stack smashing happend in extreme case Message-ID: <20140312020633.GB14456@verge.net.au> References: <1394587622-16872-1-git-send-email-zzou@redhat.com> <20140312014215.GB5282@redhat.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20140312014215.GB5282@redhat.com> List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "kexec" Errors-To: kexec-bounces+dwmw2=twosheds.infradead.org@lists.infradead.org To: Vivek Goyal Cc: arthur , kexec@lists.infradead.org On Tue, Mar 11, 2014 at 09:42:15PM -0400, Vivek Goyal wrote: > On Wed, Mar 12, 2014 at 09:27:02AM +0800, arthur wrote: > > Description > > in dump_dmesg_structured() the out_buf size is 4096, and if the > > length is less than 4080( 4096-16 ) it won't really write out. > > Normally, after writing one or four chars to the out_buf, it will > > check the length of out_buf. But in extreme cases, 19 chars was > > written to the out_buf before checking the length. This may cause > > the stack corruption. If the length was 4079 (won't realy write out), > > and then write 19 chars to it. the out_buf will overflow. > > > > Solution > > Change 16 to 64 thus can make sure that always have 64bytes before > > moving to next records. why using 64 is that a long long int can take > > 20 bytes. so the length of timestamp can be 44 ('[','.',']',' ') in > > extreme case. > > > > Signed-off-by: arthur Please include your given and family name in the From address and Signed-off-by line unless you only have one name. > > --- > > Looks good to me. > > Acked-by: Vivek Goyal > > Thanks > Vivek > > > vmcore-dmesg/vmcore-dmesg.c | 2 +- > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > diff --git a/vmcore-dmesg/vmcore-dmesg.c b/vmcore-dmesg/vmcore-dmesg.c > > index 0345660..e15cd91 100644 > > --- a/vmcore-dmesg/vmcore-dmesg.c > > +++ b/vmcore-dmesg/vmcore-dmesg.c > > @@ -674,7 +674,7 @@ static void dump_dmesg_structured(int fd) > > else > > out_buf[len++] = c; > > > > - if (len >= OUT_BUF_SIZE - 16) { > > + if (len >= OUT_BUF_SIZE - 64) { > > write_to_stdout(out_buf, len); > > len = 0; > > } > > -- > > 1.8.4.2 > > > > > > _______________________________________________ > > kexec mailing list > > kexec@lists.infradead.org > > http://lists.infradead.org/mailman/listinfo/kexec > > _______________________________________________ > kexec mailing list > kexec@lists.infradead.org > http://lists.infradead.org/mailman/listinfo/kexec > _______________________________________________ kexec mailing list kexec@lists.infradead.org http://lists.infradead.org/mailman/listinfo/kexec