You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, we considered that flip_bitmap_x and flip_bitmap_y break the alignment requirements of unsafe function slice::from_raw_parts_mut with unaligned raw pointer.
let pixels = unsafe{ slice::from_raw_parts_mut(bitmap.as_mut_ptr()as*mutu32, width * height)};
for y in0 .. height / 2{
let low_row = y * width;
let high_row = (height - 1 - y)* width;
for x in0 .. width {
pixels.swap(low_row + x, high_row + x);
Since both of the functions are private, we also checked whether the callers of functions passed the type aligned to 4 bytes actually in the library. We found that in the function rasterize_glyph
final_buffer is created from u8 slice in line 948, which is aligned to 1 byte. Therefore, we are sure that final_buffer is cast to 4 bytes and creates an unaligned pointer.
When the slice is created from unaligned raw pointer, the undefined behavior could lead to inconsistent results in different systems and architectures, which will change the pixels values here. Considering use ptr::copy_non_overlapping to create a new type aligned to 4 bytes before passing into from_raw_parts would be more safe.
The text was updated successfully, but these errors were encountered:
Hi! Thanks for reporting this issue. Do you mind reporting it at https://bugzilla.mozilla.org. This repository is just a downstream mirror of the WebRender with some patches applied for Servo. Almost all work on WebRender is happening upstream in the Gecko repository. Thanks!
Unsoundness
Hi, we considered that
flip_bitmap_x
andflip_bitmap_y
break the alignment requirements of unsafe functionslice::from_raw_parts_mut
with unaligned raw pointer.webrender/wr_glyph_rasterizer/src/platform/unix/font.rs
Lines 353 to 357 in b6b2f65
webrender/wr_glyph_rasterizer/src/platform/unix/font.rs
Lines 361 to 368 in b6b2f65
Since both of the functions are private, we also checked whether the callers of functions passed the type aligned to 4 bytes actually in the library. We found that in the function
rasterize_glyph
webrender/wr_glyph_rasterizer/src/platform/unix/font.rs
Lines 1062 to 1068 in b6b2f65
final_buffer
is created fromu8
slice in line 948, which is aligned to 1 byte. Therefore, we are sure thatfinal_buffer
is cast to 4 bytes and creates an unaligned pointer.When the slice is created from unaligned raw pointer, the undefined behavior could lead to inconsistent results in different systems and architectures, which will change the
pixels
values here. Considering useptr::copy_non_overlapping
to create a new type aligned to 4 bytes before passing intofrom_raw_parts
would be more safe.The text was updated successfully, but these errors were encountered: