Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp789772ybe; Thu, 5 Sep 2019 06:05:38 -0700 (PDT) X-Google-Smtp-Source: APXvYqxJEMAeBEPAFV2uwAKk0/MohF2xD8i+wHXxJ3OS5qUySq3kN8tCSVrMzoGVXSJEp1+xNbIi X-Received: by 2002:a63:5f95:: with SMTP id t143mr3043065pgb.304.1567688738175; Thu, 05 Sep 2019 06:05:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567688738; cv=none; d=google.com; s=arc-20160816; b=CedsfyHR5pJ3cGri0epzTsobv0PWo+UwLzQ4WnVpM61ck+/nigA8kGUUVEdqRB78wV 8j0i2Tda8Fzq4CuDCtQVUWNI0vN7+RI1KqwajvMopI0rPrTTLw49OJySlJM0Zula2/C0 snqNkJzBKSUGNJYQQgOIeQcC0H2DoRZ6Mk0XJe+cdOxFetggF6Vt7YMsZQgcZPm/Bc2t vh61w2TahJ7xW+nOcZJ5KqcXEwwWMQRUsHAx5dq9ryoIxzhq4QrtOAO0HF3NbXqdAYEQ 5DQHAyY90+DzGg8SzO1UA6Wa499rLalaKF4krRCp2HU/V0PGDhzRqaKYXXpm/UEunnx/ banA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=oautEYXJNPg/LAxxq6KlzXzuc7s3EzH8MSqml3mnlFM=; b=aet/khq/q8bfmu/GMNPHa3ev3ndMCba7j1bLTgydZnmNmHTSAWwHWgF/K6e6GxhfEP Hxt1y7gABrvSG53PtbJ2gjl24tNXlsnkVEYj2ZfkK1a9OejKEeYromZjjW6DAptldf7u bET3wI+l6C/fYPOsbcxXhYjJBRLAKigx9uwbQi83Ayf2QEcOkQWBcuvTEa4zNXufIBYK RzuRC8OkI33qa2Gk2Z47BxTnSxoTVhOKmAbdAgPXq4l4Bd0p/SVqoTKJ6GChnEwJVTvo hftuSEHZ4+BtC7JAfStve1nq/KL9DHpAypVA5TUx3HL5eHwvI3GZxZs415KMn3D7iBcT ihZw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=LBAX7V6D; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o71si2029869pjo.53.2019.09.05.06.05.21; Thu, 05 Sep 2019 06:05:38 -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=@google.com header.s=20161025 header.b=LBAX7V6D; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388364AbfIELYg (ORCPT + 99 others); Thu, 5 Sep 2019 07:24:36 -0400 Received: from mail-pl1-f195.google.com ([209.85.214.195]:44166 "EHLO mail-pl1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726162AbfIELYe (ORCPT ); Thu, 5 Sep 2019 07:24:34 -0400 Received: by mail-pl1-f195.google.com with SMTP id k1so1139010pls.11 for ; Thu, 05 Sep 2019 04:24:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=oautEYXJNPg/LAxxq6KlzXzuc7s3EzH8MSqml3mnlFM=; b=LBAX7V6D1Th2QUfX/hRQEHFvGDknVdyFkdXkIGgUFkxAk71cJS7G6lToozs2iu8Mu8 IQTQRSRqI+MDORXMr1YoTANBKUF9rZYD55NsSR7xubUHPn/sanRnQw/RSlfnvoEyfpzk DsWs4tEgDfO6hnU9U9z5vTyNFILRWeenXG8IP/D+2Y9DHv8+KxklGSvCJDobVsdLzwbf pnsqLg/MeGCE0evJfnekkkkUrBQPaO2jyzEMoKp5p7+W59kPOzCkq1W2a7hPII36GUs0 n+Yx9VprJg/gWKbZz+kda/jHxDOGXMZRgVkj7CPp2//Roi+nGzE/ckhwkFRGyiINfNc+ 5OsA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=oautEYXJNPg/LAxxq6KlzXzuc7s3EzH8MSqml3mnlFM=; b=f0yUrSgQaarpMSeE/kHD2XQWz3923Kuc0e1HdBH/0/Ea7xCiQpkafMwV039IRrN0rP khKUSSRD2xmIBuZ8DRODUL2jkqV/QfXj0TXcUGsKMybRkor6dE1m8z/AlqvNJYs5G26U gr2tCjDH5NrwHkBbQvG6o0YbtT3h1Brp/+yd4tp0FVqSTn9c9IPQ9lBECIWJswkniUje Evv9S7dTI29hTK/kwFZxB4fDM7qtY8trU2F53McgaJYOsirKzvFPFCPRXSLTqbdm98tZ sI6c0ygCO45lh6EpiFLc1pNF2Vk50fK4P2zMmGLKb+vjoKX5hPIp8/+H1BqXeikQKz3p AQUA== X-Gm-Message-State: APjAAAUUUJSSmPfCr70pOJOJXLcWyJihpQ+dXrQRhaUzJVyjEPtJp7mk Dqa3Vk7tuhpHjU/WKVtoWi8m0lts+J0fNtU4/dtWUw== X-Received: by 2002:a17:902:8c92:: with SMTP id t18mr277036plo.147.1567682673098; Thu, 05 Sep 2019 04:24:33 -0700 (PDT) MIME-Version: 1.0 References: <0000000000002a95df0591a4f114@google.com> <20190904154140.45dfb398@hermes.lan> <285edb24-01f9-3f9d-4946-b2f41ccd0774@gmail.com> In-Reply-To: <285edb24-01f9-3f9d-4946-b2f41ccd0774@gmail.com> From: Andrey Konovalov Date: Thu, 5 Sep 2019 13:24:21 +0200 Message-ID: Subject: Re: WARNING in hso_free_net_device To: Hui Peng Cc: Stephen Hemminger , syzbot+44d53c7255bb1aea22d2@syzkaller.appspotmail.com, alexios.zavras@intel.com, "David S. Miller" , Greg Kroah-Hartman , LKML , USB list , Mathias Payer , netdev , rfontana@redhat.com, syzkaller-bugs , Thomas Gleixner , Oliver Neukum Content-Type: multipart/mixed; boundary="000000000000dabb730591cc9008" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --000000000000dabb730591cc9008 Content-Type: text/plain; charset="UTF-8" On Thu, Sep 5, 2019 at 4:20 AM Hui Peng wrote: > > Can you guys have a look at the attached patch? Let's try it: #syz test: https://github.com/google/kasan.git eea39f24 FYI: there are two more reports coming from this driver, which might (or might not) have the same root cause. One of them has a suggested fix by Oliver. https://syzkaller.appspot.com/bug?extid=67b2bd0e34f952d0321e https://syzkaller.appspot.com/bug?extid=93f2f45b19519b289613 > > On 9/4/19 6:41 PM, Stephen Hemminger wrote: > > On Wed, 4 Sep 2019 16:27:50 -0400 > > Hui Peng wrote: > > > >> Hi, all: > >> > >> I looked at the bug a little. > >> > >> The issue is that in the error handling code, hso_free_net_device > >> unregisters > >> > >> the net_device (hso_net->net) by calling unregister_netdev. In the > >> error handling code path, > >> > >> hso_net->net has not been registered yet. > >> > >> I think there are two ways to solve the issue: > >> > >> 1. fix it in drivers/net/usb/hso.c to avoiding unregistering the > >> net_device when it is still not registered > >> > >> 2. fix it in unregister_netdev. We can add a field in net_device to > >> record whether it is registered, and make unregister_netdev return if > >> the net_device is not registered yet. > >> > >> What do you guys think ? > > #1 --000000000000dabb730591cc9008 Content-Type: text/x-patch; charset="US-ASCII"; name="0001-Fix-a-wrong-unregistering-bug-in-hso_free_net_device.patch" Content-Disposition: attachment; filename="0001-Fix-a-wrong-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