From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796498961; b=xgoKr3Ch7yNcMi1CdLXwEo4E/xknJBTDIgY8iuuWXdbP1qaA88PlzyczZRW7vB03YVt8 Um/f9kvtm1vScWK1FOtElzxm4QasWFCN37+dsEMUjKlqkkdsq/nNCHCfzp7cOfrN0VUo2 wUFpBl1AkB8rmC2cW2NeA1z8ue+6uM/vI3AW074awKoExwQuEWcUWl6fdVbG12GA+632h PolVNcP3t7VN/W2imGyGzBXtXod040v7OWClM83kzuQ39vUlMOEfwtIAXgmtlGTaINO80 7KOZvwa9dllQZIiPuyie98WsH9nky6BcuYjnWkTPb3NWSPlQiNPyVb08jLuhj5Y3rPA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796498961; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=i76IFPjKnH7PK3wayStHRFZIvI1iSRYg9GShzG0LuQk=; b=n5aukIFsYMiz7l3lxUg6yQs/U1Bba67ZoP+sWMA2Dmy2xuPsuzCazOvDPzBVfwcaDeGg 57c5glWKSSQRf4/dsatO6th6iN20gu27iirIY+n1zGjfkkhwSthJ5f7ZN5TGmb8tkTRk2 zW0GTzEKV7mSSQdXT3KUbCYq+yxu2nOuxDh34gl3RxDxM/ksfJPZzzEFl7I7Tg0E16Mb+ mfDexBy6qVokWa8i6LRU6dmv1yjD29s6xuoWWSjw1USQCteedRag/1BYFei0FVi5oFQ60 +dpfp2VMfQU+Xv4HlWYjkPRDfLgJ0N6BH663qrAmHnuHahXM+alSFKH9iy+4vvv8fiA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=bqfLMuDK; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 61D3D606A31F for ; Sat, 5 Dec 2026 19:29:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=bqfLMuDK Received: by smtp.kernel.org (Postfix) with ESMTPSA id 141781F0092B; Sat, 5 Dec 2026 19:29:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796498961; bh=i76IFPjKnH7PK3wayStHRFZIvI1iSRYg9GShzG0LuQk=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=bqfLMuDKLKylw6qiWrGbpA58dTpVM1Yk59mqrCRjnVLlMpzI+0rkSzHQq2EdI+jXU CDaFI4RTXzrzL1FUfgrpusVahWRBhDXWq4dYMynyit3iFPmoiEw1qXVgQObEew0cm9 D7txRKvnmPlHOOIaCv2q/GSuVWmz/XbjTdsuOet8d5CKoeBcikIRseKBpw2mwtqh5F oO/M9OIBQWtxzpmFF/8TtsV7S056UYu78/DmmnCYXfRzc7EKfsiQPyGofUOhR1t9f4 oyBCmPge0kONBmj/8c0DIsZdXvSZKDLwfc81mvr3R+gSEGxr057YwbCQ3DX93pobsF Hvx5a5UOs6VxA== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH] md/raid10: don't take a recovering member as the resync source Reply-To: sashiko-reviews@lists.linux.dev To: "Miroslav Cimerman" Cc: linux-raid@vger.kernel.org, yukuai@fygo.io In-Reply-To: <20261205190740.1519480-1-mc@raidlab.org> References: <20261205190740.1519480-1-mc@raidlab.org> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Sat, 05 Dec 2026 19:29:20 +0000 X-Mailing-List: linux-raid@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Thank you for your contribution! Sashiko AI review found 2 potential issues to consider: - [Medium] md/raid10: sync_request_write() lacks Faulty check after sync_copy_valid() - [Low] md/raid10: data race on rdev->recovery_offset in sync_copy_valid() -- commit 722f3c309b30c64a76fdb814b1a1c2ccb688d55e Author: Miroslav Cimerman md/raid10: don't take a recovering member as the resync source This commit adds sync_copy_valid() to prevent RAID10 resync from using data above recovery_offset on a non-In_sync member as the resync source and to overwrite such copies with the valid source. > diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c > index 68f42cad32a59..2139c7030bfef 100644 > --- a/drivers/md/raid10.c > +++ b/drivers/md/raid10.c > @@ -2292,6 +2292,19 @@ static void end_sync_write(struct bio *bio) > end_sync_request(r10_bio); > } > =20 > +/* > + * A member that is not In_sync holds valid data only below its > + * recovery_offset, see read_balance(). > + */ > +static bool sync_copy_valid(struct r10conf *conf, struct r10bio *r10_bio, > + int i) > +{ > + struct md_rdev *rdev =3D conf->mirrors[r10_bio->devs[i].devnum].rdev; > + sector_t end =3D r10_bio->devs[i].addr + r10_bio->sectors; > + > + return test_bit(In_sync, &rdev->flags) || end <=3D rdev->recovery_offse= t; > +} [Severity: Low] Can this plain read of rdev->recovery_offset race with md_reload_sb() on clustered RAID10 arrays? raid10d() calls sync_request_write() without holding mddev->reconfig_mutex. On a clustered RAID10 near array, recv_daemon() can concurrently handle a METADATA_UPDATED message and reload the superblock for non-Faulty members with MD_FEATURE_RECOVERY_OFFSET set: CPU0 (raid10d) CPU1 (recv_daemon) sync_request_write() process_metadata_update() sync_copy_valid() mddev_trylock(mddev) md_reload_sb() read_rdev() read rdev->recovery_offset rdev->recovery_offset =3D ... <-- data race While the resyncing node holds resync_lockres, read_rdev() normally writes the same value, causing a data race under CONFIG_KCSAN_STRICT. If a peer broadcasts a stale recovery_offset, a 32-bit kernel can also observe a torn 64-bit load. [ ... ] > @@ -2349,7 +2363,15 @@ static void sync_request_write(struct mddev *mddev= , struct r10bio *r10_bio) > tpages =3D get_resync_pages(tbio)->pages; > d =3D r10_bio->devs[i].devnum; > rdev =3D conf->mirrors[d].rdev; > - if (!r10_bio->devs[i].bio->bi_status) { > + if (!r10_bio->devs[i].bio->bi_status && > + !sync_copy_valid(conf, r10_bio, i)) { > + /* > + * Not recovered yet: don't compare, write the source > + * to it, unless this is a check. > + */ > + if (test_bit(MD_RECOVERY_CHECK, &mddev->recovery)) > + continue; > + } else if (!r10_bio->devs[i].bio->bi_status) { [Severity: Medium] Can this submit write bios to a disk that has just been marked Faulty? Assembled In_sync members keep rdev->recovery_offset at 0. If a disk fails while resync r10_bios are in flight or queued on conf->retry_list (for example via raid10_error() from an I/O error or mdadm --fail), raid10_error= () clears In_sync and sets Faulty while leaving recovery_offset at 0: CPU0 (raid10d) CPU1 raid10_error() clear_bit(In_sync, &rdev->flags) set_bit(Faulty, &rdev->flags) sync_request_write() !sync_copy_valid() -> true submit_bio_noacct(tbio) <-- writes to Faulty disk For every remaining r10_bio whose read on that disk succeeded, sync_copy_valid() now returns false even when the data matches, so this branch skips memcmp() and falls through to submit REQ_OP_WRITE bios to the Faulty disk. That mutates the failed device, keeps rdev->nr_pending and mddev->recovery_active elevated while draining, and can spuriously record write errors in end_sync_write(). Checking test_bit(Faulty, &rdev->flags) before writing (as raid1's sync_request_write() does) would avoid issuing writes to a failed member. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261205190740.1519= 480-1-mc@raidlab.org?part=3D1