From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.127.231.20 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1793930460; b=5XLEyiuM2d7hpYZv5aFRLX8/ow16brpKS6yjdGNLtp7Sg0yLEP2DDkg7ejwF/gKNgJUH G08n8bisDHSCnzDPtTFHJTtJEwy8CSzhOI9SLcHqSCy34sFUdFd4eqHZeuhTXpHxANdX9 XrdAIeAL2P1zSrH5t0iktAsPySI0pDgCKsnfOvfNWVEjn8bsEDiDExKGtb0cJosZmlZkV 7X9aTlcfjtDDR4Nj3HR8p8fc+vutxdH9Vo/nkfBHl28+VcNdf6SYzh5y3WJsvuoKJd3LZ UC5BqeDV4o+oBJG7EweJzUGuFdIGZ/g2Iv9W14vRdDaIf5Y3hizIr+81WnAr3OhvABg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1793930460; h=DMARC-Filter:DKIM-Signature:User-Agent:X-Lms-Return-Path: Mime-Version:To:Message-Id:From:Subject:Content-Transfer-Encoding: Content-Type:References:Received:Reply-To:Cc:X-Original-From:Date: In-Reply-To; bh=BzurbRUdgcB5LkEIB7Hn26hUmmq0gClbqcTlXGMVGzw=; b=EqhQVm3WWfdegy5wGHCAcSTFyAhg55yY2Isbp8+mxOh87rYWObKJF8R+qP/Qh8AFw5Z9 Hk16rCSuzvId9sjRoWdRuIbbHLPqk/PFy8ji0gHi5gqKLZ7qb3Pg42XKPAwUrrB05dqZo LVyVFaLsL788CF1nqEHBeezfv0J+QPGFREKDcPUp0rfLPR4vaJAi2H3iQbVz/aeNQ4Cfz VuzZTxhvh8dVyvK4QCsL0dyXHaaFA4TqPVHI2mtMCpnBxi6JiMO1C0952Hf6qc73okzBa JnpvtIuOe6SmGvjqi2ayzdl8Z0CWwogGXB7TbWcEP8vmjv7owKSVfy+owZihhiG9GYQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=fygo.io; spf=pass smtp.mailfrom=fygo.io; dkim=pass header.d=fygo-io.20200929.dkim.larksuite.com header.i=@fygo-io.20200929.dkim.larksuite.com header.a=rsa-sha256 header.s=s1 header.b=ByicbgQn; arc=none smtp.remote-ip=209.127.231.20 Received: from va-2-20.ptr.blmpb.com (va-2-20.ptr.blmpb.com [209.127.231.20]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 50013606A329 for ; Fri, 6 Nov 2026 02:00:58 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 50013606A329 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=fygo.io Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=fygo.io Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=fygo-io.20200929.dkim.larksuite.com header.i=@fygo-io.20200929.dkim.larksuite.com header.a=rsa-sha256 header.s=s1 header.b=ByicbgQn DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; s=s1; d=fygo-io.20200929.dkim.larksuite.com; t=1793930450; h=from:subject:mime-version:from:date:message-id:subject:to:cc: reply-to:content-type:mime-version:in-reply-to:message-id; bh=BzurbRUdgcB5LkEIB7Hn26hUmmq0gClbqcTlXGMVGzw=; b=ByicbgQncgOWB8QtXNxPUp/boZqIU+6wT7nej9vW9WnUwlRKJJxXhDyv3AScbpqzJPxpUi EVR5W6q/WvqKawJVGIzWbPXKhL6kwEBZ08cmxCnqVhYot8Sz2ByUibbbiNfvwm5UdqkI2j y/pnu+FWGgqPOKF7BSnSlHDLpv3mpEdbkY8mo2v0KgMoF3CJ0ZXNKlXUOzjK7uRGr8c73T x6jtd0d2FPejJwkPytaoYVNp6dPepnUr8/yUQYrvO6a/LuRoAw1nbDLM0zjoyBwsuJ8G9C Uczub1HHhGfKtK3dAgx1GlKM0re8BSWOxMXAB6WL+MHdcDrz2dLyLztsi2ccPg== User-Agent: Mozilla Thunderbird X-Lms-Return-Path: X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Mime-Version: 1.0 To: "Sanan Hasanov" , "Song Liu" , "yu kuai" Message-Id: From: "yu kuai" Subject: Re: [PATCH] md: don't allow changing the personality of a failed array Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=UTF-8 References: <20261019193659.31381-1-sanan.hasanou@gmail.com> Received: from [192.168.1.104] ([39.182.0.25]) by smtp.larksuite.com with ESMTPS; Fri, 06 Nov 2026 02:00:48 +0000 Reply-To: yukuai@fygo.io Cc: "Li Nan" , "Xiao Ni" , , , , "Sanan Hasanov" , X-Original-From: yu kuai Date: Fri, 6 Nov 2026 10:00:44 +0800 In-Reply-To: <20261019193659.31381-1-sanan.hasanou@gmail.com> =E5=9C=A8 2026/10/20 3:36, Sanan Hasanov =E5=86=99=E9=81=93: > From: Sanan Hasanov > > level_store() lets userspace switch a running array to another > personality through the takeover path, and then ignores the return value > of pers->run(). Takeover is expected to always produce something the new > personality can run, but that no longer holds for an array that has > already failed: since commit 57668f0a4cc4 ("raid5: introduce MD_BROKEN"), > has_failed() treats MD_BROKEN as fatal, so raid5_run() refuses such an > array. It then frees the new conf and clears mddev->private, while > level_store() has already installed the raid5 personality and freed the > old one. The array is left with mddev->pers =3D=3D &raid5_personality and > mddev->private =3D=3D NULL, and the next operation that reaches the > personality dereferences NULL: > > md/raid0md0: Disk failure on loop0 detected, failing array. > md/raid:md0: not enough operational devices (1/3 failed) > md/raid:md0: failed to run raid set. > KASAN: null-ptr-deref in range [0x0000000000000060-0x0000000000000067] > RIP: 0010:kasan_byte_accessible+0x12/0x30 mm/kasan/generic.c:210 > Call Trace: > spin_lock_irq include/linux/spinlock_rt.h:96 [inline] > lock_all_device_hash_locks_irq drivers/md/raid5.c:107 [inline] > raid5_quiesce+0xc2/0x8a0 drivers/md/raid5.c > __md_stop_writes+0xeb/0x4b0 drivers/md/md.c:7038 > md_set_readonly+0x330/0x560 drivers/md/md.c:7138 > array_state_store+0x584/0xe90 drivers/md/md.c:4720 > > syzbot gets there by failing a member of a raid0 array, which sets > MD_BROKEN, then writing "raid5" to md/level and "readonly" to > md/array_state. The same applies to a two-disk raid1 array whose last > working device has failed: raid1_error() sets MD_BROKEN but leaves > degraded at 1, so raid5_takeover_raid1() still accepts it. > > MD_BROKEN is never cleared while the array is running, and a failed > array can't be turned into a working one by changing its level. Refuse > the change up front with -EBUSY, which is also what state_store() > returns when failing a device leaves the array broken. > > Fixes: 57668f0a4cc4 ("raid5: introduce MD_BROKEN") > Reported-by:syzbot+0b672810a475890d3636@syzkaller.appspotmail.com > Closes:https://syzkaller.appspot.com/bug?extid=3D0b672810a475890d3636 > Cc:stable@vger.kernel.org > Signed-off-by: Sanan Hasanov > --- > drivers/md/md.c | 6 ++++++ > 1 file changed, 6 insertions(+) Applied --=20 Thanks, Kuai