On 32-bit platforms, this expands the shm_size to a 64-bit quantity and resolves a mismatch between the shmfd size and underlying vm_object size. The implementation did not account for this kind of mismatch.
Tentatively, I'd like to MFC it to stable/12, perhaps something like the following diff:
diff --git a/sys/kern/uipc_shm.c b/sys/kern/uipc_shm.c index 700ee55bc99..d8a614afb41 100644 --- a/sys/kern/uipc_shm.c +++ b/sys/kern/uipc_shm.c @@ -531,6 +531,11 @@ shm_dotruncate(struct shmfd *shmfd, off_t length) object->charge += delta; } shmfd->shm_size = length; +#if SIZE_MAX < UINT64_MAX + shmfd->shm_oldsize = length & 0xffffffff; +#else + shmfd->shm_oldsize = length; +#endif mtx_lock(&shm_timestamp_lock); vfs_timestamp(&shmfd->shm_ctime); shmfd->shm_mtime = shmfd->shm_ctime; diff --git a/sys/sys/mman.h b/sys/sys/mman.h index b2fad0e4757..aed759b5a8d 100644 --- a/sys/sys/mman.h +++ b/sys/sys/mman.h @@ -207,7 +207,7 @@ typedef __size_t size_t; struct file; struct shmfd { - size_t shm_size; + size_t shm_oldsize; vm_object_t shm_object; int shm_refs; uid_t shm_uid; @@ -230,6 +230,7 @@ struct shmfd { struct rangelock shm_rl; struct mtx shm_mtx; + vm_ooffset_t shm_size; }; #endif
This would maintain some level of compatibility without breaking the layout too bad. New libprocstat would read garbage for the size on older 12 kernel core dumps (e.g. from fstat -M), but it's not clear to me that we strongly care about that.