Received: by 2002:ac0:aed5:0:0:0:0:0 with SMTP id t21csp1269888imb; Sat, 2 Mar 2019 08:47:31 -0800 (PST) X-Google-Smtp-Source: APXvYqwtfIeN81OvZyQ2KN9q/+fDoGKF5aG1LX2hQRGRPQ524uOWimJUlrwYqwc0HBlCyLKZ7cFG X-Received: by 2002:a17:902:4081:: with SMTP id c1mr11547329pld.297.1551545250991; Sat, 02 Mar 2019 08:47:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551545250; cv=none; d=google.com; s=arc-20160816; b=ehooBl4D1K8eko0oqrcgiOIWbIenVxvi4yUie1XLT7uGDrb2Z/S3GuSGpXF339YcDf HlllgtTkxswBDdBldhhuxHmagKNrHN9rQ4kqZaGJu/fNhLr0AAzrMzpVveJEGltQot+8 LjyZLnOKbjcJvvhkAEZmSaHTU/v6pLhFRuUpQEArlPW91ZvCkPz5912O4MeClh9RAuei GAo/7RO/fazCI2DjFQlKwIZp5Wef6KrlXvZEGRIPWQg4VbJW4YeifKEETAjl6ocf234R /4xvfVq4rEejygrvWotor8WoZ3/YzBCwxjy0ua5uYkpMKSR1RVEoaXuxAtbNd4KBDyGB UBOw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:to:references:message-id :content-transfer-encoding:cc:date:in-reply-to:from:subject :mime-version; bh=MrOCiwC20C564/2wE8mxUz5eOIgOa1UrI9CqbS1Yn8s=; b=g/VUw88mjYtdc+WrNKZk5g7K+h0cZz4VV3/LyBzRD5/7FEStOihtoOHRvH65PMycnd paoRgR8uk2enXK0HEu3zGJ2S3wDoPS5AxIVu+Hqm+6Rqy4GMOwL7G3HVB6IS8kq8gz28 uGhY7hDT596CsPWTVewwrBhhxMSUCptHNs86wHkSxA8G2hWbCZyx7csqOlvYEjjvdzYY PpT6F2sE1X+ilBsXHNUw0/iT3A7mdmvEYR2R56ary1jDhN6j8TA3ioAMSNIsHn/ZpNC2 q0s/FfNCXSeknUSdCnU27974FhW+pAVOM9bsVT9Y1+ZWqV9Vr6oSpBmb7ma6j7IQ4BjW fRZw== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c6si987674pgj.347.2019.03.02.08.47.14; Sat, 02 Mar 2019 08:47:30 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726734AbfCBQqw convert rfc822-to-8bit (ORCPT + 99 others); Sat, 2 Mar 2019 11:46:52 -0500 Received: from coyote.holtmann.net ([212.227.132.17]:53489 "EHLO mail.holtmann.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726282AbfCBQqv (ORCPT ); Sat, 2 Mar 2019 11:46:51 -0500 Received: from marcel-macpro.fritz.box (p4FF9F361.dip0.t-ipconnect.de [79.249.243.97]) by mail.holtmann.org (Postfix) with ESMTPSA id 48389CF352; Sat, 2 Mar 2019 17:54:46 +0100 (CET) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 12.2 \(3445.102.3\)) Subject: Re: [PATCH] net/bluetooth: Fix bound check in event handling From: Marcel Holtmann In-Reply-To: <20190228195939.30685-1-tomasbortoli@gmail.com> Date: Sat, 2 Mar 2019 17:46:49 +0100 Cc: Johan Hedberg , "David S. Miller" , "open list:BLUETOOTH DRIVERS" , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, syzkaller@googlegroups.com Content-Transfer-Encoding: 8BIT Message-Id: <8F6AC5BF-F50B-4C30-A73B-98526AF181EB@holtmann.org> References: <20190228195939.30685-1-tomasbortoli@gmail.com> To: Tomas Bortoli X-Mailer: Apple Mail (2.3445.102.3) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Tomas, > hci_inquiry_result_with_rssi_evt() can perform out of bound reads > on skb->data as a bound check is missing. > > Signed-off-by: Tomas Bortoli > Reported-by: syzbot+cec7a50c412a2c03f8f5@syzkaller.appspotmail.com > Reported-by: syzbot+660883c56e2fa65d4497@syzkaller.appspotmail.com > --- > Syzkaler reports: > https://syzkaller.appspot.com/bug?id=d708485af9edc3af35f3b4d554e827c6c8bf6b0f > https://syzkaller.appspot.com/bug?id=3acd1155d48a5acc5d76711568b04926945a6885 > > net/bluetooth/hci_event.c | 4 ++++ > 1 file changed, 4 insertions(+) > > diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c > index ac2826ce162b..aa953d23bb72 100644 > --- a/net/bluetooth/hci_event.c > +++ b/net/bluetooth/hci_event.c > @@ -3983,6 +3983,10 @@ static void hci_inquiry_result_with_rssi_evt(struct hci_dev *hdev, > for (; num_rsp; num_rsp--, info++) { > u32 flags; > > + if ((void *)(info + sizeof(info)) > > + (void *)(skb->data + skb->len)) > + break; > + first of all, the loop exists twice here. If one is vulnerable, then the second is a well. And second, can we not just do this inside the for-condition check or a lot simpler than this void casting fun. Regards Marcel