Message ID | 20240625191145.3382793-1-Liam.Howlett@oracle.com (mailing list archive) |
---|---|
Headers | show |
Series | Avoid MAP_FIXED gap exposure | expand |
On Tue, 25 Jun 2024 15:11:30 -0400 "Liam R. Howlett" <Liam.Howlett@oracle.com> wrote: > It is now possible to walk the vma tree using the rcu read locks and is > beneficial to do so to reduce lock contention. Doing so while a > MAP_FIXED mapping is executing means that a reader may see a gap in the > vma tree that should never logically exist - and does not when using the > mmap lock in read mode. The temporal gap exists because mmap_region() > calls munmap() prior to installing the new mapping. What are the consequences when this race hits? IOW, why do we need to change anything?
* Andrew Morton <akpm@linux-foundation.org> [240626 16:59]: > On Tue, 25 Jun 2024 15:11:30 -0400 "Liam R. Howlett" <Liam.Howlett@oracle.com> wrote: > > > It is now possible to walk the vma tree using the rcu read locks and is > > beneficial to do so to reduce lock contention. Doing so while a > > MAP_FIXED mapping is executing means that a reader may see a gap in the > > vma tree that should never logically exist - and does not when using the > > mmap lock in read mode. The temporal gap exists because mmap_region() > > calls munmap() prior to installing the new mapping. > > What are the consequences when this race hits? IOW, why do we need to > change anything? > In the (near) future, we want to walk the vma tree to produce /proc/<pid>/maps. Without this change we will see the temporal gap and expose it to the user. This series was initially sent to Suren as part of his patch set. We also have the new interface for an ioctl request to a vma at or above an address. I had highlighted that an rcu reader would be ideal, but proved too difficult at this time. These patches by Andrii are currently not using the rcu reading method as this and a per-vma locking clarification are needed. Since there were two users for this code, I decided to send it out before the other patches. Thanks, Liam
On Wed, 26 Jun 2024 21:15:18 -0400 "Liam R. Howlett" <Liam.Howlett@oracle.com> wrote: > * Andrew Morton <akpm@linux-foundation.org> [240626 16:59]: > > On Tue, 25 Jun 2024 15:11:30 -0400 "Liam R. Howlett" <Liam.Howlett@oracle.com> wrote: > > > > > It is now possible to walk the vma tree using the rcu read locks and is > > > beneficial to do so to reduce lock contention. Doing so while a > > > MAP_FIXED mapping is executing means that a reader may see a gap in the > > > vma tree that should never logically exist - and does not when using the > > > mmap lock in read mode. The temporal gap exists because mmap_region() > > > calls munmap() prior to installing the new mapping. > > > > What are the consequences when this race hits? IOW, why do we need to > > change anything? > > > > In the (near) future, we want to walk the vma tree to produce > /proc/<pid>/maps. Without this change we will see the temporal gap and > expose it to the user. This series was initially sent to Suren as part > of his patch set. > > We also have the new interface for an ioctl request to a vma at or above > an address. I had highlighted that an rcu reader would be ideal, but > proved too difficult at this time. These patches by Andrii are currently > not using the rcu reading method as this and a per-vma locking > clarification are needed. > > Since there were two users for this code, I decided to send it out > before the other patches. OK, thanks. We're approaching -rc6 and things are a bit sketchy so I'm inclined to hold this off until the next cycle, unless there's urgency?
* Andrew Morton <akpm@linux-foundation.org> [240626 21:28]: > On Wed, 26 Jun 2024 21:15:18 -0400 "Liam R. Howlett" <Liam.Howlett@oracle.com> wrote: > > > * Andrew Morton <akpm@linux-foundation.org> [240626 16:59]: > > > On Tue, 25 Jun 2024 15:11:30 -0400 "Liam R. Howlett" <Liam.Howlett@oracle.com> wrote: > > > > > > > It is now possible to walk the vma tree using the rcu read locks and is > > > > beneficial to do so to reduce lock contention. Doing so while a > > > > MAP_FIXED mapping is executing means that a reader may see a gap in the > > > > vma tree that should never logically exist - and does not when using the > > > > mmap lock in read mode. The temporal gap exists because mmap_region() > > > > calls munmap() prior to installing the new mapping. > > > > > > What are the consequences when this race hits? IOW, why do we need to > > > change anything? > > > > > > > In the (near) future, we want to walk the vma tree to produce > > /proc/<pid>/maps. Without this change we will see the temporal gap and > > expose it to the user. This series was initially sent to Suren as part > > of his patch set. > > > > We also have the new interface for an ioctl request to a vma at or above > > an address. I had highlighted that an rcu reader would be ideal, but > > proved too difficult at this time. These patches by Andrii are currently > > not using the rcu reading method as this and a per-vma locking > > clarification are needed. > > > > Since there were two users for this code, I decided to send it out > > before the other patches. > > OK, thanks. We're approaching -rc6 and things are a bit sketchy so I'm > inclined to hold this off until the next cycle, unless there's urgency? > There is no urgency. I'm more than happy to hold off merging to get a full cycle of testing. Thanks, Liam