Closed bgianfo closed 2 years ago
I'm positively baffled that this "stupid" fuzzer still finds bugs. :D
Hi, new contributor here! I thought I'd look into this one if that's OK.
The easy fix is probably to call page_round_up_would_wrap
before page_round_up
in msync
, like mmap
does. However, there are a number of other calls to page_round_up
that are not guarded by page_round_up_would_wrap
(e.g. KBuffer.h), and I'm not sure those are safe.
I wanted to double check how comprehensive we want to be here. I suppose the options are:
msync
.page_round_up
is guarded by page_round_up_would_wrap
.page_round_up
to propagate an error, update every caller and possibly obsolete page_round_up_would_wrap
.Thoughts? I'm happy to open a PR for any of those approaches!
3 seems like the right way path forward for a robust system, especially for all cases where the data is controlled by user mode. I could imagine there being a lot of cases in the kernel that would make that hard today though. Maybe it makes sense to fix msync
first and follow up with fixing the rest in a later PR?
Agreed and thanks! I've opened a PR for option 1, and I can look more deeply into option 3 over the next few days. I'm guessing I can file a separate issue to track the further work (so my current PR is set to resolve this one), but let me know if you just want to reuse this.
Happened across this today while playing with
fuzz-syscalls
:So we end up calling
msync(0x00000000, 0xffffffff, 0x00000001)
, and we correctly detect thatpage_round_up()
on the size would overflow. However we should return an error, not crash the Kernel, :smile:.Looks like we need to add a way so this function can propagate error instead of asserting: