From: Sergey Senozhatsky <senozhatsky@chromium.org>
To: coverity-bot <keescook@chromium.org>
Cc: John Ogness <john.ogness@linutronix.de>,
Steven Rostedt <rostedt@goodmis.org>,
Sergey Senozhatsky <senozhatsky@chromium.org>,
Petr Mladek <pmladek@suse.com>,
linux-kernel@vger.kernel.org,
"Gustavo A. R. Silva" <gustavo@embeddedor.com>,
linux-next@vger.kernel.org, linux-hardening@vger.kernel.org
Subject: Re: Coverity: console_prepend_dropped(): Memory - corruptions
Date: Sat, 14 Jan 2023 19:14:29 +0900 [thread overview]
Message-ID: <Y8KAhaiZQOWTcfyF@google.com> (raw)
In-Reply-To: <202301131544.D9E804CCD@keescook>
On (23/01/13 15:46), coverity-bot wrote:
> *** CID 1530570: Memory - corruptions (OVERRUN)
> kernel/printk/printk.c:2738 in console_prepend_dropped()
> 2732 /* Truncate the message, but keep it terminated. */
> 2733 pmsg->outbuf_len = outbuf_sz - (len + 1);
> 2734 outbuf[pmsg->outbuf_len] = 0;
> 2735 }
> 2736
> 2737 memmove(outbuf + len, outbuf, pmsg->outbuf_len + 1);
> vvv CID 1530570: Memory - corruptions (OVERRUN)
> vvv Overrunning buffer pointed to by "scratchbuf" of 1024 bytes by passing it to a function which accesses it at byte offset 1998 using argument "len" (which evaluates to 1999). [Note: The source code implementation of the function has been overridden by a builtin model.]
> 2738 memcpy(outbuf, scratchbuf, len);
> 2739 pmsg->outbuf_len += len;
> 2740 }
> 2741 #else
> 2742 #define console_prepend_dropped(pmsg, dropped)
> 2743 #endif /* CONFIG_PRINTK */
[..]
> Human notes from Kees:
>
> I'm not sure how it got 1998, but I do see that snprintf() should
> probably be scnprintf(), otherwise "len" might be a lie (i.e. it'll hold
> what it WANTED to write, rather than what it actually wrote).
Cannot imagine how "** %lu printk messages dropped **\n" can expand into
1998 bytes. Does coverity have a "verbose" mode?
next prev parent reply other threads:[~2023-01-14 10:14 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-13 23:46 Coverity: console_prepend_dropped(): Memory - corruptions coverity-bot
2023-01-14 10:14 ` Sergey Senozhatsky [this message]
2023-01-16 16:35 ` Petr Mladek
2023-01-17 3:07 ` Sergey Senozhatsky
2023-01-17 7:10 ` John Ogness
2023-01-17 7:51 ` Sergey Senozhatsky
2023-01-17 11:20 ` Petr Mladek
2023-01-18 0:35 ` Sergey Senozhatsky
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=Y8KAhaiZQOWTcfyF@google.com \
--to=senozhatsky@chromium.org \
--cc=gustavo@embeddedor.com \
--cc=john.ogness@linutronix.de \
--cc=keescook@chromium.org \
--cc=linux-hardening@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-next@vger.kernel.org \
--cc=pmladek@suse.com \
--cc=rostedt@goodmis.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.