From nobody Thu May 19 15:07:02 2022 X-Original-To: fs@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 471D71B34E7E for ; Thu, 19 May 2022 15:07:03 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4L3tVt73y3z4gwK for ; Thu, 19 May 2022 15:07:02 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from kenobi.freebsd.org (kenobi.freebsd.org [IPv6:2610:1c1:1:606c::50:1d]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id C477B1FEBD for ; Thu, 19 May 2022 15:07:02 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from kenobi.freebsd.org ([127.0.1.5]) by kenobi.freebsd.org (8.15.2/8.15.2) with ESMTP id 24JF72Zi020793 for ; Thu, 19 May 2022 15:07:02 GMT (envelope-from bugzilla-noreply@freebsd.org) Received: (from www@localhost) by kenobi.freebsd.org (8.15.2/8.15.2/Submit) id 24JF72Q2020792 for fs@FreeBSD.org; Thu, 19 May 2022 15:07:02 GMT (envelope-from bugzilla-noreply@freebsd.org) X-Authentication-Warning: kenobi.freebsd.org: www set sender to bugzilla-noreply@freebsd.org using -f From: bugzilla-noreply@freebsd.org To: fs@FreeBSD.org Subject: [Bug 263853] geom(4): raid/md_jmicron.c: jmicron RAID taste code can panic if conf is garbage Date: Thu, 19 May 2022 15:07:02 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: Base System X-Bugzilla-Component: kern X-Bugzilla-Version: Unspecified X-Bugzilla-Keywords: crash, needs-qa X-Bugzilla-Severity: Affects Some People X-Bugzilla-Who: markj@FreeBSD.org X-Bugzilla-Status: Open X-Bugzilla-Resolution: X-Bugzilla-Priority: --- X-Bugzilla-Assigned-To: geom@FreeBSD.org X-Bugzilla-Flags: maintainer-feedback? mfc-stable13? mfc-stable12? X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: https://bugs.freebsd.org/bugzilla/ Auto-Submitted: auto-generated List-Id: Filesystems List-Archive: https://lists.freebsd.org/archives/freebsd-fs List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-fs@freebsd.org MIME-Version: 1.0 ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1652972823; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=pgqFi1Cz2NvH9Za6Ir/3MU7/HMNO+gV1gJ8AzLMBoiQ=; b=dmUT/GISQFcx6FKm9jJOc+HyaiJahs3QVtQEDAntbDnbTtjgkn8yd50bgeIWhzw5iTt6pl FcXXNjKIMlpQMRbNMPPu2gJJBFVrj6WBT0XF1HrTwRM3T3DAZ+ddlS6KZCpY5M9AP3f1a5 VeZBJ7MJJbEd85s0jYfzsseXOxvoEuuzPjTjDeDMfUVbhk6jubkGbik51sQb/VQ/5MCFb8 etPP2NrgCXCdlSpg9gxdn5rK86r4brVJBEpHQ4/5BjhOGe8HqxX42WecuH1fDHhGm2d+Li Nk2tXWUCUBJlB92HMqhrMqwWwdwrYUhGhNq3KQWiz1hNfTDzduI8A6SDMMcF6w== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1652972823; a=rsa-sha256; cv=none; b=YWlF7BczSeEMds6BnCVfqYCyapKI8xB0tIbxl8SiU5t87YQfenzZwnqzju+upBBC4fj/Lk BWR60Qxq2cu+9a/apvk2Bh3p4juMNG7HcGK1k9tbrpdcG6obkIyVAkrTp8uig9Ve5/JxeT peLGNiKMkBRUSahzRtLS/LXGIhTvhRNu9QJJIrYQYg1ZR62ok2YpHz2w2izXczFJB/vzAP eSekt36WLgWlLz7mk6LflE3sEcc+STe7L1nyqlQNKGLw6BKCP7GrTsZXFxzFY+Ccc1XQEd m02pWk9Sdv3VrBh7Tw/dI9L9/RD1MfVa3lrW9nIbOXnvt2aN8Pm5Amh5hEzkBw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D263853 --- Comment #5 from Mark Johnston --- Looks like there are several problems here. First, the tasting code assumes that disk IDs are non-zero, since jmicron_meta_total_disks() terminates its search when an array entry is zero. disk_ids seem to be assigned using arc4random(), so most of the time they'll be non-zero. :) jmicron_meta_find_disk() skips over zeroed entries though, so it's not consistent with total_disks(). I see another bug in the jmicron taste routine, in this line: spare =3D (disk_pos =3D=3D -2) ? 1 : 0; It's impossible for disk_pos to equal -2 here, I suspect it should be -3. I'm not sure how best to fix all of this. Something like this fixes the te= st case, but I'm sure it's incomplete, and could potentially break existing setups, though I suspect that's unlikely: diff --git a/sys/geom/raid/md_jmicron.c b/sys/geom/raid/md_jmicron.c index 939e05f78017..faa7b1cbb40e 100644 --- a/sys/geom/raid/md_jmicron.c +++ b/sys/geom/raid/md_jmicron.c @@ -249,6 +249,8 @@ jmicron_meta_find_disk(struct jmicron_raid_conf *meta, uint32_t id) int pos; id &=3D JMICRON_DISK_MASK; + if (id =3D=3D 0) + return (-1); for (pos =3D 0; pos < JMICRON_MAX_DISKS; pos++) { if ((meta->disks[pos] & JMICRON_DISK_MASK) =3D=3D id) return (pos); --=20 You are receiving this mail because: You are on the CC list for the bug.=