Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp5026022imu; Sun, 20 Jan 2019 01:47:19 -0800 (PST) X-Google-Smtp-Source: ALg8bN4Js6BbSh03nZLEmA1kN+0M3ZOisxxbgU0wS0WdB43Y5DOSUrZ97uRpEZJLc6oh4kKbbd8/ X-Received: by 2002:a63:5b1f:: with SMTP id p31mr23932989pgb.56.1547977639578; Sun, 20 Jan 2019 01:47:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547977639; cv=none; d=google.com; s=arc-20160816; b=LKmzjeDTt2Aj3aaUHzQCeLcUwGlCmKgLjnHPQquPGyzpBRP799+X6lUk9TmsVuWQmc MJgVhSYwgx/ccxYtXs8ytIPbYPyg9KnSIWONR7pMClSFM1PnST8sLNIhnfrJPspbJM4Z O+zG1kuEEIXfdXegfmRty19tbilZT8la20qKmBv4VZUA0WM1LF2A5ASjAGMk9IODC7YP JblQpUfPSYeLyFkjEXLMp77abyvLyr++ulRcUWQfxXfURrXAsoQbXN2n7IOd0c863fnQ cshMXlY4qk2cx6XXVh9Jdo8VpxQOsHz2whds3Zu+lb+uMlEven7kEbOI1+L8pJvEkzud g+YQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=Uuj5qeyPQRNMgSOvskIjreOxX4tQJ5q841j1HWFRaJs=; b=j2yMbysbHVRVeFc9/BNKsVJVB2JnEUZvY0hIoVPi1f1Mrmg4WuOi/nvJwVWrVo7hnu IAE4bZMr1XUcdpDywUjLy8LHiRRLcLWDdDQinKD934Ip5pSb5kgX9QaEm18vUL1HFz/e 6sm+k+aAVR0d0v2TjEQYO8KG0P/Di05TsCvOi+aD0lIIvHFh1HyVBYJ8XPEJku8Pp1wV vVZCXnMelQAabZ+v9I+yeTGlUXLYhDg7d+IvV+RSyOTi0OGJ/xLeA0zXvQxbXWngo4Ch WgToLNpfqlvwjjPQ7egZtHUqMhwbZvKcNxeQn6iNsRDAaKzWUq2kvP+kR06UuVsnCTwM ab7w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=B+ETn9eF; 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 b6si9458078pgm.216.2019.01.20.01.46.51; Sun, 20 Jan 2019 01:47:19 -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=B+ETn9eF; 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 S1730478AbfATJpH (ORCPT + 99 others); Sun, 20 Jan 2019 04:45:07 -0500 Received: from mail-pl1-f195.google.com ([209.85.214.195]:44623 "EHLO mail-pl1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730461AbfATJpF (ORCPT ); Sun, 20 Jan 2019 04:45:05 -0500 Received: by mail-pl1-f195.google.com with SMTP id e11so8338389plt.11; Sun, 20 Jan 2019 01:45:05 -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:references:mime-version :content-disposition:in-reply-to:user-agent; bh=Uuj5qeyPQRNMgSOvskIjreOxX4tQJ5q841j1HWFRaJs=; b=B+ETn9eFnkyGXbFKkShNkgobCVLVyCEk0x5FgM3WdrFeu3QsQGg9Xzd2rJrZuKZ874 MOujsPAfYoLda8eenq7wGYdvxB0jGJ9GDkJ0Zt6sqMIfk1OfG6+C9++OcDPmS6/d9UVY xHTdfxgHvssX2Gg5rtEVveNOjwmH2EfXZ4VPnz6kbcNmCbwnSQJ991vYPedvUIz93BEm wDGN9xHXFqUmIJPBtLBpI8a1xUHlytXDtTIvdkJGYMO8BGjRNmvk3mKZjh9v2af4Ujbl HQGWaBbYrvQXnlgwTwjTQa9QX7wC7/OIN3gy5OBlVfuyNfQDFBixqmRuD0Gqs/FzIZf+ kwOQ== 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:references :mime-version:content-disposition:in-reply-to:user-agent; bh=Uuj5qeyPQRNMgSOvskIjreOxX4tQJ5q841j1HWFRaJs=; b=JtuxPsFxfT8v4g2VVbeP6TA5v8mBC1JXsfb0NEdY8vzaqpO0YqC+yj06xvsPK6MIFO g/to/qpl3QntuLdNvUjbBxbXuPz4+DSASo3n24EVm241GCaW2K1rM5yPxBexh8o21flJ gEazSDx5TAWTjsdyr0izphG07MKBoWveCugU2tYh+N/AMVdOw6A2tnR+RrxPAW6Pkv/k h28zDa+aT63I3TlIRGz0QGS6cd6qfmdi71bd/05BB5FDr0HRVZZNfGg+9dV3He2BZyzk U6I0CL0q8x/oRDNR44eg94HvRxFBAn/RSUz8GZyqeHd9P2HrDxRGVR17o5Xj6a7OAhHa ZEeA== X-Gm-Message-State: AJcUukf75O2MVXu/cEVVsDggAQGip0XyEsK/FwgDIeWeql1Eole8i1Od svbjS/4YUPvl7KTBGcqIdmw3Nxs6 X-Received: by 2002:a17:902:128c:: with SMTP id g12mr24656538pla.146.1547977503984; Sun, 20 Jan 2019 01:45:03 -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 m3sm19444921pff.173.2019.01.20.01.45.02 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 20 Jan 2019 01:45:03 -0800 (PST) Date: Sun, 20 Jan 2019 01:45:00 -0800 From: Myungho Jung To: Marcel Holtmann Cc: Johan Hedberg , linux-bluetooth@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] Bluetooth: hci_uart: Add a local variable to store the result of h4_recv_buf() Message-ID: <20190120094459.GA22129@myunghoj-Precision-5530> References: <20190111065514.GA26542@myunghoj-Precision-5530> <09FCB21A-2184-4CDB-8BF0-75C403DF39F9@holtmann.org> <20190119081919.GA10681@myunghoj-Precision-5530> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190119081919.GA10681@myunghoj-Precision-5530> 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 On Sat, Jan 19, 2019 at 12:19:20AM -0800, Myungho Jung wrote: > On Fri, Jan 18, 2019 at 10:19:41AM +0100, Marcel Holtmann wrote: > > 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. Thanks, Myungho