Skip to content
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

syscall: unchecked overflow in byteq and msgq with GOOS=nacl #21168

Open
bcmills opened this issue Jul 25, 2017 · 0 comments

Comments

@bcmills
Copy link
Member

commented Jul 25, 2017

In looking at examples for #21165, I noticed an unchecked overflow in the syscall package on the nacl platform.

The queue implementation in syscall/net_nacl.go waits on the difference q.w-q.r, and the read and write methods of byteq and msgq increment those variables without checking for overflow. w and r both have type int, so on a 32-bit build it is quite possible to overflow one or the other and cause the reader and/or writer to deadlock.

This program times out due to the deadlock: https://play.golang.org/p/C_YmUjwXwW
In contrast, stopping the reader just before the overflow causes the program to exit successfully: https://play.golang.org/p/XPEU7FoTes

The difference between the two is just one iteration of the loop: the one that tips the writer across that overflow:

-		for n < maxInt {
+		for n+bufSize < maxInt {

(Proposal #19624 would report the overflow here instead of deadlocking the program.)

@bcmills bcmills changed the title syscall(nacl): unchecked overflow in byteq syscall(nacl): unchecked overflow in byteq and msgq Jul 25, 2017

@bradfitz bradfitz changed the title syscall(nacl): unchecked overflow in byteq and msgq syscall: unchecked overflow in byteq and msgq with GOOS=nacl Jul 25, 2017

@ianlancetaylor ianlancetaylor added this to the Unplanned milestone Mar 30, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.