From: Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com>
To: pierre Kuo <vichy.kuo@gmail.com>
Cc: pmladek@suse.com, sergey.senozhatsky@gmail.com,
rostedt@goodmis.org, linux-kernel@vger.kernel.org
Subject: Re: [RFC V2] printk: add warning while drop partial text in msg
Date: Tue, 1 Aug 2017 11:43:03 +0900 [thread overview]
Message-ID: <20170801024303.GA469@jagdpanzerIV.localdomain> (raw)
In-Reply-To: <1501421870-12042-1-git-send-email-vichy.kuo@gmail.com>
On (07/30/17 21:37), pierre Kuo wrote:
> If the buffer pass to msg_print_text is not big enough to put both all
> prefixes and log_text(msg), kernel will quietly break.
> That means the user may not have the chance to know whether the
> log_text(msg) is fully printed into buffer or not.
>
> In this patch, once above case happened, we try to calculate how many
> characters of log_text(msg) are dropped and add warning for debugging
> purpose.
[..]
Hello,
this is not the only place that can truncate the message.
vprintk_emit() can do so as well /* vscnprintf() */. but
I think we don't care that much. a user likely will notice
truncated messages. we report lost messages, because this
is a completely different sort of problem.
[..]
> @@ -1264,8 +1270,23 @@ static size_t msg_print_text(const struct printk_log *msg, bool syslog, char *bu
>
> if (buf) {
> if (print_prefix(msg, syslog, NULL) +
> - text_len + 1 >= size - len)
> + text_len + 1 >= size - len) {
> + /* below stores dropped characters
> + * related information in next msg
> + */
> + size_t drop_len;
> +
> + drop_len = scnprintf(drop_msg,
> + MAX_DROP_MSG_LENGTH,
> + "<%u characters dropped>",
> + (next) ?
> + (unsigned int)(text_size + next - text) :
> + (unsigned int)text_size);
> + drop_msg[drop_len] = 0;
> + log_store(msg->facility, msg->level, msg->flags,
> + 0, NULL, 0, drop_msg, strlen(drop_msg));
> break;
> + }
this change, most likely, will confuse people. because msg_print_text() is
called on a message that is being currently processed, which is not
necessarily the last message in the logbuf. for example, see console_unlock().
we do something like this:
while (console_seq != log_next_seq) {
msg = log_from_idx(console_idx);
msg_print_text(msg);
console_idx = log_next(console_idx);
console_seq++;
}
your log_store(), invoked from msg_print_text(), will append the error
message to the logbuf (tail), possibly far-far-far away from console_idx.
so your "characters dropped" warning will appear much later.
> len += print_prefix(msg, syslog, buf + len);
> memcpy(buf + len, text, text_len);
but more importantly, msg_print_text() is called from several places. and
can even be called from a user space, potentially triggering the same
"<characters dropped>" error log_store() over and over again, wiping out
the actually important kernel messages. which is
a) not nice
and
b) can be used to deliberately "hide" something really important.
so, no. sorry, I don't like this change.
-ss
next prev parent reply other threads:[~2017-08-01 2:42 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-07-30 13:37 [RFC V2] printk: add warning while drop partial text in msg pierre Kuo
2017-08-01 2:43 ` Sergey Senozhatsky [this message]
2017-08-10 16:26 ` pierre kuo
2017-08-10 16:55 ` pierre kuo
2017-08-16 9:21 ` Petr Mladek
2017-08-17 1:05 ` Sergey Senozhatsky
2017-09-12 6:07 ` pierre kuo
2017-09-18 9:39 ` Sergey Senozhatsky
2017-09-18 10:00 ` Joe Perches
2017-09-18 10:08 ` Sergey Senozhatsky
2017-09-27 13:59 ` pierre kuo
2017-09-30 3:14 ` Sergey Senozhatsky
2017-10-04 13:28 ` Petr Mladek
2017-10-17 17:10 ` pierre kuo
2017-10-18 1:07 ` Sergey Senozhatsky
2017-10-04 13:17 ` Petr Mladek
2017-10-17 17:07 ` pierre kuo
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=20170801024303.GA469@jagdpanzerIV.localdomain \
--to=sergey.senozhatsky.work@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=pmladek@suse.com \
--cc=rostedt@goodmis.org \
--cc=sergey.senozhatsky@gmail.com \
--cc=vichy.kuo@gmail.com \
/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