Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp5996896ybc; Wed, 27 Nov 2019 13:07:27 -0800 (PST) X-Google-Smtp-Source: APXvYqz5hqT/8pDNSc7bIiBuENcLjGfJClRRxIujMYLGZ9UYS4Xfa7K+mGKxR/1Mc6pxkg4/+qr+ X-Received: by 2002:a50:eb91:: with SMTP id y17mr34402335edr.216.1574888846947; Wed, 27 Nov 2019 13:07:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574888846; cv=none; d=google.com; s=arc-20160816; b=tV54mtafFMA+6hCWtbGaiUCZ2CVGGNstNWBx4E+T4n3+0CJMkDa+hEePPNSbLc0ktE j91ELuXqPVzhpN9djP8ZZytZeOQyHAVPei+qLdDmoR8hi1gBLS9gNk9pX+xQxHkYpdXS s3PVBdoFWcR2imb4AKxcUIdcADUgbRkL0sazdRGLgNjjxSmDtSp7rCeOLZSZNpi0PcMt WXPGVauHVuU1yhM+pe1e0vvmk5ON2ErQXWUexMquboT66cTD2vMp6E2U66fX3J4/s55+ 3QsiYbl3S8sVV+LNcQKh4bbAutzZwiW8HR1R9oBoo2PadeZ7srYppW6r6N9mLDpKo6RG Yefg== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=rZgI9guBdNlWRdeXWDn72it9UAsLNfW1hmSOSWv6CfM=; b=huZ3alq2wbMxgNTa/1OrWaupOWFbsBZ3DDzaUvEf3d2ejsk83sCyJEQfPUzmqK3YBt b9VwOeM2WerFVBQflGKbSTRU01Gdhxhk/acmk2MLmBitrAXYy3GrMOf8dyDNOB14uNml /dg5PWpbxeekyQEeJbE5/F2f4HCZ2llsoEkzb9uKIAdlO+vplkPP9Npl7IUnSrYtbe8T Ri+CuixCQLVmZ1wpyz6eSiCQnuQpfuPVeIxLAaMAPUv22DAKImVy+YgjiDObpLCAewxl D6ZJN9zVQPTEt1xi+ZR8OvUjeSSBn96v+UmiZRmUS6ZDAu36GaKyTBJBmee4DO7o46q0 jRqw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=XkRadY8X; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o14si12960216edi.116.2019.11.27.13.07.03; Wed, 27 Nov 2019 13:07:26 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=XkRadY8X; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732358AbfK0VFz (ORCPT + 99 others); Wed, 27 Nov 2019 16:05:55 -0500 Received: from mail.kernel.org ([198.145.29.99]:59772 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727440AbfK0VFy (ORCPT ); Wed, 27 Nov 2019 16:05:54 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 7D6CE217BA; Wed, 27 Nov 2019 21:05:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1574888754; bh=ivAr2KdU9K4Tx7Ky4Bm6mhRcS09rwRLNa5AkPF/3bcQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XkRadY8Xs8moqMIT8+wAdV+FWdx24iu4BKXhxue+j0ORE/qAuvNP0YvD4XuaiHd7y fMsRGPbsZHJU8yF1H7RJmbZ27hug4KLBjRcOjleN9KqyY6Tdtn6k8ifVOiZrlWSATP dqdA/em8EqwoFwJGLEavIRGRTGvVdAkfmZsrAS2I= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Tomas Bortoli , syzbot+a0d209a4676664613e76@syzkaller.appspotmail.com, Marcel Holtmann , Alexander Potapenko Subject: [PATCH 4.19 256/306] Bluetooth: Fix invalid-free in bcsp_close() Date: Wed, 27 Nov 2019 21:31:46 +0100 Message-Id: <20191127203133.564483599@linuxfoundation.org> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20191127203114.766709977@linuxfoundation.org> References: <20191127203114.766709977@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Tomas Bortoli commit cf94da6f502d8caecabd56b194541c873c8a7a3c upstream. Syzbot reported an invalid-free that I introduced fixing a memleak. bcsp_recv() also frees bcsp->rx_skb but never nullifies its value. Nullify bcsp->rx_skb every time it is freed. Signed-off-by: Tomas Bortoli Reported-by: syzbot+a0d209a4676664613e76@syzkaller.appspotmail.com Signed-off-by: Marcel Holtmann Cc: Alexander Potapenko Signed-off-by: Greg Kroah-Hartman --- drivers/bluetooth/hci_bcsp.c | 3 +++ 1 file changed, 3 insertions(+) --- a/drivers/bluetooth/hci_bcsp.c +++ b/drivers/bluetooth/hci_bcsp.c @@ -606,6 +606,7 @@ static int bcsp_recv(struct hci_uart *hu if (*ptr == 0xc0) { BT_ERR("Short BCSP packet"); kfree_skb(bcsp->rx_skb); + bcsp->rx_skb = NULL; bcsp->rx_state = BCSP_W4_PKT_START; bcsp->rx_count = 0; } else @@ -621,6 +622,7 @@ static int bcsp_recv(struct hci_uart *hu bcsp->rx_skb->data[2])) != bcsp->rx_skb->data[3]) { BT_ERR("Error in BCSP hdr checksum"); kfree_skb(bcsp->rx_skb); + bcsp->rx_skb = NULL; bcsp->rx_state = BCSP_W4_PKT_DELIMITER; bcsp->rx_count = 0; continue; @@ -645,6 +647,7 @@ static int bcsp_recv(struct hci_uart *hu bscp_get_crc(bcsp)); kfree_skb(bcsp->rx_skb); + bcsp->rx_skb = NULL; bcsp->rx_state = BCSP_W4_PKT_DELIMITER; bcsp->rx_count = 0; continue;