Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp69752pxb; Mon, 13 Sep 2021 13:11:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx/FEYTt4drbfz4vp9JqX7P81FN5E8SkXL1U7WzvZ0ZJ9114KCT+E/S0s4h6icPsLkvSuxR X-Received: by 2002:a17:906:659:: with SMTP id t25mr14429458ejb.372.1631563898046; Mon, 13 Sep 2021 13:11:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631563898; cv=none; d=google.com; s=arc-20160816; b=xd9i2QRr2xct3Wk9TDPl/NAv9Wh4Tj7+xdEft3VT4lSqBWuQatPDiho4K1IYq2tkJD YYN9nofO4xcKqxhphnQwiqEMsgZBHBkz4e8RN7/kIQN7AjUvRpq1kiZZ3KqRnP1CjpqW 2OTWJ3DuLiCPZuz2MIG15KCUcV/WKEuQP25vwoBx/yXqmYzCOTQrqai6AhDLrJXYEuEf LTw84V7+2bwfabG7IOrpBLhenrqiAmhl+aUcwkS9QbZb3s1FWZhi2yG4iNlaaqCqUOy/ IcOQGIZhjR22zA3ERSsYftoIBetRhWEEyMfJZslKnibPFvIUu/rg5KtynCRV/c6NasTy Lg+g== 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=iwEShSN6U5o4AQr7c+mgcUgzVX8uI/mICzkZrgCuSPM=; b=Mh5P0YoORTSQzJVxbjctmeBo0okiEIToT1Y4JoFbwc9Cbb2rOgNcCPlut3fpxpQFaA DZD2u92RAYTrxa5Bcjzv7EQ6U3yW19v1MUZdZ7hLD3mBrwqXwC9Ye8D4fRikkAiMcKDg h2qsVoJR5UBwADMOWDzgZGa7p32fgZ9sSVBcglSSKCvvBpnYPhps4WX9ciRhULZclNFl 1wwL4frje3CQ6TA/RB4hlSPoc6XpjAZqZtXH2YoU/7c+DfuoUQLxm09DU1UGVdG9WLXE WrXaUqyMDDGpjeCZjUK3ETtTXVV7hr8WqgD8k4H6pRKKrCfCWga71NKMoy+NHlCUdrLE p/Xg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=ygRv7BE8; 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 b6si8625254edv.47.2021.09.13.13.11.14; Mon, 13 Sep 2021 13:11:38 -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=ygRv7BE8; 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 S244667AbhIMNtn (ORCPT + 99 others); Mon, 13 Sep 2021 09:49:43 -0400 Received: from mail.kernel.org ([198.145.29.99]:46740 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242295AbhIMNpd (ORCPT ); Mon, 13 Sep 2021 09:45:33 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id ED2D960F26; Mon, 13 Sep 2021 13:31:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1631539904; bh=lDcib7FFmXZ7UrSzzSuEI54ccpbD0GYHCnYbrpM6zVo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ygRv7BE8SB0v77nxHVvxBe1CsD02erLGSatfZs6YcOGC3RJvEpK3VitcNMkdMZ6ff 737QgsMuR/fOVzkZE1KqFpnAmpR7idAvQO6+ICc8pdDyojYGkUEARYmLAxELsK9WZv IgPz3gSDytQPbKILDBOfVFyP3CNNsaJWcMjPLydw= 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 5.10 175/236] Bluetooth: add timeout sanity check to hci_inquiry Date: Mon, 13 Sep 2021 15:14:40 +0200 Message-Id: <20210913131106.327002864@linuxfoundation.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210913131100.316353015@linuxfoundation.org> References: <20210913131100.316353015@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 2f1868e426ab..a9097fb7eb82 100644 --- a/net/bluetooth/hci_core.c +++ b/net/bluetooth/hci_core.c @@ -1336,6 +1336,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