All of lore.kernel.org
 help / color / mirror / Atom feed
From: David Fries <david@fries.net>
To: Jonathan ALIBERT <jonathan.alibert@gmail.com>
Cc: Evgeniy Polyakov <zbr@ioremap.net>,
	Thorsten Bschorr <thorsten@bschorr.de>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] Avoid null-pointer access in w1/slaves/w1_therm
Date: Wed, 15 Apr 2015 22:51:57 -0500	[thread overview]
Message-ID: <20150416035157.GI3409@spacedout.fries.net> (raw)
In-Reply-To: <CADq11+-tZmQEVUL=sHC64i4auC_5i=+y2yBcMTaJMdD5Z0dE6w@mail.gmail.com>

It has not been solved.  Evgeniy would like to make use of the sysfs
device management instead of the current reference counting, however I
haven't heard any volunteers to do that work.  I posted a quick fix
patch, it was very easy to crash without this patch, it doesn't
completely solve the race conditions, and I don't think it can be
solved in just a slave driver change.

Are you up for the challenge?

On Wed, Apr 15, 2015 at 09:52:27AM +0200, Jonathan ALIBERT wrote:
> Hi,
> 
> Do you know if the problem has been solved ?
> 
> Cheers,
> 
> *Jonathan ALIBERT*
> *06 32 26 59 12*
> *265, route de Saint Haon*
> *42 370 RENAISON*
> 
> 
> 2015-03-19 1:09 GMT+01:00 David Fries <david@fries.net>:
> 
> > On Wed, Mar 18, 2015 at 06:18:53PM +0300, Evgeniy Polyakov wrote:
> > > Hi
> > >
> > > 18.03.2015, 07:20, "David Fries" <david@fries.net>:
> > > >  static void w1_therm_remove_slave(struct w1_slave *sl)
> > > >  {
> > > > + int refcnt = atomic_sub_return(1, THERM_REFCNT(sl->family_data));
> > > > + while(refcnt) {
> > > > + msleep(1000);
> > > > + refcnt = atomic_read(THERM_REFCNT(sl->family_data));
> > > > + }
> > > >          kfree(sl->family_data);
> > > >          sl->family_data = NULL;
> > > >  }
> > >
> > > Can we replace this whole atomic manipulations with kref_t and free
> > family data in the place
> > > which actually drops reference counter to zero?
> > >
> > > I.e. we return from remove_slave() function potentially leaving family
> > data floating around, it will be freed
> > > when the last user drops the reference. There is still a race between
> > increasing reference when starting
> > > reading and removing slave device, i.e. one starts reading, while
> > attached slave device is being removed,
> > > but that's a different problem.
> >
> > With the two while loops I posted, I see with two clients reading
> > w1_slave, the other command to remove a slave gets permanently stuck
> > in w1_therm_remove_slave, which keeps the slave around while the
> > clients continue to read.  I wouldn't predict things going better by
> > keeping family_data around longer, the slave data would still go away
> > with readers around.
> >
> > --
> > David Fries <david@fries.net>    PGP pub CB1EE8F0
> > http://fries.net/~david/
> >

-- 
David Fries <david@fries.net>    PGP pub CB1EE8F0
http://fries.net/~david/

  parent reply	other threads:[~2015-04-16  3:52 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CA+1k2cH5Y+RngvEbgE3CW5g+bO3V1ytDJC=u6DLVDZvbEOhu5A@mail.gmail.com>
     [not found] ` <CA+1k2cF1frcEUu-L_cSJxTp=GKExn6Vt2rdCeY=zrhM62FUggw@mail.gmail.com>
     [not found]   ` <CA+1k2cEwtY+U7TS3rpmMp5nEBokO8vwhcOiD0ExVQnuoB=XVLQ@mail.gmail.com>
2015-02-23 17:09     ` Fwd: w1/slaves/w1_therm: null-ptr access of sl->family_data Thorsten Bschorr
2015-02-24  1:37       ` David Fries
2015-02-25  9:28         ` Thorsten Bschorr
2015-02-27  8:43 ` [PATCH] Avoid null-pointer access in w1/slaves/w1_therm Thorsten.Bschorr
2015-02-28 20:17   ` David Fries
     [not found]     ` <369891425174502@web4m.yandex.ru>
2015-03-01  2:17       ` David Fries
2015-03-01 13:04         ` Thorsten Bschorr
2015-03-02  0:17           ` David Fries
2015-03-04 15:36             ` Евгений Поляков
2015-03-08 21:14               ` David Fries
2015-03-09 22:47                 ` Thorsten Bschorr
2015-03-09 23:09                   ` David Fries
2015-03-10  0:05                     ` Thorsten Bschorr
2015-03-10  0:34                       ` Thorsten Bschorr
2015-03-12  0:44                         ` David Fries
2015-03-10 13:52                     ` Evgeniy Polyakov
2015-03-12  0:54                       ` David Fries
2015-03-14 20:55                         ` Evgeniy Polyakov
2015-03-18  4:20                           ` David Fries
2015-03-18 15:18                             ` Evgeniy Polyakov
2015-03-19  0:09                               ` David Fries
     [not found]                                 ` <CADq11+-tZmQEVUL=sHC64i4auC_5i=+y2yBcMTaJMdD5Z0dE6w@mail.gmail.com>
2015-04-16  3:51                                   ` David Fries [this message]
2015-04-16 11:57                                     ` Evgeniy Polyakov
     [not found]                                       ` <CA+1k2cFw+2NTOtbSaJ1S=kBAn2Mj62DTeZo68V9t1Wk-7m7GyA@mail.gmail.com>
2015-04-17 12:55                                         ` Evgeniy Polyakov

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=20150416035157.GI3409@spacedout.fries.net \
    --to=david@fries.net \
    --cc=jonathan.alibert@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=thorsten@bschorr.de \
    --cc=zbr@ioremap.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.