Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp290627imu; Thu, 10 Jan 2019 23:57:57 -0800 (PST) X-Google-Smtp-Source: ALg8bN54JQKUR48qqHcxnoPTD8KP1+fi4Kozp5QtHZVLYRo7u68r/f4XFllR3Fn+HD7wAMWDXENX X-Received: by 2002:a62:6303:: with SMTP id x3mr13889568pfb.110.1547193477885; Thu, 10 Jan 2019 23:57:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547193477; cv=none; d=google.com; s=arc-20160816; b=uhW3eUEiYhCmEYEPm6JSilMooF2D8aAcKgHiM4IiBsqTlGkNZH7avLMK7ZnmqnY++j KLKxNTr5O8nKQ0+QE0UENAt3pFnaGRYdkVfWW8G4yH5Jsr3QNVcMUl3mIN/wYArwqxcZ fqHb55XHAKBoSuBNDyduQtqS1cqt7ZMamAXi/g80BBXHRxk6mz5VJxNpsZ8YsG79aYQK 8WDXq3M3rsIcN7UudTVk9dXbbMiP28oCQMP1quws/snFhNy/FSjfPq5zeZKNavdAU4OU LL4NzM4yWLOAiA/s9NQ4Dbi61RWpVt708MEb5GB802PIApi07TdBuwHXlzVDMXpGbi0T qZpw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:content-disposition :mime-version:message-id:subject:cc:to:from:date:dkim-signature; bh=ND9+7PXVzbCVGLg9x59ZbN8q0pF2DmYmFt3qYX2lP5g=; b=05gJVYdMdlNd61wD6Zz9EFkQ/ywFHBFNBYQdCiwI2aG2atKM8M3142bis3/Dlgc2TS YOvBylCkvemxnNWlYR3wZ9klxPd2kRHXLqd4MdtRwHh0JCMSQPdFMQ2f1c5UyeiUiyR/ rBAMrEEcpQXUMq6BujXXtsLSe9/rgqohjqsoPpES2xh4iIg4+1vY/5OYzt+85cgruRCt zRo4IQKkvkhmVpITnvwxM0/kpr567ASLEyXUtaqNfA8/fE3pKQEzwqUiyMer7xp8rYEw 5IeOImXxqLYLaJ+5UiXZ+GFSaUQlHLPh/LqS2SCp/owgrXgfUpwiJdAltG4WXaOap19K FFGw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=uHDoT1IP; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a16si20402131pls.146.2019.01.10.23.57.41; Thu, 10 Jan 2019 23:57:57 -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=@gmail.com header.s=20161025 header.b=uHDoT1IP; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728781AbfAKGzW (ORCPT + 99 others); Fri, 11 Jan 2019 01:55:22 -0500 Received: from mail-pf1-f195.google.com ([209.85.210.195]:44455 "EHLO mail-pf1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725267AbfAKGzW (ORCPT ); Fri, 11 Jan 2019 01:55:22 -0500 Received: by mail-pf1-f195.google.com with SMTP id u6so6499877pfh.11; Thu, 10 Jan 2019 22:55:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:mime-version:content-disposition :user-agent; bh=ND9+7PXVzbCVGLg9x59ZbN8q0pF2DmYmFt3qYX2lP5g=; b=uHDoT1IP1XyfHKt6Pyj0gYCAyO7jux99PBGQLGKGjEbsMNfdb79UI4FA09OxnLpQWg wD3TUdh/GMve2xiLh8Pz6mME9790SVBbyiH77RFSuSuzPNUWb0ZEtyp+Z7/uXQzQfYwp IWgTyTOO6biVPKL/oBrnca21MZLjLDI3qzGGCtP7EP9qK5pnbu7rtdlqy0yTCm+q8tAE u8wxMYTE6UYMEKoIAiDsaVgzo7CBZ0h1o7hhDwv6xfKWkWtKA8cOQ1OJMVNxdxNdvTui dKaRbzBC9ipINF+htOIwDCxKDAHgsPQJXW4bk4FW1wM5aTqRZqmobEAzxJRSywUsWdnF P0BQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-disposition:user-agent; bh=ND9+7PXVzbCVGLg9x59ZbN8q0pF2DmYmFt3qYX2lP5g=; b=eboh8HQTQFYLPB0m6PU3wBMbjMFuXB6T7yXB755brxjzi5qwdJc4ndheVf0jBw+asY YrPrX9d4I99yGzxnE5VzdmB7igJDLmgfH5BWSsLFRdOZipIr5buUAnrGib9H2uEkOgFu F/hf1OqhXWjLb/7/YQYB+T5mnRdnozm8ZHT5+rWnLDd3/7MLyomjF2ygESxIbZE5KkMZ /4o69MAaOZX9HLIR5lQvGFf+5wfEr9ySwIroaiTGMo43fY5qVczpkPpPxv/X7+WIlsSC yznP+VUabSPqtNClLI6C3mCIG1fktoA6qoiEZvMeBCYR/YKsqPN288z9XRKL1Blx60hJ hmcQ== X-Gm-Message-State: AJcUukdWmDgSUlbkCKaYHybVNrC2HAYtz/qDc17Yg0teEzT3SECbo3mX 5UnmOJOOsGhlP6vpZiDUYTk= X-Received: by 2002:a63:6984:: with SMTP id e126mr12458307pgc.143.1547189720752; Thu, 10 Jan 2019 22:55:20 -0800 (PST) Received: from myunghoj-Precision-5530 (cpe-76-176-3-80.san.res.rr.com. [76.176.3.80]) by smtp.gmail.com with ESMTPSA id j9sm99456381pfi.86.2019.01.10.22.55.19 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 10 Jan 2019 22:55:20 -0800 (PST) Date: Thu, 10 Jan 2019 22:55:17 -0800 From: Myungho Jung To: Marcel Holtmann , Johan Hedberg Cc: linux-bluetooth@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] Bluetooth: hci_uart: Add a local variable to store the result of h4_recv_buf() Message-ID: <20190111065514.GA26542@myunghoj-Precision-5530> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.9.4 (2018-02-28) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In h4_recv(), if h4_recv_buf() returns error and h4_recv() is asynchronously called again before setting rx_skb to NULL, ERR_PTR will be dereferenced in h4_recv_buf(). Check return value in a local variable before writing to rx_skb. Reported-by: syzbot+017a32f149406df32703@syzkaller.appspotmail.com Signed-off-by: Myungho Jung --- drivers/bluetooth/hci_h4.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/drivers/bluetooth/hci_h4.c b/drivers/bluetooth/hci_h4.c index fb97a3bf069b..fa30ec9cebd4 100644 --- a/drivers/bluetooth/hci_h4.c +++ b/drivers/bluetooth/hci_h4.c @@ -124,19 +124,22 @@ static const struct h4_recv_pkt h4_recv_pkts[] = { static int h4_recv(struct hci_uart *hu, const void *data, int count) { struct h4_struct *h4 = hu->priv; + struct sk_buff *skb; if (!test_bit(HCI_UART_REGISTERED, &hu->flags)) return -EUNATCH; - h4->rx_skb = h4_recv_buf(hu->hdev, h4->rx_skb, data, count, - h4_recv_pkts, ARRAY_SIZE(h4_recv_pkts)); - if (IS_ERR(h4->rx_skb)) { - int err = PTR_ERR(h4->rx_skb); + skb = h4_recv_buf(hu->hdev, h4->rx_skb, data, count, + h4_recv_pkts, ARRAY_SIZE(h4_recv_pkts)); + if (IS_ERR(skb)) { + int err = PTR_ERR(skb); bt_dev_err(hu->hdev, "Frame reassembly failed (%d)", err); h4->rx_skb = NULL; return err; } + h4->rx_skb = skb; + return count; } -- 2.17.1