mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Randy.Dunlap" <rddunlap@osdl.org>
To: Ken Ashcraft <kash@stanford.edu>
Cc: linux-kernel@vger.kernel.org, alan@redhat.com, mc@cs.stanford.edu
Subject: Re: [CHECKER] Race condition in i2o_core.c
Date: Thu, 1 Apr 2004 18:08:39 -0800	[thread overview]
Message-ID: <20040401180839.0dbcc224.rddunlap@osdl.org> (raw)
In-Reply-To: <5.2.1.1.2.20040401172809.01bcfa50@kash.pobox.stanford.edu>

On Thu, 01 Apr 2004 17:46:00 -0800 Ken Ashcraft wrote:

| Looks like there is a race condition in i2o_core_reply involving the 
| variable "evt_in".  Notice that the increment of evt_in is protected by the 
| lock, but the reads are not protected.  It looks like "events" should also 
| be protected by the lock.  If this is not a race condition, the increment 
| should not be inside the critical section.
| 
| Feedback is appreciated.
| 
| thanks,
| Ken Ashcraft
| -----------------------------------
| /home/kash/interface/linux-2.6.3/drivers/message/i2o/i2o_core.c:264:i2o_core_reply: 
| ERROR:RACE: 264:264:Possible race condition on variable "evt_in", No locks 
| held on read on line 264, Locks {&i2o_evt_lock } held on write on line 268 
| [COUNTER=i2o_handler.reply] [fit=1] [fit_fn=1] [fn_ex=0] [fn_counter=1] 
| [ex=1] [counter=1] [z = -2.91998558035372] [fn-z = -4.35889894354067]
| 
|                  return;
|          }
| 
|          if(m->function == I2O_CMD_UTIL_EVT_REGISTER)
|          {
| 
| Error --->
|                  memcpy(events[evt_in].msg, msg, (msg[0]>>16)<<2);

static int evt_in;
Access to <int> is (considered to be) atomic.
However, the MODINC() macro is nowhere close to atomic.
Does that help?

|                  events[evt_in].iop = c;
| 
|                  spin_lock(&i2o_evt_lock);
|                  MODINC(evt_in, I2O_EVT_Q_LEN);
|                  if(evt_q_len == I2O_EVT_Q_LEN)
|                          MODINC(evt_out, I2O_EVT_Q_LEN);
|                  else
|                          evt_q_len++;
|                  spin_unlock(&i2o_evt_lock);
| 
|                  up(&evt_sem);
|                  wake_up_interruptible(&evt_wait);
|                  return;


--
~Randy
(Again.  Sometimes I think ln -s /usr/src/linux/.config .signature)

  reply	other threads:[~2004-04-02  2:12 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-04-02  1:46 Ken Ashcraft
2004-04-02  2:08 ` Randy.Dunlap [this message]
2004-04-02  9:19 ` Alan Cox

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=20040401180839.0dbcc224.rddunlap@osdl.org \
    --to=rddunlap@osdl.org \
    --cc=alan@redhat.com \
    --cc=kash@stanford.edu \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mc@cs.stanford.edu \
    /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®