Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp1675278pxk; Sat, 26 Sep 2020 00:47:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJze7ZVfWMoi8CjEuiiEXPHmQd6U8v5VoK4vpfIUUevgcOBUhWMvHXdmwk9d0Z09KLBCYBfi X-Received: by 2002:a17:906:9416:: with SMTP id q22mr6371686ejx.82.1601106448847; Sat, 26 Sep 2020 00:47:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1601106448; cv=none; d=google.com; s=arc-20160816; b=KG65G/PKypeDO+6R30tjk7lfOAIdIr0vLluVTWqcqESRxQPsejiRdYYR5X6ZZ41WKE tcuIPhJsJS9cB5p+Fuy+ccjjglLXqBNg3J7GKKmu1z59fQrKI3/O+4Im9uZlGV7qcTV7 VpIzY08JrAPjpkkeaFn+nmhV4G6MIJNU60J31CbAm6Y9StFLkQt1gAZXuNBWf5wHFkgo b6wWgKbKEN8NzXnEWtktZdheIiHCJ4rroVCkejqIQnp71x968BiH4S2tpP1SnBnyAX3c zZCZoNOqDKk1u1A9uhMm+P98IoJcJLXsNszmDoMH/Zk+hwLEIYwG7p8ceEkInOWuI8OP Lc4g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:to:references:message-id :content-transfer-encoding:cc:date:in-reply-to:from:subject :mime-version; bh=3CHttc613WSJ67josyQD4k/f8WOWIDJhO3aHKuQ5yhY=; b=BSsdq56zU4AZ2pYLjmoas4l+vJf5MroGsGObTY9hXMaSkrMTjNKXMO5pkGFJzXGnQ7 vv/9ufQ4ALAAVgBYyloEZQqEl2Q4HUa09B8iW5Pw7soFv09Gdxhd6rpoRTKRy+xbW3NJ 4cLPg5lnPCnLaf+2XTf7Km76dSiPjN+jMXw+qkbXfnz8hXN2Sf67ybob5X6UUtZVLq7+ 6wi3z6I9hI4XOGaxkcA94gKxQwmlDmt2HHA1lonlIEerm3/SOEkJk92ny5sXdNK/QY+S 8BnL7kyknUqgMJeMMK1A3pCn4jfmxZMscV9U1Dwb60eeCkLpuclbxZinUYAKrxMy1ue7 eBVQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id sa7si3942123ejb.714.2020.09.26.00.47.05; Sat, 26 Sep 2020 00:47:28 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726392AbgIZHqy convert rfc822-to-8bit (ORCPT + 99 others); Sat, 26 Sep 2020 03:46:54 -0400 Received: from coyote.holtmann.net ([212.227.132.17]:38708 "EHLO mail.holtmann.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726149AbgIZHqy (ORCPT ); Sat, 26 Sep 2020 03:46:54 -0400 Received: from [172.20.10.2] (dynamic-046-114-136-219.46.114.pool.telefonica.de [46.114.136.219]) by mail.holtmann.org (Postfix) with ESMTPSA id 52A45CECE8; Sat, 26 Sep 2020 09:53:50 +0200 (CEST) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.120.23.2.1\)) Subject: Re: [Linux-kernel-mentees] [PATCH] Fix uninit-value in hci_chan_lookup_handle From: Marcel Holtmann In-Reply-To: <20200905020410.20350-1-anant.thazhemadam@gmail.com> Date: Sat, 26 Sep 2020 09:46:49 +0200 Cc: linux-kernel-mentees@lists.linuxfoundation.org, Johan Hedberg , linux-bluetooth , linux-kernel@vger.kernel.org Content-Transfer-Encoding: 8BIT Message-Id: <2AEF86AF-8F80-4B01-B506-D2ABC654DBC7@holtmann.org> References: <20200905020410.20350-1-anant.thazhemadam@gmail.com> To: Anant Thazhemadam X-Mailer: Apple Mail (2.3608.120.23.2.1) Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org Hi Anant, > When the amount of data stored in the location corresponding to > iov_iter *from is less then 4, some data seems to go uninitialized. > > Updating this condition accordingly, makes sense both intuitively and > logically as well, since the other check for extreme condition done is if > len > HCI_MAX_FRAME_SIZE, which is HCI_MAX_ACL_SIZE (which is 1024) + 4; > which itself gives some idea about what must be the ideal mininum size. > > Reported-and-tested by: syzbot+4c14a8f574461e1c3659@syzkaller.appspotmail.com > Signed-off-by: Anant Thazhemadam > --- > If there is some explicit reason why len < 4 doesn't work, and only len < 2 works, > please do let me know. > The commit message that introduced the initial change > (512b2268156a4e15ebf897f9a883bdee153a54b7) wasn't exactly very helpful in this > respect, and I couldn't find a whole lot of discussion regarding this either. > > drivers/bluetooth/hci_vhci.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/bluetooth/hci_vhci.c b/drivers/bluetooth/hci_vhci.c > index 8ab26dec5f6e..0c49821d7b98 100644 > --- a/drivers/bluetooth/hci_vhci.c > +++ b/drivers/bluetooth/hci_vhci.c > @@ -159,7 +159,7 @@ static inline ssize_t vhci_get_user(struct vhci_data *data, > __u8 pkt_type, opcode; > int ret; > > - if (len < 2 || len > HCI_MAX_FRAME_SIZE) > + if (len < 4 || len > HCI_MAX_FRAME_SIZE) > return -EINVAL; so the minimum requirement is to have an 1 octet packet indicator. If some other functions are missing length checks, then it should be fixed there. I see that in case of HCI_VENDOR_PKT we need to check for the 2nd octet to be present, but I have no idea why you require 3 octets minimum. As I said, if so, then the other functions that get called require proper range checks. Regards Marcel