Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 30 Jan 2016 19:23:35 -0800
From:      Alfred Perlstein <alfred@freebsd.org>
To:        mokhi <mokhi64@gmail.com>, freebsd-current <freebsd-ports@freebsd.org>
Subject:   Re: thread-unsafety problems as spl*() ones are NOP
Message-ID:  <56AD7E37.5050604@freebsd.org>
In-Reply-To: <CAByVWPW=eWSUWMfUV1nocxGmkCv6N%2Bd2kzYRH735XT0th_Y9_w@mail.gmail.com>
References:  <CAByVWPW=eWSUWMfUV1nocxGmkCv6N%2Bd2kzYRH735XT0th_Y9_w@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help


On 1/30/16 6:56 AM, mokhi wrote:
> Hi.
> in kbd.c there are many places spltty()/splx() used assuming it locks/unlocks.
> though there is bug filed for this, and ive asked in #bsddev, Ive
> preferred to ask and ensure it from here again.
> As these functions are obsoleted now, this assumption is incorrect and
> some places we have thread-unsafely which leads to security problems
> (and/or for example double-free, etc)
>
> can i use mutex/spin/lock/unlock under where assumed a lock/unlock by
> using spltty()/splx() to patch it?
>
> Thanks, Mokhi.
>
Sort of, you have to also make sure to understand any locks being held 
when entering the kbd.c as well as knowing how/when to drop locks using 
msleep() to make it safe.

My understanding is that kdb is locked by GIANT which is why have spls 
as nops is OK (my knowledge may be out of date), still taking out from 
under Giant would be nice as it would be one less place under Giant.

Have a go at it and post patches and let us know how it goes.

-Alfred



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?56AD7E37.5050604>