forked from tianocore/edk2
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ShellPkg: Acpiview: Remove DbgDevInfoHeader
Signed-off-by: Zhichao Gao <zhichao.gao@intel.com>
- Loading branch information
1 parent
c54700f
commit 112a412
Showing
1 changed file
with
36 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
The ParseAcpi() call above will parse either the entire DbgDevInfoParser[] array or as much data as there is left in the ACPI table buffer. I agree this prevents buffer overruns with respect to the ACPI table buffer. However, the parser now ignores the length of the Debug Device Information Structure (loaded into the *DbgDevInfoLen variable) when dumping its contents.
Here is an example:
If the DBG2 table buffer is 100-byte long, and the Debug Device Information Structure is (let's say) located at offset 20 with it's byte size (as described in the 'Length' field) of only 10 bytes, then we have a problem.
The DbgDevInfoParser[] array says that 22 bytes should be parsed, however, the user-provided structure length is 10. I believe that only 10 bytes should be parsed to reflect what an OS would do in this situation.
This is why I created a new ACPI_PARSER array in my submitted patch to first read the Length of the Debug Device Information Structure, validate it against the length of the DBG2 table buffer, and then to control how many statements from DbgDevInfoParser[] should be executed. If we print only as much data as the ACPI table writer has specified then any errors in the 'Length' field are easier to detect. You cas see that some data is missing and this is due to the 'Length' field having wrong value.
Reading the 'Length' field before the whole structure is dumped is important for our acpiview implementation for the sake of backward compatibility. As ACPI tables usually get updated by appending new fields to existing structures. If someone provides us with a Length that matches the old DBG2 version then we won't print the fields that got recently added to DbgDevInfoParser[] due to a spec update.
I understand there is still an issue of some variables not getting updated correctly because we haven't parsed enough of the DbgDevInfoParser[], for example, AddrSizeOffset. But my next patch series adds code to detect NULL pointers in all parsers.