-
Notifications
You must be signed in to change notification settings - Fork 17.5k
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
os: ReadAt should check bounds before re-slicing destination buffer #45592
Comments
That should never happen. At least, on darwin/amd64 it bottoms out at the Can you provide a reproducible example? In any case, the fix is not to change the re-slice. It is to fix the underlying bug (which is much more serious, if that is in fact what is happening). |
The underlying bug is a DMA kernel driver (exposing a character-device file) which is overriding the requested read/write length for The bug is more serious than a missing bounds-check in the |
I also falsely added |
I'm not sure it's reasonable for the Go standard library to verify that kernel system calls behave correctly. That seems like a fair amount of work for essentially zero gain. |
@gopherbot remove WaitingForInfo |
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (
go env
)?GOOS=linux
GOARCH=amd64
What did you do?
Called the
(*os.File).ReadAt
method with a 2-byte destination slice.What did you expect to see?
Data in the destination slice and no error or panic.
What did you see instead?
The panic corresponds with the source line
b = b[m:]
.Before re-slicing the destination buffer, a bounds-check is needed. Apparently, it's possible for lower layers to return more than the requested number of bytes within the initial read.
The text was updated successfully, but these errors were encountered: