Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3658822imu; Mon, 14 Jan 2019 06:57:39 -0800 (PST) X-Google-Smtp-Source: ALg8bN6pPDD54QFpIHwJU73sJnMEBBWozp1V+zCO8NYOAYB0bYw2666XYJlABrZoibp4N0CeXmwN X-Received: by 2002:a63:2784:: with SMTP id n126mr23605094pgn.48.1547477859417; Mon, 14 Jan 2019 06:57:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547477859; cv=none; d=google.com; s=arc-20160816; b=nVhfqFUWdpC4PVdNDroPoKHNbUdsmoWgm6qr1mp3gq3wx+Y1GK++FriFbdb3Oed0E0 y30u3yMMDK1LlWvK1ZewVZFVZTTkjLdKBwLq6bZSM0MzC6xFtlN7FzR/QD+1DxIUGf44 Ib0kn7KavD0T4ol2mkf7ADjkcA1L9lbjMwhOatKIAc7qWz2/Dj8NRlT2F+DFcQyAdjQN YdJAQyli0QHy4vBuVEHmDffUrT4PTS5NyK5uVCydjkw+nvD9Wd8260eFiWtor392VxBX y8kDFdbCS5n144VJVWGiajW1itYdMYJ/QZnIIRq+cCiOiBAgrVIhMHAoKPNNCSJoW26N a1gQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version; bh=zrR//IlG0dqFmdjjRS4F9ki/Uej5c0wg15cI4skFJl8=; b=ViZpf90C7h1v7lyOpm0/ycEppZYKFZvmU8cpdQ4CGbSVrk7/Nd0z7AGeBL+a605gn/ 1o0UF2L0iZn5t2kaH03JrESheeStB7PCN8Ao97uAUoSNO9ZcGKc7lX4CfP37CNRI3p+E xMuKfMUkcnbEbU2qPN4svCcZeru4LXdm0eRgjUflbVgScLmjJjyRgGHlD+MQ1/BuBpF3 nTUNck+pjNytouX5XXJbfFXCvncDcthgPPeyhtFwo4wjzhkV9fRr3Cv9PvWAIdzDdkpE m6GMkoRkWE+rBYPbqQQ3sImGHeec9eXx7+9ZccJcRX96eAhky8Opg3xIGwMSXIJ/i4fc 13IA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u22si491238pgh.286.2019.01.14.06.57.23; Mon, 14 Jan 2019 06:57:39 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726825AbfANOzm convert rfc822-to-8bit (ORCPT + 99 others); Mon, 14 Jan 2019 09:55:42 -0500 Received: from mail-qk1-f193.google.com ([209.85.222.193]:35760 "EHLO mail-qk1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726812AbfANOzm (ORCPT ); Mon, 14 Jan 2019 09:55:42 -0500 Received: by mail-qk1-f193.google.com with SMTP id w204so10676561qka.2 for ; Mon, 14 Jan 2019 06:55:41 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=yRl+5VTR5AQ/tH5rQP5s+7pz+O6bgheGx6ESfnHQJcc=; b=p6PrILU72YpfB18sOgpa6DbYUPzr1iQl5EK0CRJDjK9EBg43wTNABmkFNehf5RzxMk GvmXkocu8iZdeqDW3qcjV0Q7mQkqCS2g+yxZIpcu002EXbfLV4LIQOug49B6dYYJRX9+ +//O8wayRY+zsvT8xGTHXSMkvUd7RtSXi3keQDjRGzwHxVqLdi3xrwNpn3NvM8MFRNVW ++GiufAlzMvSDmMsF+VcyDvBQ+By5Zwq5t6SjgEvMo61cetnMobKHc+HyxAgq3Gl7W4g 1wJJ2wstc3eZRk3uTyzP6tIK0w41ZhLOyqqusJ0G5GmcVk41h/efQdlL//oJZqzq0rjo C1+A== X-Gm-Message-State: AJcUukeaiqHY9vkfW4v7RQphmSItF712zSRrCnQcYb2bBXIH281mUVI7 AoKG4DY8Us+p8OjjcOl+4+xqbaMBbRyT7M1TgYSlnQ== X-Received: by 2002:ae9:e102:: with SMTP id g2mr21447769qkm.343.1547477741257; Mon, 14 Jan 2019 06:55:41 -0800 (PST) MIME-Version: 1.0 References: <20190113230946.GA18710@amd> In-Reply-To: From: Benjamin Tissoires Date: Mon, 14 Jan 2019 15:55:28 +0100 Message-ID: Subject: Re: NULL pointer dereference when writing fuzzed data to /dev/uhid To: Anatoly Trosinenko Cc: Pavel Machek , Jiri Kosina , lkml , "open list:HID CORE LAYER" , Roderick Colenbrander Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8BIT Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jan 14, 2019 at 3:23 PM Anatoly Trosinenko wrote: > > > fuzzed data is hard to discriminate from valid data. > > Just in case it can be helpful... If it is about manually "parsing" > descriptors to understand what is wrong by hands, then maybe Kaitai > Struct parser generator can help. I understand it is probably not > suited well for in-kernel binary parsing, but given a text-form > description of a format, it can visualize parsed binary data as a > hierarchical structure. Well, the data and parsing is pretty straightforward (see http://who-t.blogspot.com/2018/12/understanding-hid-report-descriptors.html if you want to have an entertaining understanding, instead of reading the specs). The problem is the fuzzed data looks like a correct one, but there is garbage in the middle. And we can not simply rely on some global CRC that would prevent fuzzing because there is none. And the report descriptor is in the device, so we can't upgrade all of them. So in the end, sending a fuzz HID report descriptor is like sending a language grammar that doesn't mean anything. The parser says, "well, yes, why not", but sometime the rest of the drivers expect a little bit more, and this is where it gets hard to see. Cheers, Benjamin > > Best regards > Anatoly > > пн, 14 янв. 2019 г. в 02:09, Pavel Machek : > > > > > Hi! > > > > I just want to note that while these may not be high-priority, they > > are still security holes to be fixed. > > > > > > When writing the attached file to /dev/uhid, a NULL dereference occurs > > > > in kernel. As I understand, the problem is not UHID-specific, but is > > > > related to HID subsystem. > > > > > > Thanks for the report. > > > I wanted to tell you that I started investigating the other private > > > report you sent us, but couldn't find the time to properly come with a > > > fix as the fuzzed data is hard to discriminate from valid data. > > > > > > A couple of notes though: > > > - writing to uhid needs to be done by root. Any distribution that > > > doesn't enforce that is doomed to have several security issues > > > > We want to protect kernel from root, too. > > > > > - we could somehow reproduce those fuzzed data on a USB or Bluetooth > > > connection, but that would require physical access to the device, so > > > you are doomed also > > > > Not neccessarily. Imagine a kiosk where PC is protected but keyboard > > uses USB connection. If our USB stack is buggy, you are doomed... but > > you should not be ;-). > > Pavel > > -- > > (english) http://www.livejournal.com/~pavelmachek > > (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html