Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp737756imm; Mon, 9 Jul 2018 09:42:59 -0700 (PDT) X-Google-Smtp-Source: AAOMgpeIiLTH2uQFdvtUpAaN7tEfMNep7dPdSgfJWTuTxHElP0I/zO1jK0/QvJbrF1HxYUM/CMPe X-Received: by 2002:a63:383:: with SMTP id 125-v6mr13789963pgd.421.1531154579327; Mon, 09 Jul 2018 09:42:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531154579; cv=none; d=google.com; s=arc-20160816; b=rzSRAWuCMRi75V+XdLGnC9HPLvhWWdo+lkh1Rt6nhWoZAieJEObi8tr6CBtaVzcJsT l2ZODaBI5pVeGmBEO5kYE07/dv5StIls+ljqyFXBBZBO3KbUIZh1lwnDtKoi7ZgbXu2j +YgysuiMp7IKhX2PShWE2NQ6NbJG/FCrG/Awo4kfhSXYhbbGeiaucID1B2UPKZM1/brD xXnxdCUIcdj8XpQdtFDeUYtCYnKn0YsSOFwVSNIUTy3/MmMK7nPnYNji+ugkV8ZP+wEQ 8uW9/67jTpW0qZRDNsCYSIaWOh6O+vD2tELq9rhO2X4Q1eRtRVgjhJegGtIdaorgbunp uoSQ== 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:in-reply-to :mime-version:user-agent:date:message-id:from:cc:references:to :subject:arc-authentication-results; bh=B2E+9K9Fbs70hM1LvnzTB9oNqZ18UJsDBn2XFUgSwKA=; b=VhYmojfi6Yitw6JuQimH1E+ZswA45kSwkAB9IV6hnNtivXu2inFWPA9I1zv95rgUDC C0PiHWgy5gzevAGT8m7pIqvI34o5IgF4u1yhJNAUAsiNPe3PT/4ndzkUYt5GNkOTv3cJ sUmsFH4llo/kwy1QY2bcZq0d84EUJxETNC5OE86iwqezFtIQRh9JqyAHYi7vscmEdn9S +zkoI/OL7dExafR/vZR4dX1Wfuf1nqKIUjlTJ2xixMjD5Zt2qwAfRm1ejetk/N2x1bQT Zzl6zF4qPPLSyEXYzEvLRWtXVGnTSwzaGBXoET/y1qaeWXA/lT45lUQk6snlnUVkJXrO NG+g== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o3-v6si14032615pgr.521.2018.07.09.09.42.44; Mon, 09 Jul 2018 09:42:59 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933573AbeGIQk2 (ORCPT + 99 others); Mon, 9 Jul 2018 12:40:28 -0400 Received: from mx1.redhat.com ([209.132.183.28]:43168 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933009AbeGIQk1 (ORCPT ); Mon, 9 Jul 2018 12:40:27 -0400 Received: from smtp.corp.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.26]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 0FFC3C057FA1; Mon, 9 Jul 2018 16:40:27 +0000 (UTC) Received: from [10.10.122.164] (ovpn-122-164.rdu2.redhat.com [10.10.122.164]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8CFA5300193B; Mon, 9 Jul 2018 16:40:25 +0000 (UTC) Subject: Re: [PATCH v3 3/3] uio: fix crash after the device is unregistered To: Xiubo Li , gregkh@linuxfoundation.org, linux-kernel@vger.kernel.org References: <1530845836-49101-1-git-send-email-xiubli@redhat.com> <1530845836-49101-4-git-send-email-xiubli@redhat.com> <5B3FBBF1.9080902@redhat.com> <434b1b7c-604d-a446-b73a-8de7a50817c5@redhat.com> Cc: hamish.martin@alliedtelesis.co.nz, jannh@google.com, pkalever@redhat.com, pkarampu@redhat.com, atumball@redhat.com, sabose@redhat.com From: Mike Christie Message-ID: <5B438FF3.4040707@redhat.com> Date: Mon, 9 Jul 2018 11:40:19 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.6.0 MIME-Version: 1.0 In-Reply-To: <434b1b7c-604d-a446-b73a-8de7a50817c5@redhat.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.84 on 10.5.11.26 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Mon, 09 Jul 2018 16:40:27 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 07/06/2018 08:47 PM, Xiubo Li wrote: > On 2018/7/7 2:58, Mike Christie wrote: >> On 07/05/2018 09:57 PM, xiubli@redhat.com wrote: >>> void uio_event_notify(struct uio_info *info) >>> { >>> - struct uio_device *idev = info->uio_dev; >>> + struct uio_device *idev; >>> + >>> + if (!info) >>> + return; >>> + >>> + idev = info->uio_dev; >>> >> For this one too, I am not sure if it is needed. >> >> uio_interrupt -> uio_event_notify. See other mail. >> >> driver XYZ -> uio_event_notify. I think drivers need to handle this and >> set some bits and/or perform some cleanup to make sure they are not >> calling uio_event_notify after it has called uio_unregister_device. The >> problem with the above test is if they do not they could have called >> uio_unregister_device right after the info test so you could still hit >> the problem. > > When we are tcmu_destroy_device(), if the netlink notify event to > userspace is not successful then the TCMU will call the uio unregister, > which will set the idev->info = NULL, without close and deleting the > device in userspace. But the TCMU could still queue cmds to the ring > buffer, then the uio_event_notify will be called. Before tcmu_destroy_device is called LIO will have stopped new IO and waited for outstanding IO to be completed, so it would never be called after uio_unregister_device. If it does, it's a bug in LIO.