mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-09-11 13:36:13 +03:00
Kernel: Prevent reference to unaligned u32 in MBRPartitionTable init
This is technically UB, so triggers KUBSAN.
This commit is contained in:
parent
b4cdd6a55c
commit
95b9d77536
Notes:
sideshowbarker
2024-07-17 18:38:54 +09:00
Author: https://github.com/IdanHo Commit: https://github.com/SerenityOS/serenity/commit/95b9d77536 Pull-request: https://github.com/SerenityOS/serenity/pull/24441
@ -59,7 +59,11 @@ MBRPartitionTable::MBRPartitionTable(PartitionableDevice device, u32 start_lba)
|
||||
if (entry.offset == 0x00) {
|
||||
continue;
|
||||
}
|
||||
MUST(m_partitions.try_empend(entry.offset, (entry.offset + entry.length) - 1, entry.type));
|
||||
// We have to place these in stack variables, since try_empend will try to take a reference to them, which is UB (since they're gnu::packed and unaligned)
|
||||
u64 const block_offset = entry.offset;
|
||||
u64 const block_limit = (entry.offset + entry.length) - 1;
|
||||
u8 const partition_type = entry.type;
|
||||
MUST(m_partitions.try_empend(block_offset, block_limit, partition_type));
|
||||
}
|
||||
m_valid = true;
|
||||
}
|
||||
@ -78,7 +82,11 @@ MBRPartitionTable::MBRPartitionTable(PartitionableDevice device)
|
||||
if (entry.offset == 0x00) {
|
||||
continue;
|
||||
}
|
||||
MUST(m_partitions.try_empend(entry.offset, (entry.offset + entry.length) - 1, entry.type));
|
||||
// We have to place these in stack variables, since try_empend will try to take a reference to them, which is UB (since they're gnu::packed and unaligned)
|
||||
u64 const block_offset = entry.offset;
|
||||
u64 const block_limit = (entry.offset + entry.length) - 1;
|
||||
u8 const partition_type = entry.type;
|
||||
MUST(m_partitions.try_empend(block_offset, block_limit, partition_type));
|
||||
}
|
||||
m_valid = true;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user