Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp5107693rwl; Tue, 28 Mar 2023 16:36:18 -0700 (PDT) X-Google-Smtp-Source: AKy350Z+cT//6jFE4EOowalCPAEZARJCYC9nHbF0K9OPejmw3fiI2DDDboNtHl9Hklyd6PuUz1dc X-Received: by 2002:a17:907:6d27:b0:932:cfbc:7613 with SMTP id sa39-20020a1709076d2700b00932cfbc7613mr21050850ejc.24.1680046577830; Tue, 28 Mar 2023 16:36:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680046577; cv=none; d=google.com; s=arc-20160816; b=PlAonJ4dkQwfkKomrno4SLook0jbg2VmcvIZLsykvlGNFVXZ7lOdk1YUwYNBksKero YElTuoy29D44+3kKXtSir9mayOtfRJemBAwBM2Bo0gOeekEPDx23sb8GI5gwBXXzbjaj lYEMu45l24wwpF39e7FYQiPzAouRDodlZqdmwvRQJZcx+iwRiZ+4EGojYvNaGX6RqxGm UNopEewBvYk8KEXYcqkUhATCagEkif3+31xpCfzQxA9ESFGIaJiwLK8h/Sp2vFjfNkmS j1chbkhH42zhupO+Hchf1rr290RXrqxl6/6yDVO6So/OFNfROuLVO63E8BzX2+7xY+nV 13bw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=f6mXSm7e2TzCi7OfP4gtXCf7l1sYhyFNfXWnEy1hKGo=; b=m5P8VvepP/50GuSoZq27NrG/yiLzwfa6gRZWju32MA/njlJWPEjHc18mLR+o3iJWUc dtsFa73ZQzUxEBNDuVNux8pXo30zO+G6nPiHo0tAO0om4IxI5eg1cW1Yv3iePFKIOlNL kR8gt6avvdrKTiU9UxDZooEzUx+XFSHaFlD3JFOvRc5g6uFwooTOpOflTl43y84SjAXg SFTd/YLy4uIa+Zkhh/mGnCv0nFHDRMGYo01fnPptO4RJTfA9PUuR23SvBXYxCZUCRmWQ W+bu+lyKQgFsQW6/RH8M3LMJcMwg6tuMDgV13MVJ0P1wJ+OozXtiYxxlPwUtTPwqFJQM MabA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=eVwieGxD; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q24-20020aa7d458000000b00501e1a07b87si19053582edr.538.2023.03.28.16.35.53; Tue, 28 Mar 2023 16:36:17 -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; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=eVwieGxD; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229505AbjC1Xbh (ORCPT + 99 others); Tue, 28 Mar 2023 19:31:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43468 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229757AbjC1Xbg (ORCPT ); Tue, 28 Mar 2023 19:31:36 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9E11F2D52; Tue, 28 Mar 2023 16:31:31 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 51F33B81F65; Tue, 28 Mar 2023 23:31:30 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 209EAC433A4; Tue, 28 Mar 2023 23:31:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1680046289; bh=f6mXSm7e2TzCi7OfP4gtXCf7l1sYhyFNfXWnEy1hKGo=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=eVwieGxD/OsmiBqsC7hbOI45S4M1FdMhBWQMJA5pDrUWfjErBN9wb9wAF0o/yrITp J9bdxdTovCzNP/POKpezbFaGIvx7gKzdYHNN5tYNc8/j7vETxKCOjDzgRG/AwyfJRg u7kgCWCrMmSa0lLMJVSYWDrOFDLWv2IRNFveMyAEaGBha5qrenqQ3KQqV2ipqOvBmS S/sdUFTVUcAREkoD/t3XADIM3cBu6uDMgyX4IoMizkIMoVprF5ZzpDcnHLD4M+/c5H /4ikycv94u2nJ//d5ZnV5RDphlx4xV7lg11MV+zf8lHa63GlbQU114pqj5Exj3rdLA bj+aA4BzEFQMA== Received: by mail-lf1-f41.google.com with SMTP id h25so17903717lfv.6; Tue, 28 Mar 2023 16:31:29 -0700 (PDT) X-Gm-Message-State: AAQBX9dZLD8Xb1AoBmnethoJajgY5C8tsMRmtL2TvU6R5wV+6PAXId8i QtDcWxhZuL7QBNhmlLzc/D8kDT1Tyzlj9kwHEYU= X-Received: by 2002:ac2:5338:0:b0:4eb:1316:a2e6 with SMTP id f24-20020ac25338000000b004eb1316a2e6mr2107735lfh.3.1680046287127; Tue, 28 Mar 2023 16:31:27 -0700 (PDT) MIME-Version: 1.0 References: <20230315061810.653263-1-yukuai1@huaweicloud.com> <606b1388-10e7-a0ae-f314-52274b0942dd@deltatee.com> In-Reply-To: From: Song Liu Date: Tue, 28 Mar 2023 16:31:14 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v2 0/5] md: fix uaf for sync_thread To: Yu Kuai Cc: Logan Gunthorpe , Paul Menzel , agk@redhat.com, snitzer@kernel.org, linux-kernel@vger.kernel.org, linux-raid@vger.kernel.org, yi.zhang@huawei.com, yangerkun@huawei.com, "yukuai (C)" Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-2.5 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,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 lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Mar 15, 2023 at 6:26=E2=80=AFPM Yu Kuai w= rote: > > Hi, > > =E5=9C=A8 2023/03/16 6:55, Logan Gunthorpe =E5=86=99=E9=81=93: [...] > > I was going to try and confirm that no new regressions were introduced > > by Yu's patches, but seems the tests are getting worse. I tried running > > the tests on the current md-next branch and found that one of the early > > tests, 00raid5-zero, hangs indefinitely. I quickly ran the same test on I am not able to repro the issue with 00raid5-zero. (I did a rebase before running the test, so that might be the reason). > > v6.3-rc2 and found that it runs just fine there. So it looks like > > there's already a regression in md-next that is not part of this series > > and I don't have the time to dig into the root cause right now. > > > > Yu's patches don't apply cleanly to v6.3-rc2 and I can't run the tests > > against md-next; so I didn't bother running them, but I did do a quick > > review. The locking changes make sense to me so it might be worth > > merging for correctness. However, I'm not entirely sure it's the best > > solution -- the md thread stuff seems like a bit of a mess and passing > > an mddev to thread functions that were not related to the mddev to get = a > > lock seems to just make the mess a bit worse. > > > > For example, it seems a bit ugly to me for the lock mddev->thread_lock > > to protect the access of a pointer in struct r5l_log. Just spit-balling= , > > but perhaps RCU would be more appropriate here. Then md_wakeup_thread() > > would just need to hold the RCU read lock when dereferencing, and > > md_unregister_thread() would just need to synchronize_rcu() before > > stopping and freeing the thread. This has the benefit of not requiring > > the mddev object for every md_thread and would probably require a lot > > less churn than the current patches. > > Thanks for your suggestion, this make sense to me. I'll try to use rcu. Yu Kuai, do you plan to resend the set with Logan suggestions? Thanks, Song