DragonOS icon indicating copy to clipboard operation
DragonOS copied to clipboard

fix: `page_align_up` overflow

Open Marsman1996 opened this issue 1 year ago • 4 comments

Fix #1077 by using wrapping_add.

However, RedoxOS and Asterinas use checked_add. But change to checked_add in DragonOS will lead to a lot of code changes.

https://gitlab.redox-os.org/redox-os/relibc/-/merge_requests/569

https://github.com/asterinas/asterinas/blob/c0e572becdac63d814b460875dccb9d833d2b06d/ostd/libs/align_ext/src/lib.rs#L51-L54

Marsman1996 avatar Dec 11 '24 11:12 Marsman1996

感谢您的pull request,欢迎加入!🎉 DragonOS社区很兴奋地期待审核您的更改,您将在接下来的两周内收到 @fslongjin @GnoCiYeH @Chiichen (NB. this repo may be misconfigured) 的回复。💬😊

Please see the contribution instructions for more information. Namely, in order to ensure the minimum review times lag, PR authors and assigned reviewers should ensure that the review label (S-等待审查 and S-等待作者修改) stays updated, invoking these commands when appropriate:

  • @dragonosbot author: 审查结束后,PR的作者应检查评论并采取相应行动
  • @dragonosbot review: 作者已完成修改,将此PR提交给reviewer进行审阅,此PR将再次在审阅者队列中排队

dragonosbot avatar Dec 11 '24 11:12 dragonosbot

checked_add 的话,有什么影响吗~

fslongjin avatar Dec 11 '24 13:12 fslongjin

如果改用 checked_add,发生溢出时 checked_add 返回 None,那么我们需要类似 RedoxOS 的这个 PR 修改 page_align_up 的返回类型并在每个调用位置进行异常处理

Marsman1996 avatar Dec 11 '24 14:12 Marsman1996

It seems DragonOS shall not call page_align_up for start of msync.

https://github.com/DragonOS-Community/DragonOS/blob/72423f90bb39a9a3919b3630857785653c97d36c/kernel/src/syscall/mod.rs#L1171

Linux just return EINVAL when start unaligned.

https://elixir.bootlin.com/linux/v6.10.5/source/mm/msync.c#L44-L45


如果与 Linux 兼容的话,DragonOS 似乎不应该为 msyncstart 做页对齐,因为当不对齐时 Linux 直接返回 EINVAL 了

Marsman1996 avatar Dec 11 '24 14:12 Marsman1996