lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20190626074718.n7fmxugeul3lyyq6@pathway.suse.cz>
Date:   Wed, 26 Jun 2019 09:47:18 +0200
From:   Petr Mladek <pmladek@...e.com>
To:     John Ogness <john.ogness@...utronix.de>
Cc:     Sergey Senozhatsky <sergey.senozhatsky.work@...il.com>,
        linux-kernel@...r.kernel.org,
        Peter Zijlstra <peterz@...radead.org>,
        Steven Rostedt <rostedt@...dmis.org>,
        Linus Torvalds <torvalds@...ux-foundation.org>,
        Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
        Andrea Parri <andrea.parri@...rulasolutions.com>,
        Thomas Gleixner <tglx@...utronix.de>,
        Sergey Senozhatsky <sergey.senozhatsky@...il.com>
Subject: Re: [RFC PATCH v2 1/2] printk-rb: add a new printk ringbuffer
 implementation

On Wed 2019-06-26 09:16:11, John Ogness wrote:
> On 2019-06-26, Sergey Senozhatsky <sergey.senozhatsky.work@...il.com> wrote:
> > [..]
> >> > CPU0								CPU1
> >> > printk(...)
> >> >  sz = vscprintf(NULL, "Comm %s\n", current->comm);
> >> > 								ia64_mca_modify_comm()
> >> > 								  snprintf(comm, sizeof(comm), "%s %d", current->comm, previous_current->pid);
> >> > 								  memcpy(current->comm, comm, sizeof(current->comm));
> >> >  if ((buf = prb_reserve(... sz))) {
> >> >    vscnprintf(buf, "Comm %s\n", current->comm);
> >> > 				^^^^^^^^^^^^^^ ->comm has changed.
> >> > 					       Nothing critical, we
> >> > 					       should not corrupt
> >> > 					       anything, but we will
> >> > 					       truncate ->comm if its
> >> > 					       new size is larger than
> >> > 					       what it used to be when
> >> > 					       we did vscprintf(NULL).
> >> >    prb_commit(...);
> >> >  }

Great catch.

> After we get a lockless ringbuffer that we are happy with, my next
> series to integrate the buffer into printk will again use the sprint_rb
> solution to avoid the issue discussed in this thread. Perhaps it would
> be best to continue this discussion after I've posted that series.

We should keep it in head. But I fully agree with postponing
the discussion.

I personally think that this is a corner case. I would start with
a simple vscprintf(NULL, ...) and vscprintf(reserved_buf, ...)
approach. We could always make it more complex when it causes
real life problems.

If the data might change under the hood then we have bigger
problems. For example, there might be a race when the trailing
"\0" has not been written yet.

Best Regards,
Petr

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ