From nobody Thu Jun 15 18:41:33 2023 X-Original-To: bugs@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 4QhrjT45bBz4f1qL for ; Thu, 15 Jun 2023 18:41:33 +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 4QhrjT1QZXz3N9P for ; Thu, 15 Jun 2023 18:41:33 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1686854493; 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=4jel2j52xPTvJXEyIERUGSr5zbiNNO7LXlo99ioZ0rk=; b=OSs5p3WVsODFY5KJL/MDzkxFWDybR4J/6Ho3eaEXkRkesBQwLuK5529AkWDaWqY0avYDQx zUB/Sej1jCYOSvWgTtRMlcIewv0DGn5wZUQaMq130ZH+sOGmglFkKoMfQJCgLIvcl663z7 1H6XP7fa4kzZQE4OzPdiKQ1fhYkfRiMCka8AmpoIn+hOYN2Ga3lV0LpmRffvokFtFSthNV +sZhuqOqUtlVjbQkDab64koj+6gXYWjj8fPhWKlydaRlITCSXbCGGfpOenIwH2wypqJWQP 9KjXgIoU93ar98aSw5PphulYF+aZ/7lGzPUc8nUGibm2pthLlCCa0OplxVlA+Q== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1686854493; a=rsa-sha256; cv=none; b=vCN/XR81aC5Bm4CLhwpkmRUI/TN7spgxA85e42cod5/pYKD3G0/Stecy0IcDZY7549cDyV Eh649iaWipma7YDl63A429Xad6cj7jJEEpVZ50q5gzu2LFrsvYWUJBV05alo2DUAwKqhr0 ziGBNW5dXVjQiO+IubtiboAtLoIwVl8NiRTEicFa4JR5hXyQaat3GdkPlJkwxaX+rBS1Pt OWW4/Cu4GeoX4sKHGuq0OtNDsIaZ4K/KdNvP40Y2foj5OnoDqoOuBlb0/22q/zigdRUTQC GCp9G1VPFvv2lX5UYNQEHAcQ4Y38LDnU2Xa95BzTgUEbIkPy7kFbBCfiIoYiXA== 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 4QhrjT0X5GzxVF for ; Thu, 15 Jun 2023 18:41:33 +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 35FIfX0E019199 for ; Thu, 15 Jun 2023 18:41:33 GMT (envelope-from bugzilla-noreply@freebsd.org) Received: (from www@localhost) by kenobi.freebsd.org (8.15.2/8.15.2/Submit) id 35FIfXGI019196 for bugs@FreeBSD.org; Thu, 15 Jun 2023 18:41:33 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: bugs@FreeBSD.org Subject: [Bug 272018] pci_read_vpd() does not always load VPD even when valid VPD exists because of state machine bug Date: Thu, 15 Jun 2023 18:41:33 +0000 X-Bugzilla-Reason: AssignedTo X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: Base System X-Bugzilla-Component: kern X-Bugzilla-Version: 13.1-STABLE X-Bugzilla-Keywords: X-Bugzilla-Severity: Affects Some People X-Bugzilla-Who: daveb@spectralogic.com X-Bugzilla-Status: New X-Bugzilla-Resolution: X-Bugzilla-Priority: --- X-Bugzilla-Assigned-To: bugs@FreeBSD.org X-Bugzilla-Flags: 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: Bug reports List-Archive: https://lists.freebsd.org/archives/freebsd-bugs List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-bugs@freebsd.org MIME-Version: 1.0 X-ThisMailContainsUnwantedMimeParts: N https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D272018 --- Comment #1 from Dave Baukus --- The state machine to read a device's VPD in pci_vpd_read() has this stateme= nt at the end of the top level switch() statement: if (cfg->vpd.vpd_ident =3D=3D NULL || cfg->vpd.vpd_ident[0] =3D=3D '\0') { pci_printf(cfg, "no valid vpd ident found\n"); state =3D -2; } The issue is the cfg->vpd.vpd_ident[0] =3D=3D '\0' check. On the first iteration with state =3D=3D 0, case 0: if a "name" of 2 is dis= covered (name =3D (byte >> 3) & 0xf) then the code falls into a sub-switch() statem= ent where if everything else is valid then vpd_ident is allocated: switch(name) case 0x2: ... ... ... cfg->vpd.vpd_ident =3D malloc(remain + 1, M_DEVBUF, M_WAITOK); i =3D 0; state =3D 1; break; Now when the code falls out of the top level switch() the above check trigg= ers. The code has not assigned anything to cfg->vpd.vpd_ident[0]; it is therefore random luck weather or not a device with valid VPD gets its VPD cached. My quick hack: assign a characther not '\0' to cfg->vpd.vpd_ident[0] after = it is allocated. It will be overwritten in case 1 of the top level switch() on= the next iteration; I'm sure there's a more elegant solution. --=20 You are receiving this mail because: You are the assignee for the bug.=