Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp3302978rwb; Sat, 12 Nov 2022 03:15:33 -0800 (PST) X-Google-Smtp-Source: AA0mqf4d4ve0fDlfgq98Hu/6U5S4iCljo5+UbqM/SQWCyppPVLxRW1HgOqL/qyDxICFl73PiKl0A X-Received: by 2002:a17:902:820d:b0:188:b840:deff with SMTP id x13-20020a170902820d00b00188b840deffmr1303218pln.104.1668251732997; Sat, 12 Nov 2022 03:15:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668251732; cv=none; d=google.com; s=arc-20160816; b=wiM1ic0vq/mbyEiUJgoaysn9Wrof639yk7Chwswb7WCq9LqSFYzU1X++TNN4OWfreq JszoULh6bew4IUsKYIXif/3HJwXotI2VmjHNmSHj6d6ZSXQRhsmLdGg7Hcwm7DdLNXSG w2xV2hpUzMIU4YHhx//YWB8p0G5gAMDlrCaB+Hb4RMx+4mOC21m/zEV/cAL6pCzUhmRy Y5oyv2Zd9Ji1VdJ24m1213TbbRzzWb9QPtN+aOPN6BTR8iEiUyG280+/Kx2Tid0TGT5G 1YKRamAzzFScuohMqe5VnFj2Ud7a/bUvDqhJYCpZuQC0RWjwBrwCzKWlLE1y1MhaTKaI yQ8A== 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=InRP6hDuO3kf8xABi+/qzYMD8GOeuZXZaPTOEBZ1UCA=; b=A0YrEIrPD7EXptpC9Md9W4f+XPKcr97savzOxNuJFFwP9h6L/4ZMVqMZkk8CWbriOr kt0x842z6dEJbINq0A0UZRZGDtX5q99NzjKqcuOrSiVcxT246xYnQFR6zKU3kQkHR361 PwbFy9bptVpNGDtTu1TOuSsYUZPjA4P/7UZQtemFUMk5z97ZACWiGmvTUC9rR5WhTeky Bax5qGQxfUCGwAzsm9dEr6Q3kjwaocse88oCRXNKjvhLOW/wubVl2ppeifhKslwojj+i N+AYYUljaKrggPoXChlMtF8UZadjtMUAYrRqhK+O8e+hTF26EYQEGZ2J7F3EMr2aS/By S8KQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e34-20020a17090a6fa500b001f31da6b2d2si4613740pjk.154.2022.11.12.03.15.12; Sat, 12 Nov 2022 03:15:32 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231805AbiKLK5O (ORCPT + 91 others); Sat, 12 Nov 2022 05:57:14 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56712 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230170AbiKLK5N (ORCPT ); Sat, 12 Nov 2022 05:57:13 -0500 Received: from dggsgout11.his.huawei.com (dggsgout11.his.huawei.com [45.249.212.51]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A88D1B867; Sat, 12 Nov 2022 02:57:11 -0800 (PST) Received: from mail02.huawei.com (unknown [172.30.67.153]) by dggsgout11.his.huawei.com (SkyGuard) with ESMTP id 4N8XZn6nY5z4f3jZ3; Sat, 12 Nov 2022 18:57:05 +0800 (CST) Received: from [10.174.176.73] (unknown [10.174.176.73]) by APP4 (Coremail) with SMTP id gCh0CgC329gDfG9jUJSaAQ--.9600S3; Sat, 12 Nov 2022 18:57:09 +0800 (CST) Subject: Re: [PATCH] blk-mq: only unregister sysfs when registration succeeded To: Yu Kuai , Liu Shixin , Jens Axboe Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, "yukuai (C)" References: <20221112110754.1109979-1-liushixin2@huawei.com> <607beb5b-8d54-b795-8a05-76352d7ed863@huaweicloud.com> From: Yu Kuai Message-ID: <58ab3673-3e39-9ea9-1749-eebfcfb8a10f@huaweicloud.com> Date: Sat, 12 Nov 2022 18:57:07 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 MIME-Version: 1.0 In-Reply-To: <607beb5b-8d54-b795-8a05-76352d7ed863@huaweicloud.com> Content-Type: text/plain; charset=gbk; format=flowed Content-Transfer-Encoding: 8bit X-CM-TRANSID: gCh0CgC329gDfG9jUJSaAQ--.9600S3 X-Coremail-Antispam: 1UD129KBjvdXoWrury7Xr4kCr4UXw47Kry7trb_yoW3ArgEga y8KFWkWa1DGFnxKw12kFZrZFyxZ3WvgFyfJayDJFWDtw18WaykGr4j9r17CrWUKw4xCrn8 trW0gayfGrWagjkaLaAFLSUrUUUUUb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUIcSsGvfJTRUUUb4AFF20E14v26r4j6ryUM7CY07I20VC2zVCF04k26cxKx2IYs7xG 6rWj6s0DM7CIcVAFz4kK6r1j6r18M28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48ve4kI8w A2z4x0Y4vE2Ix0cI8IcVAFwI0_tr0E3s1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI0_Gr1j 6F4UJwA2z4x0Y4vEx4A2jsIE14v26rxl6s0DM28EF7xvwVC2z280aVCY1x0267AKxVW0oV Cq3wAS0I0E0xvYzxvE52x082IY62kv0487Mc02F40EFcxC0VAKzVAqx4xG6I80ewAv7VC0 I7IYx2IY67AKxVWUGVWUXwAv7VC2z280aVAFwI0_Jr0_Gr1lOx8S6xCaFVCjc4AY6r1j6r 4UM4x0Y48IcVAKI48JM4x0x7Aq67IIx4CEVc8vx2IErcIFxwCYjI0SjxkI62AI1cAE67vI Y487MxAIw28IcxkI7VAKI48JMxC20s026xCaFVCjc4AY6r1j6r4UMI8I3I0E5I8CrVAFwI 0_Jr0_Jr4lx2IqxVCjr7xvwVAFwI0_JrI_JrWlx4CE17CEb7AF67AKxVWUAVWUtwCIc40Y 0x0EwIxGrwCI42IY6xIIjxv20xvE14v26r1j6r1xMIIF0xvE2Ix0cI8IcVCY1x0267AKxV W8JVWxJwCI42IY6xAIw20EY4v20xvaj40_Wr1j6rW3Jr1lIxAIcVC2z280aVAFwI0_Jr0_ Gr1lIxAIcVC2z280aVCY1x0267AKxVW8JVW8JrUvcSsGvfC2KfnxnUUI43ZEXa7VU1a9aP UUUUU== X-CM-SenderInfo: 51xn3trlr6x35dzhxuhorxvhhfrp/ X-CFilter-Loop: Reflected X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,NICE_REPLY_A, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org ?? 2022/11/12 18:44, Yu Kuai д??: > Hi, > > ?? 2022/11/12 19:07, Liu Shixin д??: >> kobject_del() must not be called if kobject_add() has not been called. >> Hence only unregister sysfs when registration succeeded. >> > > From what I see, the blk_queue_registered() from caller > blk_unregister_queue() can already prevent that. QUEUE_FLAG_REGISTERED > will only be set if blk_register_queue() succeed. I see that the return value of blk_mq_sysfs_register() is not checked from blk_register_queue(), there will be memleak or uaf from error path. Hence I think better thing to do is to handle the case that blk_mq_sysfs_register() faild, and clean up if blk_mq_sysfs_register() succeed while follow up procedures failed from blk_register_queue().