mm/mmap: Fix extra maple tree write
Subsystems (3)
PATCH 1/1 mm/mmap: Fix extra maple tree write
commit 0503ea8f5ba73eb3ab13a81c1eefbaf51405385a upstream.
This was inadvertently fixed during the removal of __vma_adjust().
When __vma_adjust() is adjusting next with a negative value (pushing vma->vm_end lower), there would be two writes to the maple tree. The first write is unnecessary and uses all allocated nodes in the maple state. The second write is necessary but will need to allocate nodes since the first write has used the allocated nodes. This may be a problem as it may not be safe to allocate at this time, such as a low memory situation. Fix the issue by avoiding the first write and only write the adjusted "next" VMA.
--- mm/mmap.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
mm/mmap.c +2 -1
@@ -767,7 +767,8 @@ int __vma_adjust(struct vm_area_struct *vma, unsigned long start, }if (end != vma->vm_end) {if (vma->vm_end > end) { -if (!insert || (insert->vm_start != end)) { +if ((vma->vm_end + adjust_next != end) && + (!insert || (insert->vm_start != end))) {vma_mas_szero (&mas, end, vma->vm_end);mas_reset (&mas); VM_WARN_ON(insert &&
Signature · 1 line
2.39.2
Greg KH
maintainerQuoted 4 lines · Liam R. Howlett
commit
0503ea8f5ba73eb3ab13a81c1eefbaf51405385aupstream.This was inadvertently fixed during the removal of
__vma_adjust().
Quoted 8 lines
When
__vma_adjust()is adjusting next with a negative value (pushingvma->vm_endlower), there would be two writes to the maple tree. The first write is unnecessary and uses all allocated nodes in the maple state. The second write is necessary but will need to allocate nodes since the first write has used the allocated nodes. This may be a problem as it may not be safe to allocate at this time, such as a low memory situation. Fix the issue by avoiding the first write and only write the adjusted "next" VMA.
Are you sure this is the same git id? The one you reference above is _VERY_ different from your 2 line change below.
And the changelog text is not the same.
confused,
greg k-h
Quoted 14 lines · Greg KH
Quoted 4 lines · Liam R. Howlett
commit
0503ea8f5ba73eb3ab13a81c1eefbaf51405385aupstream.This was inadvertently fixed during the removal of
__vma_adjust().Quoted 8 lines
When
__vma_adjust()is adjusting next with a negative value (pushingvma->vm_endlower), there would be two writes to the maple tree. The first write is unnecessary and uses all allocated nodes in the maple state. The second write is necessary but will need to allocate nodes since the first write has used the allocated nodes. This may be a problem as it may not be safe to allocate at this time, such as a low memory situation. Fix the issue by avoiding the first write and only write the adjusted "next" VMA.
Quoted 4 lines
Are you sure this is the same git id? The one you reference above is _VERY_ different from your 2 line change below.
And the changelog text is not the same.
Yes, but I am not sure I've indicated what happened correctly.
The bug exists in the older __vma_adjust() function, but I removed __vma_adjust() and inadvertently fixed the bug. So the bug doesn't exist upstream *because* of that commit:
0503ea8f5ba7 ("mm/mmap: remove __vma_adjust()")
My comment after the commit id indicates what happened, but the documentation wasn't clear to me on how to specify what happened.
Does this answer your question?
Thanks,
Liam
Quoted 26 lines · Liam R. Howlett
Quoted 14 lines · Greg KH
Quoted 4 lines · Liam R. Howlett
commit
0503ea8f5ba73eb3ab13a81c1eefbaf51405385aupstream.This was inadvertently fixed during the removal of
__vma_adjust().Quoted 8 lines
When
__vma_adjust()is adjusting next with a negative value (pushingvma->vm_endlower), there would be two writes to the maple tree. The first write is unnecessary and uses all allocated nodes in the maple state. The second write is necessary but will need to allocate nodes since the first write has used the allocated nodes. This may be a problem as it may not be safe to allocate at this time, such as a low memory situation. Fix the issue by avoiding the first write and only write the adjusted "next" VMA.Quoted 4 lines
Are you sure this is the same git id? The one you reference above is _VERY_ different from your 2 line change below.
And the changelog text is not the same.
Yes, but I am not sure I've indicated what happened correctly.
The bug exists in the older
__vma_adjust()function, but I removed__vma_adjust()and inadvertently fixed the bug. So the bug doesn't exist upstream *because* of that commit:
Quoted 6 lines
0503ea8f5ba7("mm/mmap: remove__vma_adjust()")My comment after the commit id indicates what happened, but the documentation wasn't clear to me on how to specify what happened.
Does this answer your question?
Friendly ping on this one?
Thanks,
Liam
Quoted 16 lines · Liam R. Howlett
Quoted 15 lines · Liam R. Howlett
Quoted 14 lines · Greg KH
Quoted 12 lines · Liam R. Howlett
commit
0503ea8f5ba73eb3ab13a81c1eefbaf51405385aupstream.This was inadvertently fixed during the removal of
__vma_adjust().When
__vma_adjust()is adjusting next with a negative value (pushingvma->vm_endlower), there would be two writes to the maple tree. The first write is unnecessary and uses all allocated nodes in the maple state. The second write is necessary but will need to allocate nodes since the first write has used the allocated nodes. This may be a problem as it may not be safe to allocate at this time, such as a low memory situation. Fix the issue by avoiding the first write and only write the adjusted "next" VMA.
Quoted 6 lines
Quoted 6 lines
Quoted 4 lines
Are you sure this is the same git id? The one you reference above is _VERY_ different from your 2 line change below.
And the changelog text is not the same.
Yes, but I am not sure I've indicated what happened correctly.
"commit 0503ea8f5ba73eb3ab13a81c1eefbaf51405385a upstream." is indeed not the best indication. For stable it would mean you're backporting said commit, which is not the case.
Quoted 8 lines
Quoted 8 lines
The bug exists in the older
__vma_adjust()function, but I removed__vma_adjust()and inadvertently fixed the bug. So the bug doesn't exist upstream *because* of that commit:
0503ea8f5ba7("mm/mmap: remove__vma_adjust()")My comment after the commit id indicates what happened, but the documentation wasn't clear to me on how to specify what happened.
I think it's because the process discourages stable-specific fixes. However this is the case where such approach is much simpler than backporting several series with non-trivial vma_merge() cleanups and subsequent follow-up fixes...
So I agree with the exceptional stable-specific fix. Can you pinpoint a
Fixes: tag? Some of the commits introducing the maple tree?
Vlastimil
Quoted 7 lines
Quoted 1 line
Does this answer your question?
Friendly ping on this one?
Thanks,
Liam
Quoted 20 lines · Vlastimil Babka
Quoted 19 lines · Liam R. Howlett
Quoted 18 lines · Liam R. Howlett
Quoted 17 lines · Greg KH
Quoted 4 lines · Liam R. Howlett
commit
0503ea8f5ba73eb3ab13a81c1eefbaf51405385aupstream.This was inadvertently fixed during the removal of
__vma_adjust().Quoted 8 lines
When
__vma_adjust()is adjusting next with a negative value (pushingvma->vm_endlower), there would be two writes to the maple tree. The first write is unnecessary and uses all allocated nodes in the maple state. The second write is necessary but will need to allocate nodes since the first write has used the allocated nodes. This may be a problem as it may not be safe to allocate at this time, such as a low memory situation. Fix the issue by avoiding the first write and only write the adjusted "next" VMA.Are you sure this is the same git id? The one you reference above is _VERY_ different from your 2 line change below.
Quoted 7 lines
Quoted 3 lines
Quoted 3 lines
Quoted 1 line
And the changelog text is not the same.
Yes, but I am not sure I've indicated what happened correctly.
"commit
0503ea8f5ba73eb3ab13a81c1eefbaf51405385aupstream." is indeed not the best indication. For stable it would mean you're backporting said commit, which is not the case.
Okay, thanks. I am certainly not doing that.
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
The bug exists in the older
__vma_adjust()function, but I removed__vma_adjust()and inadvertently fixed the bug. So the bug doesn't exist upstream *because* of that commit:
0503ea8f5ba7("mm/mmap: remove__vma_adjust()")
Quoted 7 lines
Quoted 2 lines
Quoted 2 lines
My comment after the commit id indicates what happened, but the documentation wasn't clear to me on how to specify what happened.
I think it's because the process discourages stable-specific fixes. However this is the case where such approach is much simpler than backporting several series with non-trivial
vma_merge()cleanups and subsequent follow-up fixes...
Thanks, and I agree. I want to avoid that at all costs. The chances of introducing subtle bugs would be unacceptable for stable.
Quoted 3 lines
So I agree with the exceptional stable-specific fix. Can you pinpoint a
Fixes: tag? Some of the commits introducing the maple tree?
Thanks for the response & explanation,
Liam
Greg KH
maintainerQuoted 27 lines · Liam R. Howlett
Quoted 26 lines · Liam R. Howlett
Quoted 14 lines · Greg KH
Quoted 4 lines · Liam R. Howlett
commit
0503ea8f5ba73eb3ab13a81c1eefbaf51405385aupstream.This was inadvertently fixed during the removal of
__vma_adjust().Quoted 8 lines
When
__vma_adjust()is adjusting next with a negative value (pushingvma->vm_endlower), there would be two writes to the maple tree. The first write is unnecessary and uses all allocated nodes in the maple state. The second write is necessary but will need to allocate nodes since the first write has used the allocated nodes. This may be a problem as it may not be safe to allocate at this time, such as a low memory situation. Fix the issue by avoiding the first write and only write the adjusted "next" VMA.Quoted 4 lines
Are you sure this is the same git id? The one you reference above is _VERY_ different from your 2 line change below.
And the changelog text is not the same.
Yes, but I am not sure I've indicated what happened correctly.
The bug exists in the older
__vma_adjust()function, but I removed__vma_adjust()and inadvertently fixed the bug. So the bug doesn't exist upstream *because* of that commit:
Quoted 8 lines
Quoted 6 lines
0503ea8f5ba7("mm/mmap: remove__vma_adjust()")My comment after the commit id indicates what happened, but the documentation wasn't clear to me on how to specify what happened.
Does this answer your question?
Friendly ping on this one?
Now queued up, thanks.
greg k-h
Patch "mm/mmap: Fix extra maple tree write" has been added to the 6.1-stable tree
In reply to Liam R. HowlettThis is a note to let you know that I've just added the patch titled
mm/mmap: Fix extra maple tree write
to the 6.1-stable tree which can be found at:
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary
The filename of the patch is:
mm-mmap-fix-extra-maple-tree-write.patch
and it can be found in the queue-6.1 subdirectory.
If you, or anyone else, feels it should not be added to the stable tree, please let <[email protected]> know about it.
From [email protected] Sun Jul 16 17:02:51 2023
From: "Liam R. Howlett" <[email protected]>
Date: Thu, 6 Jul 2023 14:51:35 -0400
Subject: mm/mmap: Fix extra maple tree write
To: [email protected]
Cc: Andrew Morton <[email protected]>, "Liam R. Howlett" <[email protected]>, John Hsu <[email protected]>, [email protected], [email protected]
Message-ID: <[email protected]>
From: "Liam R. Howlett" <[email protected]>
based on commit 0503ea8f5ba73eb3ab13a81c1eefbaf51405385a upstream.
This was inadvertently fixed during the removal of __vma_adjust().
When __vma_adjust() is adjusting next with a negative value (pushing vma->vm_end lower), there would be two writes to the maple tree. The first write is unnecessary and uses all allocated nodes in the maple state. The second write is necessary but will need to allocate nodes since the first write has used the allocated nodes. This may be a problem as it may not be safe to allocate at this time, such as a low memory situation. Fix the issue by avoiding the first write and only write the adjusted "next" VMA.
--- mm/mmap.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
mm/mmap.c +2 -1
@@ -767,7 +767,8 @@ int __vma_adjust(struct vm_area_struct * }if (end != vma->vm_end) {if (vma->vm_end > end) { -if (!insert || (insert->vm_start != end)) { +if ((vma->vm_end + adjust_next != end) && + (!insert || (insert->vm_start != end))) {vma_mas_szero (&mas, end, vma->vm_end);mas_reset (&mas); VM_WARN_ON(insert &&
Patches currently in stable-queue which might be from [email protected] are
queue-6.1/mm-mmap-fix-extra-maple-tree-write.patch queue-6.1/mm-mmap-fix-vm_locked-check-in-do_vmi_align_munmap.patch
Patch "mm/mmap: Fix extra maple tree write" has been added to the 5.4-stable tree
In reply to Liam R. HowlettThis is a note to let you know that I've just added the patch titled
mm/mmap: Fix extra maple tree write
to the 5.4-stable tree which can be found at:
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary
The filename of the patch is:
mm-mmap-fix-extra-maple-tree-write.patch
and it can be found in the queue-5.4 subdirectory.
If you, or anyone else, feels it should not be added to the stable tree, please let <[email protected]> know about it.
From [email protected] Sun Jul 16 17:02:51 2023
From: "Liam R. Howlett" <[email protected]>
Date: Thu, 6 Jul 2023 14:51:35 -0400
Subject: mm/mmap: Fix extra maple tree write
To: [email protected]
Cc: Andrew Morton <[email protected]>, "Liam R. Howlett" <[email protected]>, John Hsu <[email protected]>, [email protected], [email protected]
Message-ID: <[email protected]>
From: "Liam R. Howlett" <[email protected]>
based on commit 0503ea8f5ba73eb3ab13a81c1eefbaf51405385a upstream.
This was inadvertently fixed during the removal of __vma_adjust().
When __vma_adjust() is adjusting next with a negative value (pushing vma->vm_end lower), there would be two writes to the maple tree. The first write is unnecessary and uses all allocated nodes in the maple state. The second write is necessary but will need to allocate nodes since the first write has used the allocated nodes. This may be a problem as it may not be safe to allocate at this time, such as a low memory situation. Fix the issue by avoiding the first write and only write the adjusted "next" VMA.
--- mm/mmap.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
mm/mmap.c +2 -1
@@ -767,7 +767,8 @@ int __vma_adjust(struct vm_area_struct *vma, unsigned long start, }if (end != vma->vm_end) {if (vma->vm_end > end) { -if (!insert || (insert->vm_start != end)) { +if ((vma->vm_end + adjust_next != end) && + (!insert || (insert->vm_start != end))) {vma_mas_szero (&mas, end, vma->vm_end);mas_reset (&mas); VM_WARN_ON(insert &&
Signature · 7 lines
2.39.2 Patches currently in stable-queue which might be from [email protected] are queue-5.4/mm-mmap-fix-extra-maple-tree-write.patch