From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S936209AbcKKSOe (ORCPT ); Fri, 11 Nov 2016 13:14:34 -0500 Received: from mx2.suse.de ([195.135.220.15]:41207 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756892AbcKKSN3 (ORCPT ); Fri, 11 Nov 2016 13:13:29 -0500 Date: Fri, 11 Nov 2016 19:13:03 +0100 From: Petr Mladek To: Steven Rostedt Cc: Linus Torvalds , Joe Perches , Andrew Morton , Sergey Senozhatsky , Jason Wessel , Jaroslav Kysela , Takashi Iwai , Chris Mason , Josef Bacik , David Sterba , linux-kernel@vger.kernel.org Subject: Re: [PATCH v2 2/4] printk/kdb: Handle more message headers Message-ID: <20161111181302.GB2145@dhcp128.suse.cz> References: <1478695291-12169-1-git-send-email-pmladek@suse.com> <1478695291-12169-3-git-send-email-pmladek@suse.com> <20161111123513.7c4d70a6@gandalf.local.home> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20161111123513.7c4d70a6@gandalf.local.home> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri 2016-11-11 12:35:13, Steven Rostedt wrote: > On Wed, 9 Nov 2016 13:41:29 +0100 > Petr Mladek wrote: > > > diff --git a/include/linux/printk.h b/include/linux/printk.h > > index eac1af8502bb..a0859e169bc3 100644 > > --- a/include/linux/printk.h > > +++ b/include/linux/printk.h > > @@ -31,6 +31,14 @@ static inline const char *printk_skip_level(const char *buffer) > > return buffer; > > } > > > > +static inline const char *printk_skip_headers(const char *buffer) > > +{ > > + while (printk_get_level(buffer)) > > + buffer = printk_skip_level(buffer); > > Hmm, shouldn't there be a length passed in here. What happens if buffer > ends with a header. Can't this overflow? It is OK when the string has the trailing '\0'. This is the case here. Note that printk_skip_level() and printk_get_level() would have the same problem if only the first byte of the header fit the buffer. Best Regards, Petr