Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 16 Jun 2023 15:04:07 +0000
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
Message-ID:  <bug-272018-227-U8htX5FK6b@https.bugs.freebsd.org/bugzilla/>
In-Reply-To: <bug-272018-227@https.bugs.freebsd.org/bugzilla/>
References:  <bug-272018-227@https.bugs.freebsd.org/bugzilla/>

next in thread | previous in thread | raw e-mail | index | archive | help
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D272018

Stefan E=C3=9Fer <se@FreeBSD.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |se@FreeBSD.org

--- Comment #2 from Stefan E=C3=9Fer <se@FreeBSD.org> ---
Created attachment 242810
  --> https://bugs.freebsd.org/bugzilla/attachment.cgi?id=3D242810&action=
=3Dedit
Simpiified VPD parser

The current VPD code uses a state machine to parse an assumed very flexible
syntax, while the structure of valid VPD actually follows a quite strict fo=
rmat
that can be parsed by a very simple parser that hard-codes this structure.
After fixing a kernel panic due to invalid VPD data that was not rejected by
the existing parser, I have re-implemented the VPD parser based on the
documented VPD definition.

See review D34268 for the code that I had uploaded as a replacement (after
adding many sanity checks to the state machine code that is meant to detect
invalid VPD data).

I'm not convinced that the current code's VPD checks catch all cases and fo=
und
that it is much easier to get a correct and safe parser by removing the
unnecessary state machine. (The state machine would make sense, if the orde=
r of
elements in the VPD structure was less strict, but given the simple "linear"
definition of VPD this flexibility stands in the way of easy detection of
malformed VPD data.)

The suggested replacement of the current VPD parser "knows" which element to
expect next (with some segments being optional) and thus does not need any
state variables.

I'd appreciate a review of the patch, which is also attached to the PR (reb=
ased
to -CURRENT as of today).

It has been tested with simulated VPD data (correct and malformed) and real=
 VPD
device data - test code is available on request.

--=20
You are receiving this mail because:
You are the assignee for the bug.=



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?bug-272018-227-U8htX5FK6b>