public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: Yuanhan Liu <yuanhan.liu@linux.intel.com>
Cc: Fengguang Wu <wfg@linux.intel.com>, Kay Sievers <kay@vrfy.org>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/2] printk: use logbuf_mutex_lock to stop syslog_seq from going wild
Date: Sat, 16 Jun 2012 08:28:36 -0700	[thread overview]
Message-ID: <20120616152836.GB7914@kroah.com> (raw)
In-Reply-To: <20120616132832.GG2231@yliu-dev.sh.intel.com>

On Sat, Jun 16, 2012 at 09:28:32PM +0800, Yuanhan Liu wrote:
> On Sat, Jun 16, 2012 at 09:20:52PM +0800, Fengguang Wu wrote:
> > On Sat, Jun 16, 2012 at 08:59:22PM +0800, Yuanhan Liu wrote:
> > > On Sat, Jun 16, 2012 at 02:42:38PM +0200, Kay Sievers wrote:
> > > > On Sat, 2012-06-16 at 12:40 +0800, Yuanhan Liu wrote:
> > > > > Although syslog_seq and log_next_seq stuff are protected by logbuf_lock
> > > > > spin log, it's not enough. Say we have two processes A and B, and let
> > > > > syslog_seq = N, while log_next_seq = N + 1, and the two processes both
> > > > > come to syslog_print at almost the same time. And No matter which
> > > > > process get the spin lock first, it will increase syslog_seq by one,
> > > > > then release spin lock; thus later, another process increase syslog_seq
> > > > > by one again. In this case, syslog_seq is bigger than syslog_next_seq.
> > > > > And latter, it would make:
> > > > >    wait_event_interruptiable(log_wait, syslog != log_next_seq)
> > > > > don't wait any more even there is no new write comes. Thus it introduce
> > > > > a infinite loop reading.
> > > > 
> > > > Oh, multiple readers on the same shared file descriptor are not useful,
> > > > but sure, that needs fixing. Thanks for tracking that down!
> > > > 
> > > > Looks like the same issue existed in the original code already, it's
> > > > just that it was granular at a single character level, and not a line,
> > > > and the seqnum which icreases one-by-one, so the issue was hard to
> > > > trigger.
> > > 
> > > Yes,  I think so, too.
> > > 
> > > > 
> > > > We better make the mutexes interruptible, right?
> > > 
> > > Yes, you are right.
> > 
> > It might be better to do them in two standalone patches?
> > One is a bug fix, the other improves user responsiveness.
> > 
> > Either way, you may add my superficial
> > 
> > Reviewed-by: Fengguang Wu <fengguang.wu@intel.com>
> 
> Too late; I just sent it out ;(
> 
> Anyway, thanks for your Reviewed-by very much. I hope commiter can add
> this for me.

I will do so, thanks.

greg k-h

      reply	other threads:[~2012-06-16 15:28 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-06-16  4:40 [PATCH 1/2] printk: use logbuf_mutex_lock to stop syslog_seq from going wild Yuanhan Liu
2012-06-16  4:40 ` [PATCH 2/2] printk: return -EINVAL if the message len is bigger than the buf size Yuanhan Liu
2012-06-16 12:50   ` Kay Sievers
2012-06-16 13:21     ` Fengguang Wu
2012-06-16 12:42 ` [PATCH 1/2] printk: use logbuf_mutex_lock to stop syslog_seq from going wild Kay Sievers
2012-06-16 12:59   ` Yuanhan Liu
2012-06-16 13:03     ` Kay Sievers
2012-06-16 13:25       ` Yuanhan Liu
2012-06-16 13:20     ` Fengguang Wu
2012-06-16 13:28       ` Yuanhan Liu
2012-06-16 15:28         ` Greg Kroah-Hartman [this message]

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=20120616152836.GB7914@kroah.com \
    --to=gregkh@linuxfoundation.org \
    --cc=kay@vrfy.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=wfg@linux.intel.com \
    --cc=yuanhan.liu@linux.intel.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