Page MenuHomeFreeBSD

posixshm: Fix range locking in shm_write()
ClosedPublic

Authored by markj on Sat, Apr 5, 4:38 PM.
Tags
None
Referenced Files
F116091799: D49673.id153177.diff
Fri, May 2, 10:56 AM
Unknown Object (File)
Thu, May 1, 1:36 AM
Unknown Object (File)
Sun, Apr 27, 3:55 AM
Unknown Object (File)
Thu, Apr 17, 12:40 AM
Unknown Object (File)
Mon, Apr 14, 7:46 AM
Unknown Object (File)
Fri, Apr 11, 7:03 AM
Unknown Object (File)
Tue, Apr 8, 6:48 AM
Unknown Object (File)
Tue, Apr 8, 3:18 AM
Subscribers

Details

Summary

There is a somewhat strange case where when writing to a POSIX shm
object, the object is not allowed to grow, and the I/O offset+length
overflows. In that case we simply truncate the I/O to the object size.
Later we write-lock the range [offset, objsize). However, we were not
checking whether offset > objsize, in which case we're writing zero
bytes but locking an invalid range.

Modify the range locking in shm_write() to take this possibility into
account. While here, rename a variable to make its purpose a bit more
clear, and add an assertion against negative offsets (which is supposed
to be enforced by the caller of fo_write for I/O to files that aren't
character devices).

Reported by: syzkaller

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

markj requested review of this revision.Sat, Apr 5, 4:38 PM

Reported by: syzkaller

In particular, this tripped an assertion I added locally to kern_rangelock.c which checks that the range passed in has start <= end.

This revision is now accepted and ready to land.Sat, Apr 5, 9:27 PM
This revision was automatically updated to reflect the committed changes.