-
Notifications
You must be signed in to change notification settings - Fork 35
Fix fuzzing-discovered issues in filesystem drivers #76
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
An UB was found during fuzz testing. When constructing a cluster number from 16-bit components, a left shift by 16 bits caused an implicit conversion to an 'int' type, leading to UB due to overflow. The fix ensures proper handling of integer promotions by: 1. Using explicit cast to unsigned type before shift operation 2. Ensuring sufficient bit-width for the operation Reference: ISO/IEC 9899:2018 (C17 standard), Section 6.3.1.1 Draft available: http://www.open-std.org/jtc1/sc22/wg14/www/docs/n2310.pdf Signed-off-by: Pavel Naberezhnev <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
026be0d to
ce72698
Compare
40d47c2 to
7a86204
Compare
Ext4Pkg/Ext4Dxe/File.c
Outdated
| EFIAPI | ||
| Ext4Flush ( | ||
| IN EFI_FILE_PROTOCOL* This | ||
| ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Formatting looks wrong. Please reformat with Uncrustify from OC.
Ext4Pkg/Ext4Dxe/File.c
Outdated
|
|
||
| ASSERT (Ext4FileIsOpenable (File)); | ||
| if (!Ext4FileIsOpenable(File)) { | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Extra new line.
Ext4Pkg/Ext4Dxe/File.c
Outdated
| Partition = File->Partition; | ||
|
|
||
| ASSERT (Ext4FileIsOpenable (File)); | ||
| if (!Ext4FileIsOpenable(File)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this not an invariant, I thought original ASSERT is meant to indicate an impossible situation? Can we read a file that is not opened?
7a86204 to
76ff029
Compare
During fuzz testing, we encountered an ASSERT() condition trigger in the Ext4ReadFile() function. This was because when reading the file system superblock, the driver relied on the s_rev_level field, based in which it initializes the Partition structure. The case when (s_rev_level != EXT4_DYNAMIC_REV) was handled incorrectly, leading to improver initialization of the InodeSize field. Additional checks have been added for this case. Signed-off-by: Pavel Naberezhnev <[email protected]>
A memory leak was discovered during fuzz testing: - The async task object (Task) created in FatIFileAccess was not being freed when FatGrowEof() returned an error Changes: - Moved the "Done" label to precede the "Task" check in if-then branch Signed-off-by: Pavel Naberezhnev <[email protected]>
The ext4 driver implements EFI_FILE_PROTOCOL_REVISION but was missing the required Flush() function. According to UEFI Specification v2.10, Section 13.5 (File Protocol), all protocol functions must be implemented. Changes: - Adds minimal Flush() function implementation Signed-off-by: Pavel Naberezhnev <[email protected]>
76ff029 to
8d95204
Compare
Description
This patch series addresses critical issues discovered during fuzzing testing of filesystem drivers:
ASSERT()with explicit error checkingImplemented missing
Flush()function in the ext4 driverAdded minimal dummy implementation to satisfy protocol requirements
Breaking change?
Impacts security?
Includes tests?
How This Was Tested
Integration Instructions