Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp867359ybt; Fri, 10 Jul 2020 14:42:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzZzPDuFiOp9EGsqoFWhhbrApDJ2cUsULamLJk6zYGpbNXX7T6QGGlQEdbxFuSHIOxiNHFZ X-Received: by 2002:a05:6402:1803:: with SMTP id g3mr75892419edy.377.1594417328151; Fri, 10 Jul 2020 14:42:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594417328; cv=none; d=google.com; s=arc-20160816; b=TdK/jN551K8bW2jf5LvrSg5YAJwFq8iYRNiHF8NjCQPhg2/PeLei0KtoYcyJN6dgvi zc9586geRm4ALILcql/trqpmIUOH+xz0ZWDl7E5PK/EDHQwSzog1WZ7rizLJeumcj/ui 3Kn4ToNXhWCVQckMcfOgJVPbFjF5lKttBUFWCMSoap7XIte/D9aYVzwPmXwD5E52rjdD Fx54mphTokI1ndDRpe6kUz2svbzYZftbd8WUlJaGkM+hyz2uW8Btqaz4Gbw6b+Fu4KPU P5ySgkUlrlSi/MlF2x9WfXGCfDKNpJ4lg0KGm2q6lGX7MEVKj1btwyK8zeHvEU5RA//e eLgQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=Da2tkZhxp36WWIM5SU4wWRnWrL+fbZs7REwsgJam7ZQ=; b=yk6IasQ3GLh9xWh0OJ0JCGndIRipSXD82Rj/L/QX3IrUve/U8gni44/soXyz2Fg/Rx 0DEKE9MVfgfpQgv54fa6vnYfjDK6IUwzp48lVuO6tF+rpN7dWefGshGzZI0uOWk5t9Rs P5pCTrAXWs57PjGRtI3Oo/UOjVugjA71UF7z2bVp0ZVhYgMvmvZS+rEC057T0Wm5DNCx /JphdFwfGh3uLSgzNhTcq+ZFVM+4TQP55Dcs9Nbwnfc+DUy6SWBTarm4UIiWC0FUpAyD 0VFf0ZtIDRIg28Xt/FBLLZmrTlpvs2CR609/GrRiHtx+h3UiNzfcTjY+w52eJGZ+ZNpN yiSQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=VHhl70xJ; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id sd15si4573435ejb.606.2020.07.10.14.41.25; Fri, 10 Jul 2020 14:42:08 -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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=VHhl70xJ; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726262AbgGJVlX (ORCPT + 99 others); Fri, 10 Jul 2020 17:41:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54162 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726251AbgGJVlW (ORCPT ); Fri, 10 Jul 2020 17:41:22 -0400 Received: from mail-qv1-xf43.google.com (mail-qv1-xf43.google.com [IPv6:2607:f8b0:4864:20::f43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 77E47C08C5DC; Fri, 10 Jul 2020 14:41:22 -0700 (PDT) Received: by mail-qv1-xf43.google.com with SMTP id di5so3270563qvb.11; Fri, 10 Jul 2020 14:41:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=Da2tkZhxp36WWIM5SU4wWRnWrL+fbZs7REwsgJam7ZQ=; b=VHhl70xJKGvDmkqn9+GFeBcUZmC518WJVEFdfy8ur5HqlFExf0rxCQqHtur+CxOaqb iC/aDjq4YILIXcE9snn6uUpJEJSctpWWeSIcBd1gpIwKFbv+erXR9MKTWreSo0dOQKMo +S2JOme4t+ViPdBBTh2LgOFP78FdMRVZa/KvKW3P12B3HMV4vmIDdLoL79AnN3/2ZMDp GI/pYYdntjQ8qmt2ICS6qw2mjW85VFeM86w2EtTA4jwe+uQ4Zgt9eXxcDc8W1JL+247M SDWh+bYC/tB5vjOXT2GObQ3uC1A7k3UDT3aCQI4VnJ9IcFq51Wrp+jeuyastgyymV+A4 D/QQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=Da2tkZhxp36WWIM5SU4wWRnWrL+fbZs7REwsgJam7ZQ=; b=JO7KY24cK6qlP+MaJXUMypghc1aH8DTWDqJLMAP2hSUm1CP0JyM00cFr0dWO8fj6yx MKpLOCnbRDRvajPppP/Zn9I2bjdwpGs5SJxIsQ+PyMra93TKxP3CYUe93B2tnwSA24hP yNsQ+c6mCAVIE+/OPEeCAM9Oax20Hbi6sUtLDhCfiWqC24ZGpBQzonFUYmLM7Oo/m/97 6qqcFvNKG/KSsrqLC767tnsHZ7FS9THuhabQY3QGDlbaQqJ09WaQr06VhBINpXwFRMQb 4hDEZwxNlEfoA9pvPDlviFD954YryCcULumfG1S0+VPGpQTd68UujzgTMxftE9nOAZqN 08bg== X-Gm-Message-State: AOAM532jxGiq47B/utf5vJ2tVW+v/3GLPyBqqRnreKq81c9dnGhcc0Gm eK+CggF9QIpAEFKJ1k0kZw== X-Received: by 2002:a0c:ab55:: with SMTP id i21mr71409390qvb.139.1594417281580; Fri, 10 Jul 2020 14:41:21 -0700 (PDT) Received: from localhost.localdomain (c-76-119-149-155.hsd1.ma.comcast.net. [76.119.149.155]) by smtp.gmail.com with ESMTPSA id 2sm8652249qka.42.2020.07.10.14.41.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 Jul 2020 14:41:21 -0700 (PDT) From: Peilin Ye To: Marcel Holtmann , Johan Hedberg Cc: Peilin Ye , "David S . Miller" , Jakub Kicinski , Russell King , Greg KH , linux-bluetooth@vger.kernel.org, netdev@vger.kernel.org, linux-kernel-mentees@lists.linuxfoundation.org, linux-kernel@vger.kernel.org Subject: [Linux-kernel-mentees] [PATCH 1/2] net/bluetooth: Prevent out-of-bounds read in hci_inquiry_result_evt() Date: Fri, 10 Jul 2020 17:39:18 -0400 Message-Id: <3f69f09d6eb0bc1430cae2894c635252a1cb09e1.1594414498.git.yepeilin.cs@gmail.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org Check `num_rsp` before using it as for-loop counter. Cc: stable@vger.kernel.org Signed-off-by: Peilin Ye --- net/bluetooth/hci_event.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c index 03a0759f2fc2..8b3736c83b8e 100644 --- a/net/bluetooth/hci_event.c +++ b/net/bluetooth/hci_event.c @@ -2517,7 +2517,7 @@ static void hci_inquiry_result_evt(struct hci_dev *hdev, struct sk_buff *skb) BT_DBG("%s num_rsp %d", hdev->name, num_rsp); - if (!num_rsp) + if (!num_rsp || skb->len < num_rsp * sizeof(*info) + 1) return; if (hci_dev_test_flag(hdev, HCI_PERIODIC_INQ)) -- 2.25.1