Received: by 2002:ab2:60d1:0:b0:1f7:5705:b850 with SMTP id i17csp856426lqm; Wed, 1 May 2024 19:22:27 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUXhc8QmhK3tYcGmKXmdVpzLMhODHdsXDAu/ButAkdHlK/OiGHKCSZKtzFLHTbzzMW31xwqKFRXypNj49Mhq4Z1idgFBqvgP39HwyFlyA== X-Google-Smtp-Source: AGHT+IFDIgBNiMKvw2tv3xUNxZHEpgyY+w7teypgjm7uz7ALNAqEMY6dDAMRJua60iJckWJb1Jla X-Received: by 2002:a05:620a:22a2:b0:790:9e68:db10 with SMTP id p2-20020a05620a22a200b007909e68db10mr4185176qkh.5.1714616547602; Wed, 01 May 2024 19:22:27 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714616547; cv=pass; d=google.com; s=arc-20160816; b=u/RygJ7HyitrpZpfextQwFNUu6/28Dkqdqp3XmIeIhKsCnbQ8H3TaK6hAiNVjfRlv8 +v2wP/Pgy7FpxVqICz3hOsbx0cGjx1IxJiiDs0GdGZ+oz1hBSNyKlvi7ouJMUZjLCuEe e2yxH2tOy4ayCFP/wo/xEWuA227gnK8MXopx6tVcH2eWcq1qTYxTGgPlFbzml7XkX1i2 gcpH0ZcZcW3F6diaG/uCPJlbROABsTtMsHZ0Sk3s5YQ6FtZvpHaV93jVS/qaSBk24rVT eFkAN1T+HgfKIt9yu4IwyL5eMarh7l9xJZWNgBT89X86GVCNdR51uXmiLTX4qkwIGyHx T8NQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from; bh=zGjZKKiGogvWCvWU2bfw67pwUvUo4ozwuFvA3Y52JnI=; fh=tz2XSgZxVmr9JAolW6ywbL37EfZxHUPrf/aZDvSEVaU=; b=Bku2nmwLgP8FfNWwb7cQQeCdOUHJoLRLbXWbv/0NRbhAK7YZdtv91vBRPXTWraY2Mc PX3ql63UObKEwMGdIV068nfAU2iqelJzfrsBYKcMcOO/j2wdGehFL5I5kESWKOGJgLJn imc7HoE7dKBLXgZqI8CTx/7n1NslGI4CmNQJi7wkbwithntvkIjOCcF1wGjfI//wB67D tksLbffQ8lGiqCW1CP+lXgg/cgu4OszOuvNIBcJfaG1bkBOcBzjhVPGKx76yjKeIPmdx 9MTkAfa9Vozb8bXy0NO0KQClcEC8KK/2mzQj6kaeKcyrLP6mCPcw34MyrPhjg2DUzY4s Jg3w==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=gmail.com); spf=pass (google.com: domain of linux-bluetooth+bounces-4248-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-bluetooth+bounces-4248-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=sung-woo.kim Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id i4-20020a05620a404400b0078eff6f05c8si650qko.569.2024.05.01.19.22.27 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 May 2024 19:22:27 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-bluetooth+bounces-4248-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=gmail.com); spf=pass (google.com: domain of linux-bluetooth+bounces-4248-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-bluetooth+bounces-4248-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=sung-woo.kim Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id E53B11C21D48 for ; Thu, 2 May 2024 02:22:25 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3C41D17BB7; Thu, 2 May 2024 02:22:21 +0000 (UTC) X-Original-To: linux-bluetooth@vger.kernel.org Received: from mail-qv1-f51.google.com (mail-qv1-f51.google.com [209.85.219.51]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3542D14F98; Thu, 2 May 2024 02:22:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.51 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714616540; cv=none; b=gwbHIGMTxeAGQiLVPMG/MFZKflTQxT6G/vTDeLx0QxlS3s3RuTR8fLwo6Gx/6pGsnpQ01xd/DgmdH47AG8rjoZs+XkhKvzo0eySqnlUjgi7eG2QyTQGzJ0T3IzvjGQLNoWZPP34xAfDzx5ogAyILvpa631mtowgXBkVCug2T0qY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714616540; c=relaxed/simple; bh=D3RDOQ/8fxSKRWRmhYenBUYE5f5frU02XXiNz0k1se0=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=APbTKt9hpewK/AGqQ9jwYGyI8JiwK/IZviacSHwcq2KSmy+C5nomdvhGfHfex537+1ZhX6UZLJSuujLgFnH18jHF/OOdx101GHHC987N197V3rrEiZhVFuF4SJtxS3Oll5YbirG0REfCouRtqbHb3AwWci1RvlTpda53/sbblYk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=sung-woo.kim; spf=pass smtp.mailfrom=gmail.com; arc=none smtp.client-ip=209.85.219.51 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=sung-woo.kim Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-qv1-f51.google.com with SMTP id 6a1803df08f44-69b10ead8f5so39353786d6.0; Wed, 01 May 2024 19:22:18 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714616538; x=1715221338; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=zGjZKKiGogvWCvWU2bfw67pwUvUo4ozwuFvA3Y52JnI=; b=SH6aYDL5frmieOgSPxjxoTY5Svf6OIQl1onxxCfH3mu04bcU1rHdywocg8aFqoYdUL SU7i2/IHEopZlHpPZwrppS/0HbzNe0Zzl24mQtN2F1Tz2OgY+sIyuKq6zGK04q7D7p7+ T3ku84zquKswGNwaqG3fyX3Q2mKHE2Ip5x0fd62pvLI+Pt1j27i//AOv2GAMaq8CgLLj V3pp3atstm1dehTt9ZkVbdtrMRyGddKOUCNAczQ0XBU2TMby9SHelIUBcguH0JzVR1y/ 2dvZimLMP0fTJcYnUd5rIcDqA0dwb6/oN2MjdKvhrxjQv/0dkwJjNmnrpUfXyJRA7kth IFrA== X-Forwarded-Encrypted: i=1; AJvYcCXQZVT8tviIHivY7fuAu0rCHbCkB9Mvf0LdulyRRBxMuIozAvouRz+2LiTM0TWuJf0J/LQar2Vskiiy2QkMhxh4NOL9+2nlNAD2IsBfqFw6B07HNQRNqj33EnmvhwWnTxqBTs+zy6ipG8c63y2R X-Gm-Message-State: AOJu0YzYOdjlu6xvHFY9ndNi63U+QjIeY3NfzXI9y7pyrnXpWn13W4rs LOHpisW283dIm0oSni79j+1lyVQiqGk5w/QKbb1xcszgrtXifBs4 X-Received: by 2002:a05:6214:c86:b0:6a0:c8f7:e47f with SMTP id r6-20020a0562140c8600b006a0c8f7e47fmr4317888qvr.3.1714616537958; Wed, 01 May 2024 19:22:17 -0700 (PDT) Received: from tofu.cs.purdue.edu ([128.210.0.165]) by smtp.gmail.com with ESMTPSA id a14-20020a0cefce000000b006a0fa61359asm4623qvt.41.2024.05.01.19.22.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 May 2024 19:22:17 -0700 (PDT) From: Sungwoo Kim To: Cc: daveti@purdue.edu, benquike@gmail.com, Sungwoo Kim , Marcel Holtmann , Johan Hedberg , Luiz Augusto von Dentz , linux-bluetooth@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] Bluetooth: HCI: Fix potential null-ptr-deref Date: Wed, 1 May 2024 22:17:09 -0400 Message-Id: <20240502021709.141220-1-iam@sung-woo.kim> X-Mailer: git-send-email 2.34.1 Precedence: bulk X-Mailing-List: linux-bluetooth@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Dear all, hci_le_big_sync_established_evt() has a potential null-ptr-deref bug. hci_le_big_sync_established_evt() bis = hci_conn_hash_lookup_handle(hdev, handle); if (!bis) bis = hci_conn_add() <- could fail /* ... */ bis = hci_conn_hash_lookup_handle(hdev, handle); set_bit(HCI_CONN_BIG_SYNC_FAILED, &bis->flags); <- null-ptr-deref There is a missing check after hci_conn_hash_lookup_handle(), which can return NULL. Especially, if a prior hci_conn_add() fails than hci_conn_hash_lookup_handle() will return NULL. This patch fixes this by adding a check. Thanks, Sungwoo. Signed-off-by: Sungwoo Kim --- net/bluetooth/hci_event.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c index 4a27e4a17..d72d238c1 100644 --- a/net/bluetooth/hci_event.c +++ b/net/bluetooth/hci_event.c @@ -7037,6 +7037,8 @@ static void hci_le_big_sync_established_evt(struct hci_dev *hdev, void *data, u16 handle = le16_to_cpu(ev->bis[i]); bis = hci_conn_hash_lookup_handle(hdev, handle); + if (!bis) + continue; set_bit(HCI_CONN_BIG_SYNC_FAILED, &bis->flags); hci_connect_cfm(bis, ev->status); -- 2.34.1