Received: by 2002:a05:6a10:6d25:0:0:0:0 with SMTP id gq37csp1830187pxb; Mon, 13 Sep 2021 06:30:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzpHwbdwiBFdG1Im7jnCAHC6xC9lletWpLHgI9S8kFEeRyIXp4SYSLtZFt+ALYsDAs181Or X-Received: by 2002:a5d:9ac1:: with SMTP id x1mr1765378ion.47.1631539822156; Mon, 13 Sep 2021 06:30:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631539822; cv=none; d=google.com; s=arc-20160816; b=BRwL3efyJyghDfoRw/c0Wnp3PGNfhjWA98LVkRfwXqaHtzuWIR2hbeHRPFKE/lsTt0 CgrRbPSzYASdlXBEjIoeRNpmVLwX/dMc4Gi9cglJXYXMBtj6QUMkSwgLfoHK2bxPlygO Br68JzDaOuiT/GrL+i4mATo7kzZOubgw+8n4Zxop/k+hnl9y5VfKZdNUytHB5r0iJaKd x1sYS8SW8mBsn7G5y3NYCHlnIEfQhzzVtk9c2MpHuIMP9vI8lvOoDets4xcMGrWwnsin JV4bscJj+dFMpbFRA2KUthy3lLP+QYYfDGxpf+zJOx8Fpk/T0GtFJ1UcKXZn4Csnifyi WdPw== 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=7V7Ni8YapnseBMAMoa76hjfsaimbw45D4mopK9aR2aw=; b=S2piDlIotHOLAeOcOEhhEHKC11ltjLYe1ThKTYtfmgzBL0ndm+eWXtvLFk8vdqE7Lo Bgz2Mt+WPnpnuqwPbnRqG6R2Gj77gKam+BLeVlPib16Ny+HAsgvXgcKnkHXg6itjznRA nWO1JygEcfaoxEPH1PSBth8l0iK3B3gJzjhYNomjXeG1yJSKzPLhvZJIej9ksTaZSrUQ Wl55fdxa4Z087vPflpUo9gPS/9Tu8HbEhGFArdif2dOGF2cQSlqTK7oPvxbcPDbg8WAh qNOkOosJMVG9dJDmtz707qSfqVqsJEt/CNFPXH6J78P4hCsRq5v8f6/2T7JTEatTrkcQ x0Qw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=SeJrKW4R; 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 j10si7227262jat.54.2021.09.13.06.30.04; Mon, 13 Sep 2021 06:30:22 -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=SeJrKW4R; 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 S242224AbhIMN16 (ORCPT + 99 others); Mon, 13 Sep 2021 09:27:58 -0400 Received: from mail.kernel.org ([198.145.29.99]:46826 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241790AbhIMNZs (ORCPT ); Mon, 13 Sep 2021 09:25:48 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id A339861248; Mon, 13 Sep 2021 13:22:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1631539340; bh=khM3ZDqweK24idQjnw87SCjOjs3KDRbruEAFjuslNKA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SeJrKW4RBmRd4O7oR0D5TQOO/Qx20QVVIlSlKhraHCiElWQNBKXGJk4Yd1qH41APl HLqdzjxT0G3p1nhgexvVs2pHFnyL65pvCrZdPR2kPuWocVrThztHkAxbWpmAHitoTn MD919YtLCW9ghfG1QbIUxhyWgbpehJVznZ4KvV78= 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.4 100/144] Bluetooth: add timeout sanity check to hci_inquiry Date: Mon, 13 Sep 2021 15:14:41 +0200 Message-Id: <20210913131051.284199891@linuxfoundation.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210913131047.974309396@linuxfoundation.org> References: <20210913131047.974309396@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 4e4972800370..bdd330527cfa 100644 --- a/net/bluetooth/hci_core.c +++ b/net/bluetooth/hci_core.c @@ -1297,6 +1297,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