From owner-freebsd-current@freebsd.org Sat Jan 30 22:03:30 2016 Return-Path: Delivered-To: freebsd-current@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id AB223A737C6 for ; Sat, 30 Jan 2016 22:03:30 +0000 (UTC) (envelope-from wlosh@bsdimp.com) Received: from mail-qk0-x234.google.com (mail-qk0-x234.google.com [IPv6:2607:f8b0:400d:c09::234]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 73D1099B for ; Sat, 30 Jan 2016 22:03:30 +0000 (UTC) (envelope-from wlosh@bsdimp.com) Received: by mail-qk0-x234.google.com with SMTP id o6so37841005qkc.2 for ; Sat, 30 Jan 2016 14:03:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20150623.gappssmtp.com; s=20150623; h=mime-version:sender:in-reply-to:references:date:message-id:subject :from:to:cc:content-type; bh=uUs4O0gICAcw6v8RuI1QA6kneCqzvdnvPbOe9M32yRg=; b=rbNWbCAse/yKKeBDwROjJkoG0I86+S/x9QCDnKyjPGq9f1YTxdaMeY0wU/xyk861ev KDlBFCQzrm6HPMRS7H5k1hQarZf2y4DO0l1FR3TDQEay2kDBN5JBxlOemsbQYqmDA01+ jGN7NosNNTQxdZ2waS1MCNjPCkrWbdGTh/iVMRaKF3Ost7Pdn2f+f+6+sHLOpLEAfGq6 lSle6C8/QjHAPeXpgxzsDP+D8UeLt5Cn6cLFzZz7juCBHeL8bxUXvi8c5HyxW+VrqPPx LdwO+ySjCaps7NEVmHp4Rm1fRrHTotNV54t3AiGdUaqJb9VqasmHBcIXzE0OcELSPJnt DHIw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:sender:in-reply-to:references:date :message-id:subject:from:to:cc:content-type; bh=uUs4O0gICAcw6v8RuI1QA6kneCqzvdnvPbOe9M32yRg=; b=kSHcrXr2sHRhddLHbG5HkEkozSWKBbX7TLrLhVnLLDNlyW979SDK9CJGTmek6ptZbx QPct8j4kuvEhCwpF7iq5jT9KcujiKInIhlsarAL0aAOZkp1PSJIXKthTklSHLLrPIxyT dbwEZgpuMXgF799YtIBn2ODnlnJC3Aefx8QifYtXjYsyKLR0oycy2a9OjPdGtw4vvz0s P4rvFWBROJD7qVmFcZLW50GjEjX7Ifk262ND/fFm+49U3LB8mKGvOqozQnyMlowC4Zay 7Nesn5vdsBo2119RbqaeLDbI4iUNrwE/jDshfpDK8AGRXKPZZIOzje9e5wwBoAI+cSok j6IQ== X-Gm-Message-State: AG10YOSADLEdcLgXjzyS8nyOI2fVKSRykbr6K37b+2dECSvlDCfluHlrOG7QhO5VhDEsvd+j31Yv/0NnXngebA== MIME-Version: 1.0 X-Received: by 10.55.192.7 with SMTP id o7mr19509798qki.93.1454191409310; Sat, 30 Jan 2016 14:03:29 -0800 (PST) Sender: wlosh@bsdimp.com Received: by 10.140.30.166 with HTTP; Sat, 30 Jan 2016 14:03:29 -0800 (PST) X-Originating-IP: [2601:280:4900:3700:6557:86bf:23c8:62de] In-Reply-To: <1454188175.32550.3.camel@freebsd.org> References: <1454188175.32550.3.camel@freebsd.org> Date: Sat, 30 Jan 2016 15:03:29 -0700 X-Google-Sender-Auth: 7N35r_mUT5y-KZLnDazt8uj36vU Message-ID: Subject: Re: thread-unsafety problems as spl*() ones are NOP From: Warner Losh To: Ian Lepore Cc: mokhi , FreeBSD Current Content-Type: text/plain; charset=UTF-8 X-Content-Filtered-By: Mailman/MimeDel 2.1.20 X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 30 Jan 2016 22:03:30 -0000 On Sat, Jan 30, 2016 at 2:09 PM, Ian Lepore wrote: > On Sat, 2016-01-30 at 18:56 +0330, 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. > > If you start working on locking in keyboard drivers you might discover > there are dragons there. For example... > > https://lists.freebsd.org/pipermail/svn-src-head/2014-March/056833.html In theory, they are all Giant locked. In reality, however, there are many dragons, and the dragons are difficult to slay... Though things have been chipped away enough that it might not be so bad now... I tried early in the locking game and found too many dependencies on Giant in the code that was called from the keyboard drivers to be able to make much progress. But that was in the FreeBSD 6 time frame, and Giant is almost gone from the rest of the system, so another run might not be so bad. Warner