mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Vincent Brillault <vincent.brillault@cern.ch>
To: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	Petr Mladek <pmladek@suse.com>,
	Andrey Ryabinin <aryabinin@virtuozzo.com>,
	Kees Cook <keescook@chromium.org>,
	Thierry Reding <treding@nvidia.com>,
	Geliang Tang <geliangtang@163.com>, Tejun Heo <tj@kernel.org>,
	Ivan Delalande <colona@arista.com>,
	<linux-kernel@vger.kernel.org>
Subject: Re: kernel/printk/printk.c: Invalid access when buffer wraps around?
Date: Sun, 31 Jul 2016 15:26:41 +0200	[thread overview]
Message-ID: <14d57dba-e293-11c2-67b2-18313a3a9b34@cern.ch> (raw)
In-Reply-To: <20160731084108.GA538@swordfish>


[-- Attachment #1.1: Type: text/plain, Size: 1155 bytes --]

Dear Sergey,

> sorry for long reply. do you see this in practice?

No, I've only thought of the bug will trying to adapt this code to build
a separate cyclic buffer in a dedicated kernel module.

> the first printk()->console_unlock() to notice `seen_seq != log_next_seq`
> will wakeup a task from log_wait, sleeping on
> 	wait_event_interruptible(seq != log_next_seq)

Yes, but a task could be not waiting to read reading while still having
open /dev/kmsg (e.g. after having read it in O_NONBLOCK)

> so I believe your assumption here is that we wrap around and then fill up
> the log_buf again without waking up the klogd even once, correct?
> 
> 	CPU0				CPU1
> 
> 	console_lock();
> 	printk();
> 	...				devkmsg_read();
> 	printk();
> 	console_unlock();
> 
> like the above?

Mmm, I did not think of such a case, which might be possible. I was more
thinking of a userland daemon reading the buffer (via /dev/kmsg) in
non-blocking mode and only pulling from time to time. I agree that this
is probably not seen often, which could explain why nobody can see it in
practice.

Thanks for your time,
Vincent Brillault


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

  reply	other threads:[~2016-07-31 13:42 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-07-25  9:22 Vincent Brillault
2016-07-31  8:41 ` Sergey Senozhatsky
2016-07-31 13:26   ` Vincent Brillault [this message]
2016-08-01 16:33 ` Ivan Delalande
2016-08-05  5:14   ` Vincent Brillault

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=14d57dba-e293-11c2-67b2-18313a3a9b34@cern.ch \
    --to=vincent.brillault@cern.ch \
    --cc=akpm@linux-foundation.org \
    --cc=aryabinin@virtuozzo.com \
    --cc=colona@arista.com \
    --cc=geliangtang@163.com \
    --cc=keescook@chromium.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pmladek@suse.com \
    --cc=sergey.senozhatsky@gmail.com \
    --cc=tj@kernel.org \
    --cc=treding@nvidia.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

all inboxes | Powered by JetHome®