Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1519941

Re: [PATCH v2 1/4] printk/NMI: Handle continuous lines and missing newline

From Petr Mladek <pmladek@suse.com>
Newsgroups linux.kernel
Subject Re: [PATCH v2 1/4] printk/NMI: Handle continuous lines and missing newline
Date 2016-11-11 19:10 +0100
Message-ID <sCoqZ-7IG-3@gated-at.bofh.it> (permalink)
References <sBAud-7n4-3@gated-at.bofh.it> <sBAud-7n4-7@gated-at.bofh.it> <sCnOh-7dZ-13@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On Fri 2016-11-11 12:28:51, Steven Rostedt wrote:
> On Wed,  9 Nov 2016 13:41:28 +0100
> Petr Mladek <pmladek@suse.com> wrote:
> 
> 
> >  /*
> > @@ -135,8 +170,8 @@ static void __printk_nmi_flush(struct irq_work *work)
> >  		__RAW_SPIN_LOCK_INITIALIZER(read_lock);
> >  	struct nmi_seq_buf *s = container_of(work, struct nmi_seq_buf, work);
> >  	unsigned long flags;
> > -	size_t len, size;
> > -	int i, last_i;
> > +	size_t len;
> > +	int i;
> >  
> >  	/*
> >  	 * The lock has two functions. First, one reader has to flush all
> > @@ -154,12 +189,14 @@ static void __printk_nmi_flush(struct irq_work *work)
> >  	/*
> >  	 * This is just a paranoid check that nobody has manipulated
> >  	 * the buffer an unexpected way. If we printed something then
> > -	 * @len must only increase.
> > +	 * @len must only increase. Also it should never overflow the
> > +	 * buffer size.
> >  	 */
> > -	if (i && i >= len) {
> > +	if ((i && i >= len) || len > sizeof(s->buffer)) {
> 
> What's wrong with using s->len? Isn't that what is inside the buffer?
> Couldn't just checking against the buffer size print garbage?

Note that this is not the classic seq_buf. It is struct nmi_seq_buf
where "len" is atomic_t and buffer is defined as
buffer[NMI_LOG_BUF_LEN].

It is just a paranoid check that should newer be true if the
implementation is correct. I believe that it makes sense as is.

Best Regards,
Petr

Back to linux.kernel | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

[PATCH v2 0/4] printk: Fixes and hardening related to KERN_CONT Petr Mladek <pmladek@suse.com> - 2016-11-09 13:50 +0100
  [PATCH v2 3/4] printk/btrfs: Handle more message headers Petr Mladek <pmladek@suse.com> - 2016-11-09 13:50 +0100
    Re: [PATCH v2 3/4] printk/btrfs: Handle more message headers David Sterba <dsterba@suse.cz> - 2016-11-10 14:30 +0100
    Re: [PATCH v2 3/4] printk/btrfs: Handle more message headers Steven Rostedt <rostedt@goodmis.org> - 2016-11-11 18:50 +0100
      Re: [PATCH v2 3/4] printk/btrfs: Handle more message headers Petr Mladek <pmladek@suse.com> - 2016-11-11 19:20 +0100
  [PATCH v2 2/4] printk/kdb: Handle more message headers Petr Mladek <pmladek@suse.com> - 2016-11-09 13:50 +0100
    Re: [PATCH v2 2/4] printk/kdb: Handle more message headers Steven Rostedt <rostedt@goodmis.org> - 2016-11-11 18:40 +0100
      Re: [PATCH v2 2/4] printk/kdb: Handle more message headers Petr Mladek <pmladek@suse.com> - 2016-11-11 19:20 +0100
  [PATCH v2 1/4] printk/NMI: Handle continuous lines and missing newline Petr Mladek <pmladek@suse.com> - 2016-11-09 13:50 +0100
    Re: [PATCH v2 1/4] printk/NMI: Handle continuous lines and missing  newline Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com> - 2016-11-11 01:30 +0100
    Re: [PATCH v2 1/4] printk/NMI: Handle continuous lines and missing  newline Steven Rostedt <rostedt@goodmis.org> - 2016-11-11 18:30 +0100
      Re: [PATCH v2 1/4] printk/NMI: Handle continuous lines and missing  newline Petr Mladek <pmladek@suse.com> - 2016-11-11 19:10 +0100

csiph-web