All of lore.kernel.org
 help / color / mirror / Atom feed
From: Kay Sievers <kay@vrfy.org>
To: Alan Cox <alan@lxorguk.ukuu.org.uk>
Cc: Greg KH <greg@kroah.com>, Jukka Ollila <jiiksteri@gmail.com>,
	linux-kernel@vger.kernel.org, jbeulich@novell.com
Subject: Re: Bug 44211 - /proc/kmsg does not (always) block for 1-byte reads
Date: Sun, 8 Jul 2012 15:06:20 +0200	[thread overview]
Message-ID: <CAPXgP11LwEdCg=iySj55mjV5=am-6rjx8VdasAFDU97AeH3iPg@mail.gmail.com> (raw)
In-Reply-To: <20120708135911.69fe9566@pyramind.ukuu.org.uk>

On Sun, Jul 8, 2012 at 2:59 PM, Alan Cox <alan@lxorguk.ukuu.org.uk> wrote:
>> The patch will not fix the underlying problem, but just make it behave
>> more like it was and allow partial message reads. This is a years old
>> problem, the net is full of bugreports of stuff going wrong with
>> running dd bs=1 on /proc/kmsg. It is a really stupid idea, and can not
>> work for many other reasons too. The interface can not safely be used
>> that way, it does not have the usual semantics, it always returned 0
>> for read() whenever it needed to.
>
> If you are breaking the semantics perhaps that should also get fixed ?

I hopefully just restored the old semantics now.

Fixing it properly would be a bigger code change, and it can't use the
far-too-simple tunneling through the syslog() syscall to feed
/proc/kmsg.

If the seq_file interface could be used, that would probably be the
best option, but I have no good idea how to make blocking reads, and
concurrent non-blocks work with the seq_file stuff.

This is how read() in /proc/kmsg works and it is not protected by a
lock or anything, and there is a not too small window between the
check and the action. Things just go wrong if there is more than a
single reader, but that was the case since forever.

static ssize_t kmsg_read(struct file *file, char __user *buf,
                         size_t count, loff_t *ppos)
{
        if ((file->f_flags & O_NONBLOCK) &&
            !do_syslog(SYSLOG_ACTION_SIZE_UNREAD, NULL, 0, SYSLOG_FROM_FILE))
                return -EAGAIN;
        return do_syslog(SYSLOG_ACTION_READ, buf, count, SYSLOG_FROM_FILE);
}

Thanks,
Kay

  reply	other threads:[~2012-07-08 13:06 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-07-06 17:45 Bug 44211 - /proc/kmsg does not (always) block for 1-byte reads Jukka Ollila
2012-07-06 17:55 ` Greg KH
2012-07-06 18:46   ` Jukka Ollila
2012-07-08 12:37   ` Kay Sievers
2012-07-08 12:59     ` Alan Cox
2012-07-08 13:06       ` Kay Sievers [this message]
2012-07-06 19:38 ` Regression " Alan Cox
2012-07-06 20:30   ` Linus Torvalds
2012-07-07 21:19     ` Kay Sievers
2012-07-08  2:09       ` Kay Sievers
2012-08-10 12:56       ` Jan Engelhardt
2012-07-06 22:05   ` Jukka Ollila
2012-07-06 22:09     ` Linus Torvalds
2012-07-08  0:33     ` Kay Sievers

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='CAPXgP11LwEdCg=iySj55mjV5=am-6rjx8VdasAFDU97AeH3iPg@mail.gmail.com' \
    --to=kay@vrfy.org \
    --cc=alan@lxorguk.ukuu.org.uk \
    --cc=greg@kroah.com \
    --cc=jbeulich@novell.com \
    --cc=jiiksteri@gmail.com \
    --cc=linux-kernel@vger.kernel.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.