-
-
Notifications
You must be signed in to change notification settings - Fork 141
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
[BUG REPORT] Integer overflow in page_align_up
#1077
Comments
I'm trying to add check for overflow in 我尝试在 # The release profile, used for `cargo build --release`
[profile.release]
debug = false
overflow-checks = true |
cc @MemoryShore @Jomocool |
但是这个貌似也是正常?Linux上面传入过大的len的话,会返回什么? @Marsman1996 |
以 但是在 Rust 程序中,这样的溢出在 debug 模式下会导致 panic。
|
这里可以考虑在内核里面加个判断啥的,实现行为上跟Linux一致? 你方便发个pr吗 @Marsman1996 |
👌 |
我没太理解,按照上面你所描述的,dragonos不也是返回了EINVAL吗? @Marsman1996 |
dragonos现在是直接返回usize吧 |
dragonos 在 align 溢出后返回 DragonOS/kernel/src/mm/syscall.rs Lines 457 to 459 in e92424d
也就是说虽然 dragonos 目前也是返回的 |
那么, 在 #1078 的修改后,貌似这个地方就不会返回EINVAL了。这样貌似不对? |
使用 addr.wrapping_add(page_size - 1) & (!(page_size - 1)) 在溢出时返回值依然是 |
描述错误/Describe the bug
There is an integer overflow in
page_align_up()
at kernel/src/libs/align.rs:135 when program calls memory related syscall (i.e.,mmap
,munmap
, andmprotect
) with largelen
.DragonOS/kernel/src/libs/align.rs
Lines 133 to 136 in 72423f9
请填写您的电脑的信息/Environment
重现步骤/To Reproduce
munmap
with largelen
期望行为/Expected behavior
DragonOS should check the add behavior first and not overflow here.
屏幕截图/Log
I add log before and after the alignment:
The text was updated successfully, but these errors were encountered: