-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
enable fuzzy_provenance_casts lint in liballoc and libstd #104647
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,6 +13,7 @@ | |
|
||
use super::DwarfReader; | ||
use core::mem; | ||
use core::ptr; | ||
|
||
pub const DW_EH_PE_omit: u8 = 0xFF; | ||
pub const DW_EH_PE_absptr: u8 = 0x00; | ||
|
@@ -151,7 +152,7 @@ unsafe fn read_encoded_pointer( | |
|
||
// DW_EH_PE_aligned implies it's an absolute pointer value | ||
if encoding == DW_EH_PE_aligned { | ||
reader.ptr = round_up(reader.ptr as usize, mem::size_of::<usize>())? as *const u8; | ||
reader.ptr = reader.ptr.with_addr(round_up(reader.ptr.addr(), mem::size_of::<usize>())?); | ||
return Ok(reader.read::<usize>()); | ||
} | ||
|
||
|
@@ -171,7 +172,7 @@ unsafe fn read_encoded_pointer( | |
result += match encoding & 0x70 { | ||
DW_EH_PE_absptr => 0, | ||
// relative to address of the encoded value, despite the name | ||
DW_EH_PE_pcrel => reader.ptr as usize, | ||
DW_EH_PE_pcrel => reader.ptr.expose_addr(), | ||
DW_EH_PE_funcrel => { | ||
if context.func_start == 0 { | ||
return Err(()); | ||
|
@@ -184,7 +185,7 @@ unsafe fn read_encoded_pointer( | |
}; | ||
|
||
if encoding & DW_EH_PE_indirect != 0 { | ||
result = *(result as *const usize); | ||
result = *ptr::from_exposed_addr::<usize>(result); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I hope this can only happen if we previously had the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Who knows, but given that There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This could add UB only if the code relied on the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
That would be incredibly goofy and surprising, so I'm going to assume it's not the case. |
||
} | ||
|
||
Ok(result) | ||
|
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.
A little surprised this is the only lint we turn on in the liballoc tests, but I'll look into that later.
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.
Yeah me too... I briefly tried denying
unsafe_op_in_unsafe_fn
and got too many red lines to pursue this further right now. ;)