mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-09-14 13:32:23 +00: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: 95b9d77536
Pull-request: https://github.com/SerenityOS/serenity/pull/24441
1 changed files with 10 additions and 2 deletions
|
@ -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…
Add table
Add a link
Reference in a new issue