https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=272018

Stefan Eßer <s...@freebsd.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |s...@freebsd.org

--- Comment #2 from Stefan Eßer <s...@freebsd.org> ---
Created attachment 242810
  --> https://bugs.freebsd.org/bugzilla/attachment.cgi?id=242810&action=edit
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 format
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 found
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 order 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 (rebased
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.

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

Reply via email to