Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp6312894imu; Mon, 21 Jan 2019 06:51:01 -0800 (PST) X-Google-Smtp-Source: ALg8bN6UXjCgxxGqIiPdJbrwXMLGSi8HN3AihOcbsnYL6ki++gmov53LveY7rVYEvQjGYr2ASasB X-Received: by 2002:a17:902:2aa8:: with SMTP id j37mr29282673plb.226.1548082261110; Mon, 21 Jan 2019 06:51:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548082261; cv=none; d=google.com; s=arc-20160816; b=tDxw7bVrivhbQWyr/uEwyE1t03G5fZrG1Tkt3RriBsqJq/aiLYRF4c2zzJ87dPAQgU r1Ck0wU4+y4WcOCXBI3Y+bUDKtmLdNk6o33ypy7+EoKezoWZmLJ3Qa/dTY5/vRVgs5sI MH8lLwnRUQYvJ/0RaO/0/Ok/MiXz6R802iYKVV03Vwy99CaKX7mnA1PspScmwqey+WHB vLMubFLt6LZCxlgH9elME/D4K3WcTODMb0CPSbM//qNj34XEA1/4zf8uW7lwwIthX3BW CqupCDmUEkRDmS1a/Lqy/QTQ0843igyxNTAUFv+lL/XkVf4pVC0zZqnynmBfUn4d6jQ+ Jeyg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:to:references:message-id :content-transfer-encoding:cc:date:in-reply-to:from:subject :mime-version; bh=MxR31reX4L0tF1Rf6Sz1p90XO4C1r8bTtfJuV8Hgy2c=; b=0+Aj9nEUNHE+Wwlh9EhsbdsAd8yElDkeSba2yaj37/YlgSDYnCG0qnSErDvFHxYLBq fBsivGMQca4mLA5HygcHk8RUJgiCh590GRJUjUHOugh11UBcv9IeogWDEDgMowj7r2/l vtQMQ3BHnGdZdrbrDF5JVpABpbU4HsmgSBjjsRkhG9mr07JS1BEVfzAuo1H9OWD4LXpy 5aRqR66MlPjis7RsVWsxPEhZ0GfSoK6CB7e5KJcemFXHWdMmk3bn5h2QrFvKWaT8ah9Z BHJP6DHXBDY900R1R+mfYwYYAuU842ERVDD97ZLCfnj8cGrMY2IfeZrpDoJdO7LUY/c7 njeg== ARC-Authentication-Results: i=1; mx.google.com; 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 g17si12293739pgi.578.2019.01.21.06.50.45; Mon, 21 Jan 2019 06:51:01 -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; 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 S1729628AbfAUOsh convert rfc822-to-8bit (ORCPT + 99 others); Mon, 21 Jan 2019 09:48:37 -0500 Received: from coyote.holtmann.net ([212.227.132.17]:33519 "EHLO mail.holtmann.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729072AbfAUOsg (ORCPT ); Mon, 21 Jan 2019 09:48:36 -0500 Received: from marcel-macpro.fritz.box (p4FF9FD60.dip0.t-ipconnect.de [79.249.253.96]) by mail.holtmann.org (Postfix) with ESMTPSA id 9B3D1CEE94; Mon, 21 Jan 2019 15:56:21 +0100 (CET) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 12.2 \(3445.102.3\)) Subject: Re: [PATCH] Bluetooth: hci_uart: Add a local variable to store the result of h4_recv_buf() From: Marcel Holtmann In-Reply-To: <20190120094459.GA22129@myunghoj-Precision-5530> Date: Mon, 21 Jan 2019 15:48:34 +0100 Cc: Johan Hedberg , linux-bluetooth@vger.kernel.org, linux-kernel@vger.kernel.org Content-Transfer-Encoding: 8BIT Message-Id: References: <20190111065514.GA26542@myunghoj-Precision-5530> <09FCB21A-2184-4CDB-8BF0-75C403DF39F9@holtmann.org> <20190119081919.GA10681@myunghoj-Precision-5530> <20190120094459.GA22129@myunghoj-Precision-5530> To: Myungho Jung X-Mailer: Apple Mail (2.3445.102.3) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Myungho, >>>> 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(-) >>> >>> patch has been applied to bluetooth-next tree. >>> >>> Can you actually fix all callers of h4_recv_buf since they all suffer from the same issue. >>> >>> Regards >>> >>> Marcel >>> >> >> Hi Marcel, >> >> Sure, let me check other callers and fix them if applicable. >> >> Thanks, >> Myungho >> > > Hi Marcel, > > I found there are many callers that need to be fixed. So, how about checking > error code in h4_recv_buf() instead? > > diff --git a/drivers/bluetooth/hci_h4.c b/drivers/bluetooth/hci_h4.c > index fb97a3bf069b..dea48090d2dc 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 if socket buffer is not reset yet from previous error */ > + if (IS_ERR(skb)) > + skb = NULL; > + > while (count) { > int i, len; > > > It is tested and verified by syzbot. The previous commit is no more needed if > this looks better. please send a proper patch for this and also don’t forget drivers/bluetooth/h4_recv.h since these two are not yet consolidated. Regards Marcel