An approach to D21391 using rangelocks instead of an sx for the shm seal lock would have shm_dotruncate_locked take a cookie and assert that it's been granted a write lock to leave the locking out of the _locked function.
I do not yet know how I like the rangelock approach, but I think this is a good idea if we go that route.