public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Sven Schnelle <svens@linux.ibm.com>
To: John Ogness <john.ogness@linutronix.de>
Cc: Petr Mladek <pmladek@suse.com>,
	Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com>,
	Sergey Senozhatsky <sergey.senozhatsky@gmail.com>,
	Steven Rostedt <rostedt@goodmis.org>,
	Linus Torvalds <torvalds@linux-foundation.org>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] printk: fix buffer overflow potential for print_text()
Date: Sat, 23 Jan 2021 22:41:23 +0100	[thread overview]
Message-ID: <yt9d8s8je3gc.fsf@linux.ibm.com> (raw)
In-Reply-To: <yt9deeibe4ia.fsf@linux.ibm.com> (Sven Schnelle's message of "Sat, 23 Jan 2021 22:18:37 +0100")

Sven Schnelle <svens@linux.ibm.com> writes:

> John Ogness <john.ogness@linutronix.de> writes:
>
>> On 2021-01-22, Sven Schnelle <svens@linux.ibm.com> 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:  -> 00000000001B8814"  MVI     92001000 >> 000000000163F1CD     CC 2
>
> That's a watchpoint telling me that the code at 0x1b8814 wants to store
> one byte to 0x163f1cd, which is the second byte of console_drivers.
>
> gdb tells me about 0x1b8814:
>
> (gdb) list *(0x1b8814)
> 0x1b8814 is in record_print_text (/home/svens/ibmgit/linux/kernel/printk/printk.c:1402).
> 1397		 * If a buffer was provided, it will be terminated. Space for the
> 1398		 * string terminator is guaranteed to be available. The terminator is
> 1399		 * not counted in the return value.
> 1400		 */
> 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 the zero byte
in that case?

> 1403	
> 1404		return len;
> 1405	}
> 1406
>


  reply	other threads:[~2021-01-23 21:43 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-14 17:04 [PATCH] printk: fix buffer overflow potential for print_text() John Ogness
2021-01-15 12:04 ` Petr Mladek
2021-01-15 12:07   ` Petr Mladek
2021-01-19  0:44     ` Sergey Senozhatsky
2021-01-19  8:54       ` John Ogness
2021-01-19 10:29         ` Sergey Senozhatsky
2021-01-19 11:44           ` John Ogness
2021-01-19 12:22             ` Petr Mladek
2021-01-19 11:20       ` Petr Mladek
2021-01-15 14:16 ` John Ogness
2021-01-15 16:04   ` Petr Mladek
2021-01-22 21:21 ` Sven Schnelle
2021-01-22 23:42   ` John Ogness
2021-01-23 21:18     ` Sven Schnelle
2021-01-23 21:41       ` Sven Schnelle [this message]
2021-01-24  8:13         ` John Ogness
2021-01-24  8:59           ` Sven Schnelle
2021-02-26 17:19 ` Alexander Gordeev
2021-02-26 17:39   ` John Ogness

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=yt9d8s8je3gc.fsf@linux.ibm.com \
    --to=svens@linux.ibm.com \
    --cc=john.ogness@linutronix.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pmladek@suse.com \
    --cc=rostedt@goodmis.org \
    --cc=sergey.senozhatsky.work@gmail.com \
    --cc=sergey.senozhatsky@gmail.com \
    --cc=torvalds@linux-foundation.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox