Received: by 2002:ab2:1149:0:b0:1f3:1f8c:d0c6 with SMTP id z9csp2007729lqz; Tue, 2 Apr 2024 04:48:44 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVQEH26+0kBJVxBX9m0Xv/agZXiZnp29vIrig7yZ76q3c47F7VdK1kE9jdKmKVDO0+cHNplYp51mxOuzS7FlpREi8FLbQbuab4EgrF+HA== X-Google-Smtp-Source: AGHT+IETwpcqvENNpAcZ6LxjXrnSb64k/Bq0fZyg+Um0+W/PcNGyGWp14Yz3/luP4RrVXvtBMJB2 X-Received: by 2002:a17:90a:ba8d:b0:2a0:7895:f356 with SMTP id t13-20020a17090aba8d00b002a07895f356mr22158845pjr.12.1712058524647; Tue, 02 Apr 2024 04:48:44 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712058524; cv=pass; d=google.com; s=arc-20160816; b=VEwvdwh8VuJv9AmmYEnrrIvMQrO+/Rp7jx4BfQa9izMqpG7GTFaaKhRBnK6Zp6MvTs opk4/a3kcNPI+cIltZ1gMCk/2fg81mkXolWWgN/ca5IigGpvjPMIPj1t7bOMocArt6D8 tDLOwqC8SNUH7JPs03zZF390ECW5MIePKfezbhTmsSV6OlnIFVJ6LljDChR5+2MMRR/5 azRy9PRJRVmlcCmSehiPHFSE96VQ/gzDA3ukjgWuM644+DeC4gF97X1aw/S2qdRiqOu+ mBK+oit4lm2u+ru8yZj7IjJjOG8QGyIVBfaSPIAGKmdlTeXP5dBSe40elrYJbjDIMDfc rtDQ== 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:dkim-signature; bh=afxENWSoVYIs+dj5wCAUXvNsz/HQtcJMCSYZyFyBTiM=; fh=LRhtFldz/QsYyKJ7tOD48tjwr7XstKfrBab9M0j9ZVo=; b=w1Hmisn4xE8hG/vVVum0JUEma7RRdBLj3sb/h7hKk9Von051ya15u7QA0F4Kv31GLk 3JF1FoRU418olZQC0/BleMLhBPbZR2qOU8ENtz6KjbXXbMsdxVwJNlMiHXv0AEDqGSz8 I7KPALvjHKk4wM1HcLRqHYy0pevBvxxIdlQdvlFp2s8j5D5pOlSXbDUvEAQ6s8cqlAeW 17vkVCQgY4DwsJhUGQxnBdUrmTuvCU7nD0PxSSQAj9SUuEVm9aD07cwxN1L9MwuYHccm 50bo/nvsDy46u5NX+Hu/TczLdgCxm37F/GOCWDblssUQClPx6AqdapfGKViICMP/m8NS 9S1w==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@yandex.ru header.s=mail header.b=FeN5p0g4; arc=pass (i=1 spf=pass spfdomain=yandex.ru dkim=pass dkdomain=yandex.ru dmarc=pass fromdomain=yandex.ru); spf=pass (google.com: domain of linux-bluetooth+bounces-3067-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-bluetooth+bounces-3067-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=yandex.ru Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id s22-20020a17090ad49600b002a03f130f08si11204084pju.61.2024.04.02.04.48.44 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Apr 2024 04:48:44 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-bluetooth+bounces-3067-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@yandex.ru header.s=mail header.b=FeN5p0g4; arc=pass (i=1 spf=pass spfdomain=yandex.ru dkim=pass dkdomain=yandex.ru dmarc=pass fromdomain=yandex.ru); spf=pass (google.com: domain of linux-bluetooth+bounces-3067-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-bluetooth+bounces-3067-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=yandex.ru 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 sy.mirrors.kernel.org (Postfix) with ESMTPS id DBDA1B268EE for ; Tue, 2 Apr 2024 11:32:27 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C6D9A657A7; Tue, 2 Apr 2024 11:32:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=yandex.ru header.i=@yandex.ru header.b="FeN5p0g4" X-Original-To: linux-bluetooth@vger.kernel.org Received: from forward102c.mail.yandex.net (forward102c.mail.yandex.net [178.154.239.213]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 22D394CB4A; Tue, 2 Apr 2024 11:32:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=178.154.239.213 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712057540; cv=none; b=VI+zVkArYmRqEYnBinE4zVCeFf+m0LDAGP12gDBp7g7R33NoYJe7rJW7NbHNvXtbkWh2pZP+xihE2YUxq7FHOO3BXlFUzPIxty4zPBtfcsvMMRh2tSTWKiXMJF7g8gYjwYq+0i6v1db7afD5IYKva0UwBCLzaH4TZiqwR0h55zA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712057540; c=relaxed/simple; bh=eYeSrltvF+cUWa2IqQCh1lj0SrTxH0+xfPp5ajygmAU=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=JrscB8bpu6mvLRyGkVgpQn/VcgPD+IQw9edWopav4vnqBO5Oo9Bj5K3YM1s9xCyuAuLB51tqX1x6B64QjW6b0OyV0wFdcruMWyws/exNMxfJKVEfPWyMCzG1Ad32PLb8k6R2PIbl29E7SquJYQXf7JA272gj1+2g2DG1ronY9rU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=yandex.ru; spf=pass smtp.mailfrom=yandex.ru; dkim=pass (1024-bit key) header.d=yandex.ru header.i=@yandex.ru header.b=FeN5p0g4; arc=none smtp.client-ip=178.154.239.213 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=yandex.ru Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=yandex.ru Received: from mail-nwsmtp-smtp-production-main-29.myt.yp-c.yandex.net (mail-nwsmtp-smtp-production-main-29.myt.yp-c.yandex.net [IPv6:2a02:6b8:c12:30ac:0:640:8a30:0]) by forward102c.mail.yandex.net (Yandex) with ESMTPS id 0527B60B67; Tue, 2 Apr 2024 14:32:08 +0300 (MSK) Received: by mail-nwsmtp-smtp-production-main-29.myt.yp-c.yandex.net (smtp/Yandex) with ESMTPSA id 6WQ91E8WlKo0-S3pysM6y; Tue, 02 Apr 2024 14:32:07 +0300 X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex.ru; s=mail; t=1712057527; bh=afxENWSoVYIs+dj5wCAUXvNsz/HQtcJMCSYZyFyBTiM=; h=Message-ID:Date:Cc:Subject:To:From; b=FeN5p0g4RmZ9ynGCzPul+7Gtr2Y/BoyEgltU3ZzxLEwA2s3AcDrFM/cGalP94vXNg aOCkXR4vvoGOsWavrJyE15mcZXRZu73DDxai5OXbZqlFQgroCzdUJME+BwKM5jDRnk VNaEJB8918aoSp+d+mQ7U5CRI42dyJ6CeY36Gcv8= Authentication-Results: mail-nwsmtp-smtp-production-main-29.myt.yp-c.yandex.net; dkim=pass header.i=@yandex.ru From: Dmitry Antipov To: Johan Hedberg Cc: Luiz Augusto von Dentz , linux-bluetooth@vger.kernel.org, lvc-project@linuxtesting.org, Dmitry Antipov , syzbot+39ec16ff6cc18b1d066d@syzkaller.appspotmail.com, stable@vger.kernel.org Subject: [PATCH] Bluetooth: fix memory leak in hci_req_sync_complete() Date: Tue, 2 Apr 2024 14:32:05 +0300 Message-ID: <20240402113205.7260-1-dmantipov@yandex.ru> X-Mailer: git-send-email 2.44.0 Precedence: bulk X-Mailing-List: linux-bluetooth@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit In 'hci_req_sync_complete()', always free the previous sync request state before assigning reference to a new one. Reported-by: syzbot+39ec16ff6cc18b1d066d@syzkaller.appspotmail.com Closes: https://syzkaller.appspot.com/bug?extid=39ec16ff6cc18b1d066d Cc: stable@vger.kernel.org Fixes: f60cb30579d3 ("Bluetooth: Convert hci_req_sync family of function to new request API") Signed-off-by: Dmitry Antipov --- net/bluetooth/hci_request.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/net/bluetooth/hci_request.c b/net/bluetooth/hci_request.c index 00e02138003e..efea25eb56ce 100644 --- a/net/bluetooth/hci_request.c +++ b/net/bluetooth/hci_request.c @@ -105,8 +105,10 @@ void hci_req_sync_complete(struct hci_dev *hdev, u8 result, u16 opcode, if (hdev->req_status == HCI_REQ_PEND) { hdev->req_result = result; hdev->req_status = HCI_REQ_DONE; - if (skb) + if (skb) { + kfree_skb(hdev->req_skb); hdev->req_skb = skb_get(skb); + } wake_up_interruptible(&hdev->req_wait_q); } } -- 2.44.0