Re: [PATCH] printk: fix buffer overflow potential for print_text()

2021-02-26 Thread John Ogness
On 2021-02-26, Alexander Gordeev wrote: > I am seeing KASAN reporting incorrect 1-byte access in exactly > same location Sven has identified before. In case there no > fix for it yet, please see below what happens in case of pretty > large buffer - WARN_ONCE() invocation in my case. It looks

Re: [PATCH] printk: fix buffer overflow potential for print_text()

2021-02-26 Thread Alexander Gordeev
On Thu, Jan 14, 2021 at 06:10:12PM +0106, John Ogness wrote: > Before commit b6cf8b3f3312 ("printk: add lockless ringbuffer"), > msg_print_text() would only write up to size-1 bytes into the > provided buffer. Some callers expect this behavior and append > a terminator to returned string. In

Re: [PATCH] printk: fix buffer overflow potential for print_text()

2021-01-24 Thread Sven Schnelle
John Ogness writes: > Hi Sven, > > Thanks for the outstanding analysis! > > On 2021-01-23, Sven Schnelle wrote: >>> 1401if (buf_size > 0) >>> 1402text[len] = 0; >> >> I don't think i have really understood how all the printk magic works, >> but using

Re: [PATCH] printk: fix buffer overflow potential for print_text()

2021-01-24 Thread John Ogness
Hi Sven, Thanks for the outstanding analysis! On 2021-01-23, Sven Schnelle wrote: >> 1401 if (buf_size > 0) >> 1402 text[len] = 0; > > I don't think i have really understood how all the printk magic works, > but using r->text_buf[len] seems to be the correct place to put

Re: [PATCH] printk: fix buffer overflow potential for print_text()

2021-01-23 Thread Sven Schnelle
Sven Schnelle writes: > John Ogness writes: > >> On 2021-01-22, Sven Schnelle wrote: > I was able to reproduce it in a virtual machine where i have a few more > ways to debug. What i got was: > > 01: -> 001B8814" MVI 92001000 >> 0163F1CD CC 2 > > That's a watchpoint

Re: [PATCH] printk: fix buffer overflow potential for print_text()

2021-01-23 Thread Sven Schnelle
John Ogness writes: > On 2021-01-22, Sven Schnelle wrote: >> >> So somehow the pointer for console_drivers changes. >> >> I can't provide the normal kernel crash output as printk is no longer >> working, > > I don't understand what you mean here. The crash tool can dump the > printk buffer. > >

Re: [PATCH] printk: fix buffer overflow potential for print_text()

2021-01-22 Thread John Ogness
On 2021-01-22, Sven Schnelle wrote: > I'm seeing crashes on s390x with this patch while running the glibc > testsuite. The glibc test suite triggers a few FPU exceptions which > are printed to the kernel log by default. Looking at the crash dump, > i see that the console_drivers pointer seems to

Re: [PATCH] printk: fix buffer overflow potential for print_text()

2021-01-22 Thread Sven Schnelle
John Ogness writes: > Before commit b6cf8b3f3312 ("printk: add lockless ringbuffer"), > msg_print_text() would only write up to size-1 bytes into the > provided buffer. Some callers expect this behavior and append > a terminator to returned string. In particular: > >

Re: [PATCH] printk: fix buffer overflow potential for print_text()

2021-01-19 Thread Petr Mladek
On Tue 2021-01-19 12:50:47, John Ogness wrote: > On 2021-01-19, Sergey Senozhatsky wrote: > >>> John, how did you spot these problems? > >> > >> I am preparing my series to remove the logbuf_lock, which also > >> refactors and consolidates code from syslog_print_all() and > >>

Re: [PATCH] printk: fix buffer overflow potential for print_text()

2021-01-19 Thread John Ogness
On 2021-01-19, Sergey Senozhatsky wrote: >>> John, how did you spot these problems? >> >> I am preparing my series to remove the logbuf_lock, which also >> refactors and consolidates code from syslog_print_all() and >> kmsg_dump_get_buffer(). While testing/verifying my series, I noticed >> the

Re: [PATCH] printk: fix buffer overflow potential for print_text()

2021-01-19 Thread Petr Mladek
On Tue 2021-01-19 09:44:56, Sergey Senozhatsky wrote: > On (21/01/15 13:07), Petr Mladek wrote: > > On Fri 2021-01-15 13:04:37, Petr Mladek wrote: > > > On Thu 2021-01-14 18:10:12, John Ogness wrote: > > > > Before commit b6cf8b3f3312 ("printk: add lockless ringbuffer"), > > > > msg_print_text()

Re: [PATCH] printk: fix buffer overflow potential for print_text()

2021-01-19 Thread Sergey Senozhatsky
On (21/01/19 10:00), John Ogness wrote: > On 2021-01-19, Sergey Senozhatsky wrote: > > John, how did you spot these problems? > > I am preparing my series to remove the logbuf_lock, which also refactors > and consolidates code from syslog_print_all() and > kmsg_dump_get_buffer(). While

Re: [PATCH] printk: fix buffer overflow potential for print_text()

2021-01-19 Thread John Ogness
On 2021-01-19, Sergey Senozhatsky wrote: > John, how did you spot these problems? I am preparing my series to remove the logbuf_lock, which also refactors and consolidates code from syslog_print_all() and kmsg_dump_get_buffer(). While testing/verifying my series, I noticed the these oddities in

Re: [PATCH] printk: fix buffer overflow potential for print_text()

2021-01-18 Thread Sergey Senozhatsky
On (21/01/15 13:07), Petr Mladek wrote: > On Fri 2021-01-15 13:04:37, Petr Mladek wrote: > > On Thu 2021-01-14 18:10:12, John Ogness wrote: > > > Before commit b6cf8b3f3312 ("printk: add lockless ringbuffer"), > > > msg_print_text() would only write up to size-1 bytes into the > > > provided

Re: [PATCH] printk: fix buffer overflow potential for print_text()

2021-01-15 Thread Petr Mladek
On Fri 2021-01-15 15:22:03, John Ogness wrote: > Hi Petr, > > I noticed some minor errors in the commit log and comments... > > On 2021-01-14, John Ogness wrote: > > Before commit b6cf8b3f3312 ("printk: add lockless ringbuffer"), > > msg_print_text() > > Can you fixup the patch for the commit

Re: [PATCH] printk: fix buffer overflow potential for print_text()

2021-01-15 Thread John Ogness
Hi Petr, I noticed some minor errors in the commit log and comments... On 2021-01-14, John Ogness wrote: > Before commit b6cf8b3f3312 ("printk: add lockless ringbuffer"), > msg_print_text() The correct commit where the change was made is: 896fbe20b4e2333fb55 ("printk: use the lockless

Re: [PATCH] printk: fix buffer overflow potential for print_text()

2021-01-15 Thread Petr Mladek
On Fri 2021-01-15 13:04:37, Petr Mladek wrote: > On Thu 2021-01-14 18:10:12, John Ogness wrote: > > Before commit b6cf8b3f3312 ("printk: add lockless ringbuffer"), > > msg_print_text() would only write up to size-1 bytes into the > > provided buffer. Some callers expect this behavior and append >

Re: [PATCH] printk: fix buffer overflow potential for print_text()

2021-01-15 Thread Petr Mladek
On Thu 2021-01-14 18:10:12, John Ogness wrote: > Before commit b6cf8b3f3312 ("printk: add lockless ringbuffer"), > msg_print_text() would only write up to size-1 bytes into the > provided buffer. Some callers expect this behavior and append > a terminator to returned string. In particular: > >

[PATCH] printk: fix buffer overflow potential for print_text()

2021-01-14 Thread John Ogness
Before commit b6cf8b3f3312 ("printk: add lockless ringbuffer"), msg_print_text() would only write up to size-1 bytes into the provided buffer. Some callers expect this behavior and append a terminator to returned string. In particular: arch/powerpc/xmon/xmon.c:dump_log_buf()