All of lore.kernel.org
 help / color / mirror / Atom feed
From: Oliver Neukum <oliver@neukum.org>
To: J <jhnlmn@yahoo.com>
Cc: Greg KH <gregkh@suse.de>,
	linux-usb-devel@lists.sourceforge.net,
	linux-kernel@vger.kernel.org
Subject: Re: Possible race condition in usb-serial.c
Date: Fri, 22 Dec 2006 20:59:50 +0100	[thread overview]
Message-ID: <200612222059.50652.oliver@neukum.org> (raw)
In-Reply-To: <20061222190800.3167.qmail@web32909.mail.mud.yahoo.com>

Am Freitag, 22. Dezember 2006 20:08 schrieb J:
> > This problem will need some deeper surgery probably
> > involving
> > removal of the refcounting.
> 
> Refcounting may be OK if used consistently. 
> It is not OK when some pointers are ref-counted, 
> but other (in serial_table) are not (like it is
> in the current version).

No, this is a fundamental problem. You don't refcount
a pointer, you refcount a data structure. But this is
insufficient. We need to make sure the pointer points to valid
memory.
The problem with the current scheme is that serial_table
needs a lock. It needs to be taken in four places
- disconnect()
- open()
- probe()
- read_proc()

Refcounting solves only the race between disconnect() and close()
There's little use in a second locking mechanism if you use it
only in a minority of occasions.
Refcounting is a great idea if the number of references follows
a clear up -> maximum -> down -> free scheme, like for
skbs, etc..

> 
> As for the deeper surgery, what do you think about my
> earlier suggestion to start by rewriting
> usb_serial_probe
> to fully initialize usb_serial before it is added to 
> serial_table? 

Good suggestion. However, if done right, we'd go for a spin lock.

	Regards
		Oliver

  reply	other threads:[~2006-12-22 19:58 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-12-19 19:21 Possible race condition in usb-serial.c J
2006-12-19 20:15 ` Oliver Neukum
2006-12-19 22:33   ` J
2006-12-20  9:47     ` Oliver Neukum
2006-12-20 15:10       ` [linux-usb-devel] " Alan Stern
2006-12-20 21:02         ` Oliver Neukum
2006-12-20 19:32       ` J
2006-12-20 20:43         ` Greg KH
2006-12-20 22:39           ` J
2006-12-20 22:52             ` Greg KH
2006-12-20 20:43         ` Oliver Neukum
2006-12-20 22:24           ` J
2006-12-22 18:14             ` Oliver Neukum
2006-12-22 19:08               ` J
2006-12-22 19:59                 ` Oliver Neukum [this message]
2006-12-22 20:51                   ` J

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=200612222059.50652.oliver@neukum.org \
    --to=oliver@neukum.org \
    --cc=gregkh@suse.de \
    --cc=jhnlmn@yahoo.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb-devel@lists.sourceforge.net \
    /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.