Received: by 2002:a05:6520:4d:b0:139:a872:a4c9 with SMTP id i13csp2566695lkm; Mon, 20 Sep 2021 18:53:43 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyYDessAtool8f2wMbAWZy5w2uusCtvcWkqP1mKioP3cweqMeJzaXbRFEfdEmdnX2H6FumA X-Received: by 2002:a05:6e02:12a1:: with SMTP id f1mr19479916ilr.293.1632188769097; Mon, 20 Sep 2021 18:46:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632188769; cv=none; d=google.com; s=arc-20160816; b=XKqVMeCWf8h2S15qYmSB/gQijgSfaG7+ESUxrcupDUO5wRIVpF+E0/3idUp8rDJD8C DhV8DMKSDffUYlfgv7Ddyl+4BoKNtRxQiwrIaiFLiCXuPqUZXcP8ri/PqMMUAlM9JHFW PnKxnWFXi5vwal++04lSFDr59ycd35zsitLdhJg0FYchjYwq2eS+Kp3sEvDRL9Ee9pa9 dnWvmre4CCD6uanGfEWvvt8pGTFUuwPO7+Qf8UVD7Qo1LmsBSIM7UHyuLi2f+xP/f3Xc SQB8JNmjmUCD4ZM2kuQ4oWJUM+IjqPweBnS2RU5Hsk6mL+kBnvlf1Mx6t/tQdAT943xK E0gA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=IGOhQT5V2IDPHJNF4AqW0Fl4WWd83L6hl5wNrlGzQOo=; b=JMUqzPakLgIlzi496c4owqzioVLI9YUjUWHl1nVcLneIOIIpLmqD43oiZheP2u8isS XityCZ7wXi0uvbwjPMCJ363JrXYM3pwK5ixrNBbVBMh3R/bEJZcKepsR/8l6F30qBO0k s2ejbN2b/OEVD40yvY8vEwjzIza+zjUgJMNvsf2B9AEOVsKgoVp+cIFvQ+kIanrr35qP 9lSpMoT5k6fHoEAOfnCADGODmL/RtlmlinjSaVWQFwI1BveGZdhriIcI9vmIux4vhA/D sWMWoRXiTGU6gX8zVqpPfuUGGwm0Tw1C//0ETjcIYy8cKwivq6U3FaNzVlFH7Vm/hocf uCRw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=hgq8+OTX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id r1si13524166ilg.125.2021.09.20.18.45.57; Mon, 20 Sep 2021 18:46:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=hgq8+OTX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1349108AbhITRVq (ORCPT + 99 others); Mon, 20 Sep 2021 13:21:46 -0400 Received: from mail.kernel.org ([198.145.29.99]:48050 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1348602AbhITRTs (ORCPT ); Mon, 20 Sep 2021 13:19:48 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 5E54961245; Mon, 20 Sep 2021 17:00:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1632157215; bh=5CF0LH7OY6iwG7fugtDG6glgozGKS9EZyankhiIpnRY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hgq8+OTXNZaLgwU7SbpuAaG5LfxWFNQ1yhYuqzZ5lK67vUGveIjhuq3SfK1wzAd94 aqiKtsgvFNIHqKEWrC4nK2SOsmczy9gYdMRss6xnVT6kXn3SemJO324qahL0aI3U4t eBQ5zFFrkhWl70z4wINXBVhlUXvO/NMIk7OjhnvI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Pavel Skripkin , Marcel Holtmann , Sasha Levin , syzbot+be2baed593ea56c6a84c@syzkaller.appspotmail.com Subject: [PATCH 4.14 075/217] Bluetooth: add timeout sanity check to hci_inquiry Date: Mon, 20 Sep 2021 18:41:36 +0200 Message-Id: <20210920163927.172366640@linuxfoundation.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210920163924.591371269@linuxfoundation.org> References: <20210920163924.591371269@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Pavel Skripkin [ Upstream commit f41a4b2b5eb7872109723dab8ae1603bdd9d9ec1 ] Syzbot hit "task hung" bug in hci_req_sync(). The problem was in unreasonable huge inquiry timeout passed from userspace. Fix it by adding sanity check for timeout value to hci_inquiry(). Since hci_inquiry() is the only user of hci_req_sync() with user controlled timeout value, it makes sense to check timeout value in hci_inquiry() and don't touch hci_req_sync(). Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2") Reported-and-tested-by: syzbot+be2baed593ea56c6a84c@syzkaller.appspotmail.com Signed-off-by: Pavel Skripkin Signed-off-by: Marcel Holtmann Signed-off-by: Sasha Levin --- net/bluetooth/hci_core.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c index 89f4b9fc9bcc..1906adfd553a 100644 --- a/net/bluetooth/hci_core.c +++ b/net/bluetooth/hci_core.c @@ -1258,6 +1258,12 @@ int hci_inquiry(void __user *arg) goto done; } + /* Restrict maximum inquiry length to 60 seconds */ + if (ir.length > 60) { + err = -EINVAL; + goto done; + } + hci_dev_lock(hdev); if (inquiry_cache_age(hdev) > INQUIRY_CACHE_AGE_MAX || inquiry_cache_empty(hdev) || ir.flags & IREQ_CACHE_FLUSH) { -- 2.30.2