mm/mmap: remove unnecessary vp->vma check in vma_prepare
Subsystems (3)
Suren Baghdasaryan
reviewerPATCH 1/2 mm/mmap: remove unnecessary vp->vma check in vma_prepare
vp->vma in vma_prepare() is always non-NULL, therefore checking it is not necessary. Remove the extra check.
---
Fix cleanly apply over mm-unstable, SHA in "Fixes" is from that tree.
mm/mmap.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
mm/mmap.c +1 -2
@@ -505,8 +505,7 @@ static inline void init_vma_prep(struct vma_prepare *vp,*/ static inline void vma_prepare (struct vma_prepare *vp) { -if (vp->vma) -vma_start_write (vp->vma); +vma_start_write (vp->vma);if (vp->adj_next)vma_start_write (vp->adj_next);/* vp->insert is always a newly created VMA, no need for locking */
Signature · 1 line
2.39.2.722.g9855ee24e9-goog
Suren Baghdasaryan
reviewerPATCH 2/2 mm: document FAULT_FLAG_VMA_LOCK flag
FAULT_FLAG_VMA_LOCK flag was introduced without proper description. Fix this by documenting it.
---
Fix cleanly apply over mm-unstable, SHA in "Fixes" is from that tree.
include/linux/mm_types.h | 1 + 1 file changed, 1 insertion(+)
include/linux/mm_types.h +1 -0
@@ -1064,6 +1064,7 @@ typedef struct {* mapped after the fault. * @FAULT_FLAG_ORIG_PTE_VALID: whether the fault has vmf->orig_pte cached. * We should only access orig_pte if this flag set. +* @FAULT_FLAG_VMA_LOCK: The fault is handled under VMA lock. * * About @FAULT_FLAG_ALLOW_RETRY and @FAULT_FLAG_TRIED: we can specify * whether we would allow page faults to retry by specifying these two
Signature · 1 line
2.39.2.722.g9855ee24e9-goog
Re: [PATCH 2/2] mm: document FAULT_FLAG_VMA_LOCK flag
Quoted 9 lines · Suren Baghdasaryan
FAULT_FLAG_VMA_LOCKflag was introduced without proper description. Fix this by documenting it.Fixes 863be34fc093 ("mm: add FAULT_FLAG_VMA_LOCK flag")Reported-by Stephen Rothwell <[email protected]>Signed-off-by Suren Baghdasaryan <[email protected]>---
Fix cleanly apply over mm-unstable, SHA in "Fixes" is from that tree.
Okay, that should be squashed then. LGTM.
Signature · 3 lines
Thanks, David / dhildenb
Suren Baghdasaryan
reviewerRe: [PATCH 2/2] mm: document FAULT_FLAG_VMA_LOCK flag
Quoted 5 lines · David Hildenbrand
Quoted 3 lines · Suren Baghdasaryan
FAULT_FLAG_VMA_LOCKflag was introduced without proper description. Fix this by documenting it.
Quoted 8 lines
Quoted 6 lines
Fixes 863be34fc093 ("mm: add FAULT_FLAG_VMA_LOCK flag")Reported-by Stephen Rothwell <[email protected]>Signed-off-by Suren Baghdasaryan <[email protected]>---
Fix cleanly apply over mm-unstable, SHA in "Fixes" is from that tree.Okay, that should be squashed then. LGTM.
Yeah, both fixes in this patchset could be squashed into the original series without information loss. I'll leave that to Andrew to decide what makes more sense here.
Thanks!
Quoted 6 lines
--
Thanks,David / dhildenb
Quoted 6 lines · Suren Baghdasaryan
vp->vmainvma_prepare()is always non-NULL, therefore checking it is not necessary. Remove the extra check.Fixes e8f071350ea5 ("mm/mmap: write-lock VMAs in vma_prepare before modifying them")Reported-by kernel test robot <[email protected]>Reported-by Dan Carpenter <[email protected]>
It would be great to mention that this simply silences a smatch warning. Otherwise, one might be mislead that this commit fixes an actual BUG ;)
Quoted 13 lines
Signed-off-by Suren Baghdasaryan <[email protected]>---
Fix cleanly apply over mm-unstable, SHA in "Fixes" is from that tree.mm/mmap.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)mm/mmap.c +0
-0
mm/mmap.c static inline void init_vma_prep(struct vma_prepare *vp, · line 511
Quoted 9 lines
mm/mmap.c +1
-2@@ -505,8 +505,7 @@ static inline void init_vma_prep(struct vma_prepare *vp,*/ static inline void vma_prepare (struct vma_prepare *vp) { -if (vp->vma) -vma_start_write (vp->vma); +vma_start_write (vp->vma);if (vp->adj_next)vma_start_write (vp->adj_next);/* vp->insert is always a newly created VMA, no need for locking */
Yes, that looks correct.
Signature · 3 lines
Thanks, David / dhildenb
Quoted 19 lines · Suren Baghdasaryan
vp->vmainvma_prepare()is always non-NULL, therefore checking it is not necessary. Remove the extra check.Fixes e8f071350ea5 ("mm/mmap: write-lock VMAs in vma_prepare before modifying them")Reported-by kernel test robot <[email protected]>Reported-by Dan Carpenter <[email protected]>Signed-off-by Suren Baghdasaryan <[email protected]>---
Fix cleanly apply over mm-unstable, SHA in "Fixes" is from that tree.mm/mmap.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)mm/mmap.c +0
-0
mm/mmap.c static inline void init_vma_prep(struct vma_prepare *vp, · line 508
Quoted 6 lines
mm/mmap.c +1
-2@@ -505,8 +505,7 @@ static inline void init_vma_prep(struct vma_prepare *vp,*/ static inline void vma_prepare (struct vma_prepare *vp) { -if (vp->vma) -vma_start_write (vp->vma); +vma_start_write (vp->vma);
Would a WARN_ON_ONCE() be worth it? Maybe not since it will be detected rather quickly once we dereference it below, but it might make it more clear as to what happened?
I'm happy either way.
Quoted 6 lines
mm/mmap.c +0
-0if (vp->adj_next)vma_start_write (vp->adj_next);/* vp->insert is always a newly created VMA, no need for locking */ Signature · 1 line
2.39.2.722.g9855ee24e9-goog
Suren Baghdasaryan
reviewerQuoted 16 lines · Liam R. Howlett
Quoted 14 lines · Suren Baghdasaryan
vp->vmainvma_prepare()is always non-NULL, therefore checking it is not necessary. Remove the extra check.Fixes e8f071350ea5 ("mm/mmap: write-lock VMAs in vma_prepare before modifying them")Reported-by kernel test robot <[email protected]>Reported-by Dan Carpenter <[email protected]>Signed-off-by Suren Baghdasaryan <[email protected]>---
Fix cleanly apply over mm-unstable, SHA in "Fixes" is from that tree.mm/mmap.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
Quoted 15 lines
mm/mmap.c static inline void init_vma_prep(struct vma_prepare *vp, · line 508
Quoted 11 lines
mm/mmap.c +1
-2@@ -505,8 +505,7 @@ static inline void init_vma_prep(struct vma_prepare *vp,*/ static inline void vma_prepare (struct vma_prepare *vp) { -if (vp->vma) -vma_start_write (vp->vma); +vma_start_write (vp->vma);Would a
WARN_ON_ONCE()be worth it? Maybe not since it will be detected rather quickly once we dereference it below, but it might make it more clear as to what happened?
WARN_ON_ONCE() seems like an overkill to me. It always follows after init_multi_vma_prep()/init_vma_prep() both of which set the VMA. Risk should be minimal here and as you said, misuse is easily discoverable.
Quoted 11 lines
I'm happy either way.
Reviewed-by Liam R. Howlett <[email protected]>Quoted 6 lines
mm/mmap.c +0
-1if (vp->adj_next)vma_start_write (vp->adj_next);/* vp->insert is always a newly created VMA, no need for locking */ --2.39.2.722.g9855ee24e9-goog