Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp5586824img; Wed, 27 Mar 2019 11:11:54 -0700 (PDT) X-Google-Smtp-Source: APXvYqykw2fF3fZdUM5d6RHZrZfBn6nHBZ34hWMWlKAmY+opiGCi52JfwhWXwBd9Sfs5Q6QB8/B+ X-Received: by 2002:a63:e70c:: with SMTP id b12mr36135785pgi.399.1553710313956; Wed, 27 Mar 2019 11:11:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553710313; cv=none; d=google.com; s=arc-20160816; b=bOi8M7E437GfDgU+9jJ0COuCcLfrORJcipO4T83zMBRomm1IdrL0HJkjC82LeLzlAm i7ox5WI1Ibey2H/w29bd1kjQqTg8x9YwwpwRCXCz9tCVfpR/LszK6X0JKXwkLsjSKa0p p/1haa7Mwg0Ny8cXwhEjdR6wWpJyfeMRxanNczo+v2WuHJDAHoSoyli/RtTtbtScE5B+ kWve/rXukBCOAPh1bnBozN0g3vq8KxoaNz2niweBbAcwduVx7Ve1VUbVrLdrRYVQZbPL LXo9Gy/oiW3ut84d6UCarkTfPxBkdNMbMOx4TEo+zVnqhUck4NU+MU2PWL81xYjn4oqw Hn+g== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=+dsidezkPKX122d6vtCGSdDhGRVtJMCU3BEulZGajX8=; b=QNF8jQ9CuBYD7eWM6w1lAu9aVUvLQIgKxvmReSp+jSDjiC4aSHoq9WAjJUi9XC8IvG SJJJqaRJh4jYOjk0Vs+CXRf8wmu7SyzAMVmQYwWJayRv11ahuLCpKqaB+nGl0ENTxUxb 6B778JmtYhR9miE8bx/MifmoIvIIk/6M8vL3S3esCmhF0unmF378apkAznMyb55pO08a ZX3o1AJpUrfsaB/n8mlM8tWU80AS7CJn4UwPVQfNNmdKWyWCCRTmOUZa6EgTevRGoG8v srZ5CDxNmVoAz7Faf+ObBXfcmRIrGePTB7l2dp3sBtp2HZdCWEcmqKhU5Ey/R0QPXkFr FOrg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=GP06BADX; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f89si21137330plb.20.2019.03.27.11.11.38; Wed, 27 Mar 2019 11:11:53 -0700 (PDT) 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=GP06BADX; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388572AbfC0SJ1 (ORCPT + 99 others); Wed, 27 Mar 2019 14:09:27 -0400 Received: from mail.kernel.org ([198.145.29.99]:51122 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388538AbfC0SJS (ORCPT ); Wed, 27 Mar 2019 14:09:18 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id C8E762063F; Wed, 27 Mar 2019 18:09:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1553710157; bh=92zrjK9+2OxQcwL86HWfOxqPvfxC31dI70oNFNOH2VA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GP06BADXhNoAUXKJEkHEI2ReMVit3ntLFf+L72oA9wdOcffm8b/ZRkZxpRG5kLkGj jVEi1mLYsaAUkHqu7jsJcPaGeapgbz0WjPCgfXBL8iqIsXZj2xY7cn1xtRGDhG7zvV Q+tHlh01VS+MitvdpmTWnlgejnb+tLOz5Do13wSw= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Myungho Jung , Marcel Holtmann , Sasha Levin , linux-bluetooth@vger.kernel.org Subject: [PATCH AUTOSEL 5.0 225/262] Bluetooth: hci_uart: Check if socket buffer is ERR_PTR in h4_recv_buf() Date: Wed, 27 Mar 2019 14:01:20 -0400 Message-Id: <20190327180158.10245-225-sashal@kernel.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190327180158.10245-1-sashal@kernel.org> References: <20190327180158.10245-1-sashal@kernel.org> MIME-Version: 1.0 X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Myungho Jung [ Upstream commit 1dc2d785156cbdc80806c32e8d2c7c735d0b4721 ] h4_recv_buf() callers store the return value to socket buffer and recursively pass the buffer to h4_recv_buf() without protection. So, ERR_PTR returned from h4_recv_buf() can be dereferenced, if called again before setting the socket buffer to NULL from previous error. Check if skb is ERR_PTR in h4_recv_buf(). Reported-by: syzbot+017a32f149406df32703@syzkaller.appspotmail.com Signed-off-by: Myungho Jung Signed-off-by: Marcel Holtmann Signed-off-by: Sasha Levin --- drivers/bluetooth/h4_recv.h | 4 ++++ drivers/bluetooth/hci_h4.c | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/drivers/bluetooth/h4_recv.h b/drivers/bluetooth/h4_recv.h index b432651f8236..307d82166f48 100644 --- a/drivers/bluetooth/h4_recv.h +++ b/drivers/bluetooth/h4_recv.h @@ -60,6 +60,10 @@ static inline struct sk_buff *h4_recv_buf(struct hci_dev *hdev, const struct h4_recv_pkt *pkts, int pkts_count) { + /* Check for error from previous call */ + if (IS_ERR(skb)) + skb = NULL; + while (count) { int i, len; diff --git a/drivers/bluetooth/hci_h4.c b/drivers/bluetooth/hci_h4.c index fb97a3bf069b..5d97d77627c1 100644 --- a/drivers/bluetooth/hci_h4.c +++ b/drivers/bluetooth/hci_h4.c @@ -174,6 +174,10 @@ struct sk_buff *h4_recv_buf(struct hci_dev *hdev, struct sk_buff *skb, struct hci_uart *hu = hci_get_drvdata(hdev); u8 alignment = hu->alignment ? hu->alignment : 1; + /* Check for error from previous call */ + if (IS_ERR(skb)) + skb = NULL; + while (count) { int i, len; -- 2.19.1