Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp4951703pxb; Mon, 15 Feb 2021 05:52:29 -0800 (PST) X-Google-Smtp-Source: ABdhPJxDy/2JfxUnuuScz/1yBa4F0/5mBSKGOBkYmDkE6wNZXbjeLCNJMES96I6UxDgIQF+S7csy X-Received: by 2002:a50:8b66:: with SMTP id l93mr15298549edl.384.1613397149498; Mon, 15 Feb 2021 05:52:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1613397149; cv=none; d=google.com; s=arc-20160816; b=JI4fo5Noxg1mP1KH3Jxisp5HXCXvD//PFsxN89EB4oVVH6SJNimcbjD5hhaofVbanP YD7Od0pYC7v9L52XR8r4XvmNdmxwZNASSfWjT13TGpsiPzAwFZ9/UK/38c7ZwTJebo9E 8tysytS5Ukz4Ab77GpaAvtYLjHUleZ+w1XJWMnpZmVgp/+RlrT656+DDFcYZww6iPqfD BSPn1L+DNSYSY8e2hhsa7glgkn3fQmu19pbk4RSp+l95TAb+KsekF+XE8p1OqY5gHfg3 APr9v+CF/akFSlOzesb+yo6xjDJy2+gC7kxXYIR5Gt9ZuUwi7f/0H12f7KfLHHQKuOJh OB8Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=dUY/mk1Lc8G78pgBS2Mx3NjfEuV+qgOPeV5BhtagDQU=; b=bDTKEgqUVAG4KnQbD9QKk2z7uXVVqEImnMlnwNubm9AmkcraJXQJHX/jPsPQ1BRHqx UwrVN3/zCTtaHqieUzMT8Gyirn7CkXZbbJwoKjRVeEZ4Pu4dUutvaV/Z/CVa3Fr5kSej 88JTKd4wJGgNg0vglcSeqNq0SotOF4JDiX07oJs7YcPy3/aU9BX7OgqCnHOGlNY7eRZn tTHSvtZugpW3jThynSClHoZQzJ3eR/UTCKlgNwS6z7MUA45EoNLCngxR6Sb2rG3PAsdC NNLieGq//ZqxXFwQ15X982j/RK+BDZM1UD5YOjr9YWqTBWmAFDgFdNMVqJl8ykk34Rm8 fSdg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="d3oq4pH/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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. [23.128.96.18]) by mx.google.com with ESMTP id p17si4093444edu.119.2021.02.15.05.52.04; Mon, 15 Feb 2021 05:52:29 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="d3oq4pH/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S230098AbhBONvE (ORCPT + 99 others); Mon, 15 Feb 2021 08:51:04 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45336 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230420AbhBONug (ORCPT ); Mon, 15 Feb 2021 08:50:36 -0500 Received: from mail-qk1-x730.google.com (mail-qk1-x730.google.com [IPv6:2607:f8b0:4864:20::730]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5739FC06178B for ; Mon, 15 Feb 2021 05:43:27 -0800 (PST) Received: by mail-qk1-x730.google.com with SMTP id t63so6387570qkc.1 for ; Mon, 15 Feb 2021 05:43:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=dUY/mk1Lc8G78pgBS2Mx3NjfEuV+qgOPeV5BhtagDQU=; b=d3oq4pH/F36Pnfxw8LFnft/6C40f2NyuTx5tsiCjUqEJuMfkxR0hMYfxwrsSdiYDLw z7jOcR5Dx21ni9aFGTLRqqLZhS3AgAIG5Rj67PA4/Bt+6LNqZyGI+p/jkjh/KsJ1qa8J L9PURCEku8u+32fSdUmg3Z5e8GghXQfbDoi761K9lDi7XgsvjP7Z4qJIS9fXZGKXET0E /8kRQPjAWSM2zqrNguwD0S5cS0yAz079SdrpN730F6QIXDUfqMdkKo5wZNuKF61+HG7T d5VoAmgUcdUBNFrucfXposBo9VKXiAAjyo0NmTvj/5xsx0y5HOVzVCdLzXP/TirzSZLQ Mi4w== 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=dUY/mk1Lc8G78pgBS2Mx3NjfEuV+qgOPeV5BhtagDQU=; b=a0bredBxecpbWTX1fUUPGgme8CUEzlB5yk+My7WZMTmoY0fdHrrtVW88G0pJznbGej Czt+0QpEAqE1HMh3hzoXFWEVtYv7awAtgNFzauabRFyNOohGyDnPijmagQzoSvDBzm0w 5IJbBFKt+99VdCDoay4LGMEjVIwXs+rMosLJTCR3K++pEvSfy8FtjnIBB8sZ+TSP1/8M 61jqj1O+sfUFeuK2fwBeuahLYjrBurhbG2eoyr+XiOOuVd2XpOR3osRzBkuMWC+AvMKH 2PvzlGXdEHBYIzjpfoBxZ4N66DahuJPa9EDU9GqlQhOL5DxMSAH/ggqTLfX1zJYiO6AW 5Ztw== X-Gm-Message-State: AOAM530tI/nxgbcijGuEvFlu9zqmdPqPc2zvVdF8fiJ6SGjzBDL/gGQQ 8Kk7z2TiYWfgbSF3HSatjdkk+SvfVCTiB+DmCT8= X-Received: by 2002:a37:a20b:: with SMTP id l11mr6003460qke.237.1613396606583; Mon, 15 Feb 2021 05:43:26 -0800 (PST) MIME-Version: 1.0 References: <20210127200319.662842-1-tomas.winkler@intel.com> <1776363776.325713.1611782270873.JavaMail.zimbra@nod.at> <1665542284.336646.1611820031174.JavaMail.zimbra@nod.at> <20210128100032.5eb542c6@xps13> <10c2e98c393a486cab3bc953e9926e38@intel.com> <1363048722.339069.1611865409332.JavaMail.zimbra@nod.at> <783a45b0bc04483e9a0a6bb0a083bccb@intel.com> In-Reply-To: <783a45b0bc04483e9a0a6bb0a083bccb@intel.com> From: Richard Weinberger Date: Mon, 15 Feb 2021 14:43:15 +0100 Message-ID: Subject: Re: [PATCH] mtd: use refcount to prevent corruption To: "Winkler, Tomas" Cc: Richard Weinberger , Miquel Raynal , Vignesh Raghavendra , linux-mtd , linux-kernel Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, Feb 13, 2021 at 6:12 PM Winkler, Tomas wrote: > > Well, the trick in glubi (and other MTDs with "hotplug" support) is not to > > reject removal of the sub-device. ->_put_device() is of return type void. > > The key is grabbing a reference on the sub-device in ->_get_device() such > > that the layer below doesn't even try to remove while the MTD is in use. > > I understand that. But in that case the kernel is in the mercy of user space to close the handle, > the whole perception here is that of hotplug that the device is physically removed it cannot wait > for the user space to complete. What's the fix is trying to do is to bail out gracefully. > > > > so we postpone the mtd unregister to mtd_info->_put_device() but it > > > that state we have nothing to hold on as the device is gone in > > > remove() User will fail anyway, as the underlying device is not > > > functional in that state. > > > Anyway I've tried your suggestion, the kernel is crashing, hope I > > > haven't done some silly bug. > > > > Can you point us to the affected code? > > This would help a lot to understand the issue better. > > I'm sure we can find a solution. > > Got green light on releasing the patches will send soon. I'm eager to see them. :-) As said, I'm sure we can find a nice solution. -- Thanks, //richard