FAILED: patch "[PATCH] mm/vma: avoid spurious write locks when mm->mm_lock_seq overflows" failed to apply to 7.3-stable tree
Subsystems (7)
Sasha Levin
maintainerThe patch below does not apply to the 7.3-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.
To reproduce the conflict and resubmit, you may use the following commands:
git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-7.3.y
git checkout FETCH_HEAD
git cherry-pick -x 7135a05838e85845e1bbf6caa6596a7e3b791a40
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<[email protected]>' --in-reply-to '[email protected]' --subject-prefix 'PATCH 7.3.y' 'HEAD^..'
Thanks,
Sasha
------------------ original commit in Linus's tree ------------------
From 7135a05838e85845e1bbf6caa6596a7e3b791a40 Mon Sep 17 00:00:00 2001
From: "Lorenzo Stoakes (ARM)" <[email protected]>
Date: Fri, 16 Oct 2026 12:34:33 +0100
Subject: [PATCH] mm/vma: avoid spurious write locks when mm->mm_lock_seq
overflows
So far the assumption has been that mm->mm_lock_seq overflow is benign, resulting only in readers spuriously falling back to the mmap lock, however it turns out that this was an unsafe assumption.
If a VMA can be spuriously considered write locked that means read lock exclusion does not take place, and thus a VMA can end up write-locked with concurrent readers.
Since overflow only occurs every 2^31 write lock/unlock cycles, resolve the issue by resetting every VMA's vma->vm_lock_seq each time such an overflow occurs.
This is done in vma_end_write_all(), which is called when the mmap write lock is released, i.e. in mmap_write_unlock() and mmap_write_downgrade().
Care must be taken, as resetting the sequence count at overflow means changing the seqcount of VMAs which are already attached and observable.
The mm's seqcount is guaranteed to be odd when a write lock is held, and thus any write locked VMA will have an odd seqcount assigned.
Therefore resetting to an even value prevents spurious write locks, since these can only occur with the mmap write lock held, at which point the mmap seqcount will be odd.
However, vma_start_read() also checks vma->vm_lock_seq == mm->mm_lock_seq, bailing if so (indicating a write lock).
This would cause any even reset value chosen to prevent VMA read locks from being taken - avoid this by also checking whether the VMA seqcount is odd before bailing on the read lock.
So far, vma->vm_lock_seq has defaulted to UINT_MAX, but this has been unnecessary since commit e5e7fb278e59 ("mm: convert mm_lock_seq to a proper seqcount"), since this is assigned when the VMA is still detached, and cannot be observed.
Therefore perform both reset and initialisation of vma->vm_lock_seq by simply setting vma->vm_lock_seq to zero.
The reset, performed in __mm_reset_vma_seqcounts(), only needs to WRITE_ONCE() the value.
However the read of vma->vm_lock_seq in vma_start_read() needs to have acquire semantics to pair with the smp_wmb() in do_raw_write_seqcount_end() so a reader reading a reset value also observes VMA modifications made under the write lock.
Since all VMA write locks were just released and the mmap write lock is still held, there are no concurrent VMA writers.
Concurrent VMA readers are unaffected. New VMA readers observe either zero, never a write lock, or the prior seqcount, behaving as before the reset.
Since this only occurs every 2^31 write lock/unlock cycles, the time taken to update all VMAs is considered to be acceptable.
Also update comments, documentation and VMA userland tests to reflect the change.
User facing effects are - dangerous races that could cause memory corruption or NULL pointer derefences (especially on page table traversal) are avoided.
--- Documentation/mm/process_addrs.rst | 14 ++++- include/linux/mm_types.h | 12 ++-- include/linux/mmap_lock.h | 24 ++++++-- mm/mmap_lock.c | 89 ++++++++++++++++++++++++++---- tools/testing/vma/include/dup.h | 2 +- tools/testing/vma/shared.c | 8 +-- 6 files changed, 120 insertions(+), 29 deletions(-)
Documentation/mm/process_addrs.rst +11 -3
@@ -819,9 +819,17 @@ All this is achieved by the use of per-mm and per-VMA sequence counts, which are used in order to reduce complexity, especially for operations which write-lock multiple VMAs at once. -If the mm sequence count, :c:member:`!mm->mm_lock_seq` is equal to the VMA -sequence count :c:member:`!vma->vm_lock_seq` then the VMA is write-locked. If -they differ, then it is not. +The mm sequence count :c:member:`!mm->mm_lock_seq` is incremented on both mmap +write lock and unlock, so it is odd while the mmap write lock is held. If it is +equal to the VMA sequence count :c:member:`!vma->vm_lock_seq`, and that value +is odd, then the VMA is write-locked. If they differ, then it is not. + +A VMA's sequence count is not updated on unlock, so after 2^31 write lock/unlock +cycles the mm sequence count would wrap and match stale VMA values again. To +prevent this, when the mm sequence count wraps to zero, +:c:func:`!vma_end_write_all` invokes :c:func:`!__mm_reset_vma_seqcounts` to +reset every VMA's sequence count to zero, an even value which can never +indicate a write lock. Each time the mmap write lock is released in :c:func:`!mmap_write_unlock` or :c:func:`!mmap_write_downgrade`, :c:func:`!vma_end_write_all` is invoked which
include/linux/mm_types.h +8 -4
@@ -992,15 +992,19 @@ struct vm_area_struct {* Can only be written (using WRITE_ONCE()) while holding both: * - mmap_lock (in write mode) * - vm_refcnt bit at VM_REFCNT_EXCLUDE_READERS_FLAG is set +* The one exception is __mm_reset_vma_seqcounts(), which stores zero +* (an even value, which can never indicate a write lock) under the +* mmap write lock alone once the mm seqcount has wrapped, so a reader +* holding only vm_refcnt may observe the value change from odd to zero. * Can be read reliably while holding one of: * - mmap_lock (in read or write mode) -* - vm_refcnt bit at VM_REFCNT_EXCLUDE_READERS_BIT is set or vm_refcnt > 1 +* - vm_refcnt bit at VM_REFCNT_EXCLUDE_READERS_BIT is set * Can be read unreliably (using READ_ONCE()) for pessimistic bailout * while holding nothing (except RCU to keep the VMA struct allocated). * -* This sequence counter is explicitly allowed to overflow; sequence -* counter reuse can only lead to occasional unnecessary use of the -* slowpath. +* Assigned the (odd) mm seqcount on write lock and not updated on +* unlock, so a stale value would alias the mm seqcount again 2^31 write +* lock/unlock cycles later. The reset described above prevents this. */ unsigned int vm_lock_seq;
include/linux/mmap_lock.h +19 -5
@@ -154,7 +154,7 @@ static inline void vma_lock_init(struct vm_area_struct *vma, bool reset_refcnt)#endif if (reset_refcnt)refcount_set (&vma->vm_refcnt,0 ); - vma->vm_lock_seq =UINT_MAX ; + vma->vm_lock_seq =0 ; }/*
@@ -229,8 +229,9 @@ static inline void vma_refcount_put(struct vm_area_struct *vma)/* * Use only while holding mmap read lock which guarantees that vma lock is not -* contended (nobody can concurrently write-lock the vma). vma_start_read() should -* not be used in such cases because it might fail due to mm_lock_seq overflow. +* contended (nobody can concurrently write-lock the vma). vma_start_read() need +* not be used in such cases, as the mmap lock already excludes VMA writers so +* its sequence number checks are redundant. * This functionality is used to obtain vma read lock and drop the mmap read lock. * * VMA can't be detached while we are holding mmap lock, therefore in practice this
@@ -252,8 +253,9 @@ static inline bool vma_start_read_locked_nested(struct vm_area_struct *vma, int/* * Use only while holding mmap read lock which guarantees that vma lock is not -* contended (nobody can concurrently write-lock the vma). vma_start_read() should -* not be used in such cases because it might fail due to mm_lock_seq overflow. +* contended (nobody can concurrently write-lock the vma). vma_start_read() need +* not be used in such cases, as the mmap lock already excludes VMA writers so +* its sequence number checks are redundant. * This functionality is used to obtain vma read lock and drop the mmap read lock. * * VMA can't be detached while we are holding mmap lock, therefore in practice this
@@ -552,6 +554,8 @@ static inline int __must_check mmap_write_lock_killable(struct mm_struct *mm)return ret; } +void __mm_reset_vma_seqcounts (struct mm_struct *mm); +/* * Drop all currently-held per-VMA locks. * This is called from the mmap_lock implementation directly before releasing
@@ -564,6 +568,16 @@ static inline void vma_end_write_all(struct mm_struct *mm) {mmap_assert_write_locked (mm);mm_lock_seqcount_end (mm); + +/* +* VMA seqcounts are not updated on unlock, so once the mm seqcount has +* wrapped, any VMA still carrying a sequence number from before the +* wrap would satisfy __is_vma_write_locked() when that number comes +* round again, and readers would not be excluded. Reset every VMA's +* seqcount so that no stale value survives the wrap. +*/ +if (unlikely (!mm->mm_lock_seq.sequence)) +__mm_reset_vma_seqcounts (mm); }static inline void mmap_write_unlock (struct mm_struct *mm)
mm/mmap_lock.c +77 -12
128 lines not on this page · raw message
tools/testing/vma/include/dup.h +1 -1
@@ -1225,7 +1225,7 @@ static inline void vma_init(struct vm_area_struct *vma, struct mm_struct *mm) vma->vm_mm = mm; vma->vm_ops = &vma_dummy_vm_ops;INIT_LIST_HEAD (&vma->anon_vma_chain); - vma->vm_lock_seq =UINT_MAX ; + vma->vm_lock_seq =0 ; }/*
tools/testing/vma/shared.c +4 -4
@@ -65,7 +65,7 @@ struct vm_area_struct *alloc_and_link_vma(struct mm_struct *mm,* begun. Linking to the tree will have caused this to be incremented, * which means we will get a false positive otherwise. */ - vma->vm_lock_seq =UINT_MAX ; + vma->vm_lock_seq =0 ;return vma; }
@@ -97,13 +97,13 @@ int cleanup_mm(struct mm_struct *mm, struct vma_iterator *vmi)bool vma_write_started (struct vm_area_struct *vma) { -int seq = vma->vm_lock_seq; +unsigned int seq = vma->vm_lock_seq;/* We reset after each check. */ - vma->vm_lock_seq =UINT_MAX ; + vma->vm_lock_seq =0 ;/* The vma_start_write() stub simply increments this value. */ -return seq >-1 ; +return seq >0 ; } void __vma_set_dummy_anon_vma(struct vm_area_struct *vma,
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 1/2 mm: add RCU-based VMA lookup helper that waits for writers
From: Dave Hansen <[email protected]>
[ Upstream commit d96082aa35043cd1856e2213e683db778482a7d8 ]
There are basically two parallel ways to look up a VMA: the traditional way, which is protected by mmap_read_lock, and the RCU-based per-VMA lock way which is based on RCU and refcounts. However, per-VMA locks will fail if the lock is help by a writer and therefore never waits. In a number of places we need to wait for the lock and it's done by falling back to mmap_read_lock, locking the VMA and releasing the mmap_lock once VMA is locked.
Add vma_start_read_unlocked() - a variant of the RCU-based lookup that waits for writers. This is basically the same as the existing RCU-based lookup, but on a failure to lock it temporarily takes mmap_lock for read and waits for writers to finish before locking the VMA, dropping the mmap_read_lock and returning the locked VMA. This has some advantages:
1. Callers do not need to have a fallback path for when they collide with writers.
2. Its fast path does not require taking mmap_lock for read.
Basically, when applied correctly, this approach results in faster *and* simpler code.
While at it, fix the comments for vma_start_read_locked(), vma_start_read_locked_nested(), and uffd_lock_vma().
Stable-dep-of: 7135a05838e8 ("mm/vma: avoid spurious write locks when mm->mm_lock_seq overflows")
--- include/linux/mmap_lock.h | 19 +++++++++++++++---- mm/mmap_lock.c | 35 +++++++++++++++++++++++++++++++++++ mm/userfaultfd.c | 6 ++++-- 3 files changed, 54 insertions(+), 6 deletions(-)
include/linux/mmap_lock.h +15 -4
@@ -230,10 +230,14 @@ static inline void vma_refcount_put(struct vm_area_struct *vma) }/* -* Use only while holding mmap read lock which guarantees that locking will not -* fail (nobody can concurrently write-lock the vma). vma_start_read() should +* Use only while holding mmap read lock which guarantees that vma lock is not +* contended (nobody can concurrently write-lock the vma). vma_start_read() should * not be used in such cases because it might fail due to mm_lock_seq overflow. * This functionality is used to obtain vma read lock and drop the mmap read lock. +* +* VMA can't be detached while we are holding mmap lock, therefore in practice this +* function can fail only when there are so many readers that vm_refcnt overflows. +* The failure case is very unlikely and is already annotated as such internally. */ static inline bool vma_start_read_locked_nested (struct vm_area_struct *vma,int subclass) {
@@ -249,16 +253,23 @@ static inline bool vma_start_read_locked_nested(struct vm_area_struct *vma, int }/* -* Use only while holding mmap read lock which guarantees that locking will not -* fail (nobody can concurrently write-lock the vma). vma_start_read() should +* Use only while holding mmap read lock which guarantees that vma lock is not +* contended (nobody can concurrently write-lock the vma). vma_start_read() should * not be used in such cases because it might fail due to mm_lock_seq overflow. * This functionality is used to obtain vma read lock and drop the mmap read lock. +* +* VMA can't be detached while we are holding mmap lock, therefore in practice this +* function can fail only when there are so many readers that vm_refcnt overflows. +* The failure case is very unlikely and is already annotated as such internally. */ static inline bool vma_start_read_locked (struct vm_area_struct *vma) {return vma_start_read_locked_nested (vma,0 ); } +struct vm_area_struct *vma_start_read_unlocked (struct mm_struct *mm, +unsigned long address); +static inline void vma_end_read (struct vm_area_struct *vma) {vma_refcount_put (vma);
mm/mmap_lock.c +35 -0
@@ -341,6 +341,41 @@ struct vm_area_struct *lock_vma_under_rcu(struct mm_struct *mm,return NULL ; } +/** +* vma_start_read_unlocked() - Find the VMA covering 'address' and read-lock it. +* @mm: the mm_struct of the address space to search +* @address: address that the vma should contain +* +* The fast path does not take mmap_lock. Waits for writers to finish if the +* VMA is being modified by taking mmap_lock. +* Use when mmap_lock is not held, otherwise use vma_start_read_locked(). +* Nothing prevents VMAs being unmapped/mapped before or after the VMA is +* looked up, if a stronger guarantee is required, take an mmap_lock. +* +* Return: If a VMA exists which spans @address, return that VMA, read-locked. +* If no VMA is mapped there or, very unlikely, a reference count overflow +* occurred, return NULL. +*/ +struct vm_area_struct *vma_start_read_unlocked (struct mm_struct *mm, +unsigned long address) +{ +struct vm_area_struct *vma; + +/* Fast path: return stable VMA covering 'address': */ + vma =lock_vma_under_rcu (mm, address); +if (vma) +return vma; + +/* Slow path: preclude VMA writers by temporarily getting mmap read lock. */ +mmap_read_lock (mm); + vma =vma_lookup (mm, address); +if (vma && !vma_start_read_locked (vma)) + vma =NULL ; +mmap_read_unlock (mm); + +return vma; +} +static struct vm_area_struct *lock_next_vma_under_mmap_lock (struct mm_struct *mm,struct vma_iterator *vmi,unsigned long from_addr)
mm/userfaultfd.c +4 -2
@@ -130,8 +130,10 @@ struct vm_area_struct *find_vma_and_prepare_anon(struct mm_struct *mm,* * Should be called without holding mmap_lock. * -* Return: A locked vma containing @address, -ENOENT if no vma is found, or -* -ENOMEM if anon_vma couldn't be allocated. +* Return: A locked vma containing @address, -ENOENT if no vma is found, +* -ENOMEM if anon_vma couldn't be allocated, or -EAGAIN if vma refcount +* overflow happened due to high number of readers and the caller should +* retry later. */ static struct vm_area_struct *uffd_lock_vma (struct mm_struct *mm,unsigned long address)
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 2/2 mm/vma: avoid spurious write locks when mm->mm_lock_seq overflows
From: "Lorenzo Stoakes (ARM)" <[email protected]>
[ Upstream commit 7135a05838e85845e1bbf6caa6596a7e3b791a40 ]
So far the assumption has been that mm->mm_lock_seq overflow is benign, resulting only in readers spuriously falling back to the mmap lock, however it turns out that this was an unsafe assumption.
If a VMA can be spuriously considered write locked that means read lock exclusion does not take place, and thus a VMA can end up write-locked with concurrent readers.
Since overflow only occurs every 2^31 write lock/unlock cycles, resolve the issue by resetting every VMA's vma->vm_lock_seq each time such an overflow occurs.
This is done in vma_end_write_all(), which is called when the mmap write lock is released, i.e. in mmap_write_unlock() and mmap_write_downgrade().
Care must be taken, as resetting the sequence count at overflow means changing the seqcount of VMAs which are already attached and observable.
The mm's seqcount is guaranteed to be odd when a write lock is held, and thus any write locked VMA will have an odd seqcount assigned.
Therefore resetting to an even value prevents spurious write locks, since these can only occur with the mmap write lock held, at which point the mmap seqcount will be odd.
However, vma_start_read() also checks vma->vm_lock_seq == mm->mm_lock_seq, bailing if so (indicating a write lock).
This would cause any even reset value chosen to prevent VMA read locks from being taken - avoid this by also checking whether the VMA seqcount is odd before bailing on the read lock.
So far, vma->vm_lock_seq has defaulted to UINT_MAX, but this has been unnecessary since commit e5e7fb278e59 ("mm: convert mm_lock_seq to a proper seqcount"), since this is assigned when the VMA is still detached, and cannot be observed.
Therefore perform both reset and initialisation of vma->vm_lock_seq by simply setting vma->vm_lock_seq to zero.
The reset, performed in __mm_reset_vma_seqcounts(), only needs to WRITE_ONCE() the value.
However the read of vma->vm_lock_seq in vma_start_read() needs to have acquire semantics to pair with the smp_wmb() in do_raw_write_seqcount_end() so a reader reading a reset value also observes VMA modifications made under the write lock.
Since all VMA write locks were just released and the mmap write lock is still held, there are no concurrent VMA writers.
Concurrent VMA readers are unaffected. New VMA readers observe either zero, never a write lock, or the prior seqcount, behaving as before the reset.
Since this only occurs every 2^31 write lock/unlock cycles, the time taken to update all VMAs is considered to be acceptable.
Also update comments, documentation and VMA userland tests to reflect the change.
User facing effects are - dangerous races that could cause memory corruption or NULL pointer derefences (especially on page table traversal) are avoided.
--- Documentation/mm/process_addrs.rst | 14 ++++- include/linux/mm_types.h | 12 ++-- include/linux/mmap_lock.h | 24 ++++++-- mm/mmap_lock.c | 89 ++++++++++++++++++++++++++---- tools/testing/vma/include/dup.h | 2 +- tools/testing/vma/shared.c | 8 +-- 6 files changed, 120 insertions(+), 29 deletions(-)
Documentation/mm/process_addrs.rst +11 -3
@@ -808,9 +808,17 @@ All this is achieved by the use of per-mm and per-VMA sequence counts, which are used in order to reduce complexity, especially for operations which write-lock multiple VMAs at once. -If the mm sequence count, :c:member:`!mm->mm_lock_seq` is equal to the VMA -sequence count :c:member:`!vma->vm_lock_seq` then the VMA is write-locked. If -they differ, then it is not. +The mm sequence count :c:member:`!mm->mm_lock_seq` is incremented on both mmap +write lock and unlock, so it is odd while the mmap write lock is held. If it is +equal to the VMA sequence count :c:member:`!vma->vm_lock_seq`, and that value +is odd, then the VMA is write-locked. If they differ, then it is not. + +A VMA's sequence count is not updated on unlock, so after 2^31 write lock/unlock +cycles the mm sequence count would wrap and match stale VMA values again. To +prevent this, when the mm sequence count wraps to zero, +:c:func:`!vma_end_write_all` invokes :c:func:`!__mm_reset_vma_seqcounts` to +reset every VMA's sequence count to zero, an even value which can never +indicate a write lock. Each time the mmap write lock is released in :c:func:`!mmap_write_unlock` or :c:func:`!mmap_write_downgrade`, :c:func:`!vma_end_write_all` is invoked which
include/linux/mm_types.h +8 -4
@@ -955,15 +955,19 @@ struct vm_area_struct {* Can only be written (using WRITE_ONCE()) while holding both: * - mmap_lock (in write mode) * - vm_refcnt bit at VM_REFCNT_EXCLUDE_READERS_FLAG is set +* The one exception is __mm_reset_vma_seqcounts(), which stores zero +* (an even value, which can never indicate a write lock) under the +* mmap write lock alone once the mm seqcount has wrapped, so a reader +* holding only vm_refcnt may observe the value change from odd to zero. * Can be read reliably while holding one of: * - mmap_lock (in read or write mode) -* - vm_refcnt bit at VM_REFCNT_EXCLUDE_READERS_BIT is set or vm_refcnt > 1 +* - vm_refcnt bit at VM_REFCNT_EXCLUDE_READERS_BIT is set * Can be read unreliably (using READ_ONCE()) for pessimistic bailout * while holding nothing (except RCU to keep the VMA struct allocated). * -* This sequence counter is explicitly allowed to overflow; sequence -* counter reuse can only lead to occasional unnecessary use of the -* slowpath. +* Assigned the (odd) mm seqcount on write lock and not updated on +* unlock, so a stale value would alias the mm seqcount again 2^31 write +* lock/unlock cycles later. The reset described above prevents this. */ unsigned int vm_lock_seq;#endif
include/linux/mmap_lock.h +19 -5
@@ -156,7 +156,7 @@ static inline void vma_lock_init(struct vm_area_struct *vma, bool reset_refcnt)#endif if (reset_refcnt)refcount_set (&vma->vm_refcnt,0 ); - vma->vm_lock_seq =UINT_MAX ; + vma->vm_lock_seq =0 ; }/*
@@ -231,8 +231,9 @@ static inline void vma_refcount_put(struct vm_area_struct *vma)/* * Use only while holding mmap read lock which guarantees that vma lock is not -* contended (nobody can concurrently write-lock the vma). vma_start_read() should -* not be used in such cases because it might fail due to mm_lock_seq overflow. +* contended (nobody can concurrently write-lock the vma). vma_start_read() need +* not be used in such cases, as the mmap lock already excludes VMA writers so +* its sequence number checks are redundant. * This functionality is used to obtain vma read lock and drop the mmap read lock. * * VMA can't be detached while we are holding mmap lock, therefore in practice this
@@ -254,8 +255,9 @@ static inline bool vma_start_read_locked_nested(struct vm_area_struct *vma, int/* * Use only while holding mmap read lock which guarantees that vma lock is not -* contended (nobody can concurrently write-lock the vma). vma_start_read() should -* not be used in such cases because it might fail due to mm_lock_seq overflow. +* contended (nobody can concurrently write-lock the vma). vma_start_read() need +* not be used in such cases, as the mmap lock already excludes VMA writers so +* its sequence number checks are redundant. * This functionality is used to obtain vma read lock and drop the mmap read lock. * * VMA can't be detached while we are holding mmap lock, therefore in practice this
@@ -577,6 +579,8 @@ static inline int __must_check mmap_write_lock_killable(struct mm_struct *mm)return ret; } +void __mm_reset_vma_seqcounts (struct mm_struct *mm); +/* * Drop all currently-held per-VMA locks. * This is called from the mmap_lock implementation directly before releasing
@@ -589,6 +593,16 @@ static inline void vma_end_write_all(struct mm_struct *mm) {mmap_assert_write_locked (mm);mm_lock_seqcount_end (mm); + +/* +* VMA seqcounts are not updated on unlock, so once the mm seqcount has +* wrapped, any VMA still carrying a sequence number from before the +* wrap would satisfy __is_vma_write_locked() when that number comes +* round again, and readers would not be excluded. Reset every VMA's +* seqcount so that no stale value survives the wrap. +*/ +if (unlikely (!mm->mm_lock_seq.sequence)) +__mm_reset_vma_seqcounts (mm); }static inline void mmap_write_unlock (struct mm_struct *mm)
mm/mmap_lock.c +77 -12
128 lines not on this page · raw message
tools/testing/vma/include/dup.h +1 -1
@@ -1229,7 +1229,7 @@ static inline void vma_init(struct vm_area_struct *vma, struct mm_struct *mm) vma->vm_mm = mm; vma->vm_ops = &vma_dummy_vm_ops;INIT_LIST_HEAD (&vma->anon_vma_chain); - vma->vm_lock_seq =UINT_MAX ; + vma->vm_lock_seq =0 ; }/*
tools/testing/vma/shared.c +4 -4
@@ -56,7 +56,7 @@ struct vm_area_struct *alloc_and_link_vma(struct mm_struct *mm,* begun. Linking to the tree will have caused this to be incremented, * which means we will get a false positive otherwise. */ - vma->vm_lock_seq =UINT_MAX ; + vma->vm_lock_seq =0 ;return vma; }
@@ -88,13 +88,13 @@ int cleanup_mm(struct mm_struct *mm, struct vma_iterator *vmi)bool vma_write_started (struct vm_area_struct *vma) { -int seq = vma->vm_lock_seq; +unsigned int seq = vma->vm_lock_seq;/* We reset after each check. */ - vma->vm_lock_seq =UINT_MAX ; + vma->vm_lock_seq =0 ;/* The vma_start_write() stub simply increments this value. */ -return seq >-1 ; +return seq >0 ; } void __vma_set_dummy_anon_vma(struct vm_area_struct *vma,
Signature · 1 line
2.53.0