Received: by 2002:a05:6358:c692:b0:131:369:b2a3 with SMTP id fe18csp3931484rwb; Sun, 30 Jul 2023 20:29:32 -0700 (PDT) X-Google-Smtp-Source: APBJJlHuUbK932U0Bun0hM0v3wyKSfPFEHQb56omTDyglThq8XhuJvmzCCu/hG9DVLBN8G+fmhYK X-Received: by 2002:ac8:7d4f:0:b0:405:5a1a:2b1b with SMTP id h15-20020ac87d4f000000b004055a1a2b1bmr12821501qtb.21.1690774171992; Sun, 30 Jul 2023 20:29:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690774171; cv=none; d=google.com; s=arc-20160816; b=k+P7KM9UgBAEA06noRvEp7+eIWfVir+b1+TxhxNqU/XHltShRwLrgRR8eX8KRdtxFo JNPTUkIT363Tj4EHMa0Ec67TAvmnHzLibL5rv8CsnmoU96v9C0XdB4s+5zt0ZKtu92YF DnqM2egIkI5V5Jfv6gZPf8RHgSGtgfz1sE+V5cUftaR7r9vECGye1AeWQI/LAjKvzHzE vSvRSEcZikJ3RQ4lUGBwrXC9pIZynrrPjF9O0gZWiNcJ3jO5JPtulzygbvKrwwH3WfRa dF8fpS4IihAMagjDjYCdtB7bmER2Kkk1p2UsniXuc0bydWuZe4FM4dPFRRHDPl4J6zzR ceFA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=1lkJlU0BpqYS11PSZ3aIam+Mchtu5DpJq4vRegXlSiI=; fh=x0YGOK/9gE3GyhYQ29a+rlDdFHxwPhuiBfRrtSzssq0=; b=udS8E64gpmIxoBH3EZBXXqOpwGEGeYRG7LUmPvbux/IpxrTvRyqFLs/A9GWCYEBl7C wSdcu8wyVHQ4Azmyd1H7q/bRztKXxmU3tXaACeFUBeXEvontZYP7+7MzwO1QXtyw1yzO VhunzKG9b9CIRbyKwMmL5uK3vwY55piR6OE29x1RQWjwCg0BIFuYC7rAMOpQVvQf/2cJ NIEK1K/Vd728Xlv4csOcmKJ94LBbdKrWFXuUbL9ijvQP78MCDhRVkAQo732U1FW1paUY LBHYkowm9vL2OUOHE+U/QMTmwOmeL6P1Os7HtJmAxM7Vqy8Ty9Eb8J8sM0vPQrccAUnB qvaQ== 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 s10-20020a65584a000000b0053ef469281bsi5795053pgr.474.2023.07.30.20.29.20; Sun, 30 Jul 2023 20:29:31 -0700 (PDT) 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 S229724AbjGaCax (ORCPT + 99 others); Sun, 30 Jul 2023 22:30:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35946 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229538AbjGaCav (ORCPT ); Sun, 30 Jul 2023 22:30:51 -0400 Received: from dggsgout12.his.huawei.com (dggsgout12.his.huawei.com [45.249.212.56]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 148FBE4E; Sun, 30 Jul 2023 19:30:50 -0700 (PDT) Received: from mail02.huawei.com (unknown [172.30.67.143]) by dggsgout12.his.huawei.com (SkyGuard) with ESMTP id 4RDj036rbXz4f3nq6; Mon, 31 Jul 2023 10:30:43 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.104.67]) by APP2 (Coremail) with SMTP id Syh0CgC3ltTUHMdkCiyOPA--.31595S4; Mon, 31 Jul 2023 10:30:46 +0800 (CST) From: Yu Kuai To: song@kernel.org, yukuai3@huawei.com Cc: linux-raid@vger.kernel.org, linux-kernel@vger.kernel.org, yukuai1@huaweicloud.com, yi.zhang@huawei.com, yangerkun@huawei.com Subject: [PATCH -next] md/raid10: fix a 'conf->barrier' leakage in raid10_takeover() Date: Mon, 31 Jul 2023 10:28:00 +0800 Message-Id: <20230731022800.1424902-1-yukuai1@huaweicloud.com> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CM-TRANSID: Syh0CgC3ltTUHMdkCiyOPA--.31595S4 X-Coremail-Antispam: 1UD129KBjvJXoW7ur1rGr15JrW8GF4DKw48WFg_yoW8Gw4rpa 1IgF13Zr43Cas8Aw1DX34DCFyrtayDGrW8Ca93u3s8ZF13tFZ3K3y5XFW5WFWDuF95Jw1D tFn8C3yrAFyjgFDanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUyC14x267AKxVW8JVW5JwAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2ocxC64kIII0Yj41l84x0c7CEw4AK67xGY2AK02 1l84ACjcxK6xIIjxv20xvE14v26F1j6w1UM28EF7xvwVC0I7IYx2IY6xkF7I0E14v26r4U JVWxJr1l84ACjcxK6I8E87Iv67AKxVW0oVCq3wA2z4x0Y4vEx4A2jsIEc7CjxVAFwI0_Gc CE3s1le2I262IYc4CY6c8Ij28IcVAaY2xG8wAqx4xG64xvF2IEw4CE5I8CrVC2j2WlYx0E 2Ix0cI8IcVAFwI0_Jr0_Jr4lYx0Ex4A2jsIE14v26r1j6r4UMcvjeVCFs4IE7xkEbVWUJV W8JwACjcxG0xvY0x0EwIxGrwACjI8F5VA0II8E6IAqYI8I648v4I1l42xK82IYc2Ij64vI r41l4I8I3I0E4IkC6x0Yz7v_Jr0_Gr1lx2IqxVAqx4xG67AKxVWUJVWUGwC20s026x8Gjc xK67AKxVWUGVWUWwC2zVAF1VAY17CE14v26r126r1DMIIYrxkI7VAKI48JMIIF0xvE2Ix0 cI8IcVAFwI0_Jr0_JF4lIxAIcVC0I7IYx2IY6xkF7I0E14v26r1j6r4UMIIF0xvE42xK8V AvwI8IcIk0rVWrZr1j6s0DMIIF0xvEx4A2jsIE14v26r1j6r4UMIIF0xvEx4A2jsIEc7Cj xVAFwI0_Gr0_Gr1UYxBIdaVFxhVjvjDU0xZFpf9x0JUdHUDUUUUU= X-CM-SenderInfo: 51xn3trlr6x35dzhxuhorxvhhfrp/ X-CFilter-Loop: Reflected X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE 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 From: Yu Kuai After commit 4d27e927344a ("md: don't quiesce in mddev_suspend()"), 'conf->barrier' will be leaked in the case that raid10 takeover raid0: level_store pers->takeover -> raid10_takeover raid10_takeover_raid0 WRITE_ONCE(conf->barrier, 1) mddev_suspend // still raid0 mddev->pers = pers // switch to raid10 mddev_resume // resume without suspend After the above commit, mddev_resume() will not decrease 'conf->barrier' that is set in raid10_takeover_raid0(). Fix this problem by remove the setting of 'conf->barrier' from raid10_takeover_raid0(). By the way, this problem is found while I'm trying to make mddev_suspend/resume() to be independent from raid personalities. rai10 is the only personality to use reference count in the quiesce() callback and this problem is only related to raid10. Fixes: 4d27e927344a ("md: don't quiesce in mddev_suspend()") Signed-off-by: Yu Kuai --- drivers/md/raid10.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c index 16aa9d735880..7704a4c7f469 100644 --- a/drivers/md/raid10.c +++ b/drivers/md/raid10.c @@ -4417,7 +4417,6 @@ static void *raid10_takeover_raid0(struct mddev *mddev, sector_t size, int devs) rdev->new_raid_disk = rdev->raid_disk * 2; rdev->sectors = size; } - WRITE_ONCE(conf->barrier, 1); } return conf; -- 2.39.2