Received: by 2002:a05:7412:251c:b0:e2:908c:2ebd with SMTP id w28csp1050328rda; Mon, 23 Oct 2023 00:10:05 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFzcHTN73Q/nTvD6PQ0fhF6Ws6mjqGGT002Wf7GFBDBMZnXNfW4j8pHaEG5SlYbDr/oYIJU X-Received: by 2002:a17:90b:1214:b0:27c:edd6:b08d with SMTP id gl20-20020a17090b121400b0027cedd6b08dmr5734580pjb.24.1698045004714; Mon, 23 Oct 2023 00:10:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698045004; cv=none; d=google.com; s=arc-20160816; b=dex4Y6wg1ajoaKlFWlTnn4X6dQBmGPhgFMqooEziEhKYV4Hq3AHhqUZZ3OMHGd16ii lttM38orU2dY3NmXU33H3klEqamc5FU8eJPBfXxe/sDM/OgWOmOufPYufS1I4nZ8LdRs BEJaiOOLSN5C7U9OUkLwjdQR1LtYwDQUdRvnaCFnW7NIzG1JVtcwk8CERcC4gCkcv2MC pBCwgu6k9dGrE2CZtWz/xZciaakSv7R5szpn/JNek5Jra1w6qdsQ8Bb45Tdo44BAkQ5T 4s7Lcu4zXfJYUo+Lcxysmg/fAlyK6kbS/BecPWFRf8qsSkJmefR4P+zxWobGPgsoG4sE Mvvw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to :mime-version:user-agent:date:message-id:from:references:cc:to :subject; bh=0XjAUjVxfJW5ctykFAqrANAo/QWMOGfSrzn/i65Pd60=; fh=hS8FnZAZ9OINvZSmU8bstjCHl/CMPLx205fs0npgqfQ=; b=rorQhVUj4H1Jpc/JLWyWsXTOPAQvPZTe70HUR/mK6rYb4gWwYKVSUkHcPBUaI6OqpR p2hK+e1lsArIS0I61ghFIOsFo9Cq6FIi/pml4A6Sf9QmWqkC2ayFZoV3SnSwwv3E5CDj E3kP6qDWlYvOi8PiA8lEkONUChpHbWODCV0kDJ40vx7m0teTAfIc1YUY2gX1834oBaWw OQBdGZnt3QAc+jMi8/0AWJp1RGXxbDDMHeGG2e8lMPMWolxD7MW/kxjWuh5IKOhOR90q 7OxD4Mu9VyCUmiIHgjKA/jAa8FbQFjhrZeAOCpjIkjC4Tq8V08AjeIK1wwzmPC7ud7cT vuNQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from howler.vger.email (howler.vger.email. [2620:137:e000::3:4]) by mx.google.com with ESMTPS id o14-20020a17090ab88e00b0027d22503b9esi6059788pjr.84.2023.10.23.00.10.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Oct 2023 00:10:04 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) client-ip=2620:137:e000::3:4; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id 4B5C98068591; Mon, 23 Oct 2023 00:10:02 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229769AbjJWHJq (ORCPT + 99 others); Mon, 23 Oct 2023 03:09:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50122 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229450AbjJWHJp (ORCPT ); Mon, 23 Oct 2023 03:09:45 -0400 Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C30BB8F for ; Mon, 23 Oct 2023 00:09:41 -0700 (PDT) Received: from kwepemm000013.china.huawei.com (unknown [172.30.72.56]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4SDR6J1gtnzMmC4; Mon, 23 Oct 2023 15:05:28 +0800 (CST) Received: from [10.174.178.46] (10.174.178.46) by kwepemm000013.china.huawei.com (7.193.23.81) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.31; Mon, 23 Oct 2023 15:09:38 +0800 Subject: Re: [PATCH v2] ubi: gluebi: Fix NULL pointer dereference caused by ftl notifier To: Richard Weinberger CC: ZhaoLong Wang , Miquel Raynal , Vignesh Raghavendra , dpervushin , Artem Bityutskiy , linux-mtd , linux-kernel , yi zhang , yangerkun References: <20231018121618.778385-1-wangzhaolong1@huawei.com> <1381458025.20897.1697747248632.JavaMail.zimbra@nod.at> <891e554b-c133-6378-3a65-836fc9147e54@huawei.com> <441107100.23734.1697904580252.JavaMail.zimbra@nod.at> From: Zhihao Cheng Message-ID: <93b2d5ab-e36c-be08-7343-ef4ca16f991d@huawei.com> Date: Mon, 23 Oct 2023 15:09:26 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.5.0 MIME-Version: 1.0 In-Reply-To: <441107100.23734.1697904580252.JavaMail.zimbra@nod.at> Content-Type: text/plain; charset="utf-8"; format=flowed Content-Transfer-Encoding: 8bit X-Originating-IP: [10.174.178.46] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To kwepemm000013.china.huawei.com (7.193.23.81) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-4.1 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on howler.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Mon, 23 Oct 2023 00:10:02 -0700 (PDT) 在 2023/10/22 0:09, Richard Weinberger 写道: > ----- Ursprüngliche Mail ----- >> Von: "chengzhihao1" >>>> Such a modification currently works because the mutex "mtd_table_mutex" >>>> is held on all necessary paths, including the ftl_add_mtd() call path, >>>> open and close paths. Therefore, many race condition can be avoided. >>> >>> I see the problem, but I'm not really satisfied by the solution. >>> Adding this hack to gluebi_read() is not nice at all. >> >> Yes, it's jsut a workaround. At the begining, I prefer that increasing >> volume refcnt (by ubi_open_volume) in gluebi_create and releasing volume >> refcnt in gluebi_remove. It looks more reasonable that holding a refcnt >> of UBI volume when gluebi is alive. After looking through the code, the >> creation/destroying of gluebi is triggered by volume >> actions(UBI_VOLUME_ADDED/UBI_VOLUME_REMOVED), which means that: >> 1. gluebi_remove is depended on UBI_VOLUME_REMOVED(triggered by >> ubi_remove_volume) >> 2. ubi_remove_volume won't be executed until the refcnt of volume >> becomes 0(released by gluebi_remove) >> >> If we add new ioctls to control creation/destroying of gluebi, then >> gluebi mtd won't be automatically created when UBI volume is added. I'm >> not certain whether this change will effect existing startup process >> that depends on gluebi. > > Let's take a stack back. The sole purpose of gluebi is providing > a way to run JFFS2 on top of UBI. Is it possible that someone runs ext4 on mtdblock based on gluebi, for the advantage of wear-leveling? > IMHO there is no need to run an FTL on top of UBI or even mtdblock. > This kind of stacking does not make sense. > > So, I'd go so far and propose the following: > diff --git a/drivers/mtd/mtd_blkdevs.c b/drivers/mtd/mtd_blkdevs.c > index ff18636e08897..b362a64411ebd 100644 > --- a/drivers/mtd/mtd_blkdevs.c > +++ b/drivers/mtd/mtd_blkdevs.c > @@ -463,7 +463,7 @@ static void blktrans_notify_add(struct mtd_info *mtd) > { > struct mtd_blktrans_ops *tr; > > - if (mtd->type == MTD_ABSENT) > + if (mtd->type == MTD_ABSENT || mtd->type == MTD_UBIVOLUME) > return; > > list_for_each_entry(tr, &blktrans_majors, list) > > IOW, no mtdblock (hence, also no FTLs) on top of gluebi. > > What do you guys think? > > Thanks, > //richard > > . >