mm: refactor vm_area_struct::anon_vma_name usage code
Subsystems (10)
Suren Baghdasaryan
reviewerPATCH v2 1/3 mm: refactor vm_area_struct::anon_vma_name usage code
Avoid mixing strings and their anon_vma_name referenced pointers by using struct anon_vma_name whenever possible. This simplifies the code and allows easier sharing of anon_vma_name structures when they represent the same name.
---
changes in v2:
- renamed vma_anon_name to anon_vma_name, dup_vma_anon_name to dup_anon_vma_name and free_vma_anon_name to free_anon_vma_name, per Michal Hocko
- moved anon_vma_name_get and anon_vma_name_put close together, per Michal Hocko
- Updated the comment in free_anon_vma_name, per Michal Hocko
- Removed extra check in anon_vma_name_alloc, per Michal Hocko
- Removed extra variable usage in madvise_vma_behavior, per Michal Hocko
- Cleaned whitespace noise in madvise_set_anon_name, per Michal Hocko
fs/proc/task_mmu.c | 6 +-- fs/userfaultfd.c | 6 +-- include/linux/mm.h | 7 ++-- include/linux/mm_inline.h | 87 ++++++++++++++++++++++++++------------- include/linux/mm_types.h | 5 ++- kernel/fork.c | 4 +- kernel/sys.c | 19 +++++---- mm/madvise.c | 87 +++++++++++++-------------------------- mm/mempolicy.c | 2 +- mm/mlock.c | 2 +- mm/mmap.c | 12 +++--- mm/mprotect.c | 2 +- 12 files changed, 125 insertions(+), 114 deletions(-)
fs/proc/task_mmu.c +3 -3
@@ -309,7 +309,7 @@ show_map_vma(struct seq_file *m, struct vm_area_struct *vma) name =arch_vma_name (vma);if (!name) { -const char *anon_name; +struct anon_vma_name *anon_name;if (!mm) { name ="[vdso]" ;
@@ -327,10 +327,10 @@ show_map_vma(struct seq_file *m, struct vm_area_struct *vma) goto done; } - anon_name =vma_anon_name (vma); + anon_name =anon_vma_name (vma);if (anon_name) {seq_pad (m,' ' ); -seq_printf (m,"[anon:%s]" , anon_name); +seq_printf (m,"[anon:%s]" , anon_name->name); } }
fs/userfaultfd.c +3 -3
@@ -878,7 +878,7 @@ static int userfaultfd_release(struct inode *inode, struct file *file) new_flags, vma->anon_vma, vma->vm_file, vma->vm_pgoff,vma_policy (vma), - NULL_VM_UFFD_CTX, vma_anon_name(vma)); + NULL_VM_UFFD_CTX, anon_vma_name(vma));if (prev) vma = prev;else
@@ -1438,7 +1438,7 @@ static int userfaultfd_register(struct userfaultfd_ctx *ctx, vma->anon_vma, vma->vm_file, vma->vm_pgoff,vma_policy (vma), ((struct vm_userfaultfd_ctx ){ ctx }), - vma_anon_name(vma)); + anon_vma_name(vma));if (prev) { vma = prev; goto next;
@@ -1615,7 +1615,7 @@ static int userfaultfd_unregister(struct userfaultfd_ctx *ctx, prev =vma_merge (mm, prev, start, vma_end, new_flags, vma->anon_vma, vma->vm_file, vma->vm_pgoff,vma_policy (vma), -NULL_VM_UFFD_CTX ,vma_anon_name (vma)); +NULL_VM_UFFD_CTX ,anon_vma_name (vma));if (prev) { vma = prev; goto next;
include/linux/mm.h +4 -3
@@ -2626,7 +2626,7 @@ static inline int vma_adjust(struct vm_area_struct *vma, unsigned long start,extern struct vm_area_struct *vma_merge (struct mm_struct *,struct vm_area_struct *prev,unsigned long addr,unsigned long end,unsigned long vm_flags,struct anon_vma *,struct file *,pgoff_t , -struct mempolicy *,struct vm_userfaultfd_ctx ,const char *); +struct mempolicy *,struct vm_userfaultfd_ctx ,struct anon_vma_name *);extern struct anon_vma *find_mergeable_anon_vma (struct vm_area_struct *);extern int __split_vma (struct mm_struct *,struct vm_area_struct *,unsigned long addr,int new_below);
@@ -3372,11 +3372,12 @@ static inline int seal_check_future_write(int seals, struct vm_area_struct *vma)#ifdef CONFIG_ANON_VMA_NAME int madvise_set_anon_name (struct mm_struct *mm,unsigned long start, -unsigned long len_in,const char *name); +unsigned long len_in, +struct anon_vma_name *anon_name);#else static inline int madvise_set_anon_name (struct mm_struct *mm,unsigned long start, -unsigned long len_in,const char *name) { +unsigned long len_in,struct anon_vma_name *anon_name) {return 0 ; }#endif
include/linux/mm_inline.h +59 -28
109 lines not on this page · raw message
include/linux/mm_types.h +4 -1
@@ -416,7 +416,10 @@ struct vm_area_struct {struct rb_node rb;unsigned long rb_subtree_last; } shared; -/* Serialized by mmap_sem. */ +/* +* Serialized by mmap_sem. Never use directly because it is +* valid only when vm_file is NULL. Use anon_vma_name instead. +*/ struct anon_vma_name *anon_name; };
kernel/fork.c +2 -2
@@ -366,14 +366,14 @@ struct vm_area_struct *vm_area_dup(struct vm_area_struct *orig) *new =data_race (*orig);INIT_LIST_HEAD (&new->anon_vma_chain); new->vm_next = new->vm_prev =NULL ; -dup_vma_anon_name (orig, new); +dup_anon_vma_name (orig, new); }return new; }void vm_area_free (struct vm_area_struct *vma) { -free_vma_anon_name (vma); +free_anon_vma_name (vma);kmem_cache_free (vm_area_cachep, vma); }
kernel/sys.c +12 -7
@@ -7,6 +7,7 @@#include <linux/export.h> #include <linux/mm.h> +#include <linux/mm_inline.h> #include <linux/utsname.h> #include <linux/mman.h> #include <linux/reboot.h>
@@ -2286,15 +2287,16 @@ static int prctl_set_vma(unsigned long opt, unsigned long addr, {struct mm_struct *mm = current->mm;const char __user *uname; -char *name, *pch; +struct anon_vma_name *anon_name =NULL ;int error;switch (opt) {case PR_SET_VMA_ANON_NAME : uname = (const char __user *)arg;if (uname) { - name =strndup_user (uname,ANON_VMA_NAME_MAX_LEN ); +char *name, *pch; + name =strndup_user (uname,ANON_VMA_NAME_MAX_LEN );if (IS_ERR (name))return PTR_ERR (name);
@@ -2304,15 +2306,18 @@ static int prctl_set_vma(unsigned long opt, unsigned long addr,return -EINVAL ; } } - }else { -/* Reset the name */ - name =NULL ; +/* anon_vma has its own copy */ + anon_name =anon_vma_name_alloc (name); +kfree (name); +if (!anon_name) +return -ENOMEM ; + }mmap_write_lock (mm); - error =madvise_set_anon_name (mm, addr, size, name); + error =madvise_set_anon_name (mm, addr, size, anon_name);mmap_write_unlock (mm); -kfree (name); +anon_vma_name_put (anon_name);break ;default : error = -EINVAL ;
mm/madvise.c +29 -58
176 lines not on this page · raw message
mm/mempolicy.c +1 -1
@@ -814,7 +814,7 @@ static int mbind_range(struct mm_struct *mm, unsigned long start, prev =vma_merge (mm, prev, vmstart, vmend, vma->vm_flags, vma->anon_vma, vma->vm_file, pgoff, new_pol, vma->vm_userfaultfd_ctx, -vma_anon_name (vma)); +anon_vma_name (vma));if (prev) { vma = prev; next = vma->vm_next;
mm/mlock.c +1 -1
@@ -512,7 +512,7 @@ static int mlock_fixup(struct vm_area_struct *vma, struct vm_area_struct **prev, pgoff = vma->vm_pgoff + ((start - vma->vm_start) >>PAGE_SHIFT ); *prev =vma_merge (mm, *prev, start, end, newflags, vma->anon_vma, vma->vm_file, pgoff,vma_policy (vma), - vma->vm_userfaultfd_ctx,vma_anon_name (vma)); + vma->vm_userfaultfd_ctx,anon_vma_name (vma));if (*prev) { vma = *prev; goto success;
mm/mmap.c +6 -6
@@ -1031,7 +1031,7 @@ int __vma_adjust(struct vm_area_struct *vma, unsigned long start,static inline int is_mergeable_vma (struct vm_area_struct *vma,struct file *file,unsigned long vm_flags,struct vm_userfaultfd_ctx vm_userfaultfd_ctx, -const char *anon_name) +struct anon_vma_name *anon_name) {/* * VM_SOFTDIRTY should not prevent from VMA merging, if we
@@ -1049,7 +1049,7 @@ static inline int is_mergeable_vma(struct vm_area_struct *vma,return 0 ;if (!is_mergeable_vm_userfaultfd_ctx (vma, vm_userfaultfd_ctx))return 0 ; -if (!is_same_vma_anon_name (vma, anon_name)) +if (!anon_vma_name_eq (anon_vma_name (vma), anon_name))return 0 ;return 1 ; }
@@ -1084,7 +1084,7 @@ can_vma_merge_before(struct vm_area_struct *vma, unsigned long vm_flags, struct anon_vma *anon_vma, struct file *file, pgoff_t vm_pgoff, struct vm_userfaultfd_ctx vm_userfaultfd_ctx, - const char *anon_name) + struct anon_vma_name *anon_name) { if (is_mergeable_vma(vma, file, vm_flags, vm_userfaultfd_ctx, anon_name) && is_mergeable_anon_vma(anon_vma, vma->anon_vma, vma)) {
@@ -1106,7 +1106,7 @@ can_vma_merge_after(struct vm_area_struct *vma, unsigned long vm_flags, struct anon_vma *anon_vma, struct file *file, pgoff_t vm_pgoff, struct vm_userfaultfd_ctx vm_userfaultfd_ctx, - const char *anon_name) + struct anon_vma_name *anon_name) { if (is_mergeable_vma(vma, file, vm_flags, vm_userfaultfd_ctx, anon_name) && is_mergeable_anon_vma(anon_vma, vma->anon_vma, vma)) {
@@ -1167,7 +1167,7 @@ struct vm_area_struct *vma_merge(struct mm_struct *mm, struct anon_vma *anon_vma, struct file *file, pgoff_t pgoff, struct mempolicy *policy, struct vm_userfaultfd_ctx vm_userfaultfd_ctx, - const char *anon_name) + struct anon_vma_name *anon_name) { pgoff_t pglen = (end - addr) >> PAGE_SHIFT;struct vm_area_struct *area, *next;
@@ -3255,7 +3255,7 @@ struct vm_area_struct *copy_vma(struct vm_area_struct **vmap,return NULL ;/* should never get here */ new_vma =vma_merge (mm, prev, addr, addr + len, vma->vm_flags, vma->anon_vma, vma->vm_file, pgoff,vma_policy (vma), - vma->vm_userfaultfd_ctx,vma_anon_name (vma)); + vma->vm_userfaultfd_ctx,anon_vma_name (vma));if (new_vma) {/* * Source vma may have been merged into new_vma
mm/mprotect.c +1 -1
@@ -464,7 +464,7 @@ mprotect_fixup(struct vm_area_struct *vma, struct vm_area_struct **pprev, pgoff = vma->vm_pgoff + ((start - vma->vm_start) >>PAGE_SHIFT ); *pprev =vma_merge (mm, *pprev, start, end, newflags, vma->anon_vma, vma->vm_file, pgoff,vma_policy (vma), - vma->vm_userfaultfd_ctx,vma_anon_name (vma)); + vma->vm_userfaultfd_ctx,anon_vma_name (vma));if (*pprev) { vma = *pprev;VM_WARN_ON ((vma->vm_flags ^ newflags) & ~VM_SOFTDIRTY );
Signature · 1 line
2.35.1.473.g83b2b277ed-goog
Suren Baghdasaryan
reviewerPATCH v5 3/3 mm: fix use-after-free when anon vma name is used after vma is freed
When adjacent vmas are being merged it can result in the vma that was originally passed to madvise_update_vma being destroyed. In the current implementation, the name parameter passed to madvise_update_vma points directly to vma->anon_name and it is used after the call to vma_merge. In the cases when vma_merge merges the original vma and destroys it, this will result in use-after-free bug as shown below:
madvise_vma_behavior(vma)
madvise_update_vma(vma, ..., anon_name == vma->anon_name)
vma_merge(vma)
__vma_adjust(vma) <-- merges vma with adjacent one
vm_area_free(vma) <-- frees the original vma
replace_vma_anon_name(anon_name) <-- UAF of vma->anon_name
Fix this by raising the name refcount and stabilizing it.
---
changes in v5:
- Updated description, per Michal Hocko
mm/madvise.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
mm/madvise.c +7 -1
@@ -131,6 +131,8 @@ static int replace_anon_vma_name(struct vm_area_struct *vma,/* * Update the vm_flags on region of a vma, splitting it or merging it as * necessary. Must be called with mmap_sem held for writing; +* Caller should ensure anon_name stability by raising its refcount even when +* anon_name belongs to a valid vma because this function might free that vma. */ static int madvise_update_vma(struct vm_area_struct *vma, struct vm_area_struct **prev, unsigned long start,
@@ -945,6 +947,7 @@ static int madvise_vma_behavior(struct vm_area_struct *vma, unsigned long behavior) {int error; +struct anon_vma_name *anon_name;unsigned long new_flags = vma->vm_flags;switch (behavior) {
@@ -1010,8 +1013,11 @@ static int madvise_vma_behavior(struct vm_area_struct *vma,break ; } + anon_name =anon_vma_name (vma); +anon_vma_name_get (anon_name); error =madvise_update_vma (vma, prev, start, end, new_flags, -anon_vma_name (vma)); + anon_name); +anon_vma_name_put (anon_name); out:/*
Signature · 1 line
2.35.1.473.g83b2b277ed-goog
Re: [PATCH v5 3/3] mm: fix use-after-free when anon vma name is used after vma is freed
Quoted 6 lines · Suren Baghdasaryan
When adjacent vmas are being merged it can result in the vma that was originally passed to
madvise_update_vmabeing destroyed. In the current implementation, the name parameter passed tomadvise_update_vmapoints directly tovma->anon_nameand it is used after the call tovma_merge. In the cases whenvma_mergemerges the original vma and destroys it, this will result in use-after-free bug as shown below:
Not that I want to nit pick on the wording here because destruction of the original vma will not result in UAF automatically. For that it would need to hold anon_vma_name with the last reference. So I would reformulate:
"In cases when vma_merge merges the original vma and destroys it, it might result in UAF. For that the original vma would have to hold the anon_vma_name with the last reference. The following vma would need to contain a different anon_vma_name object with the same string.
Quoted 7 lines
madvise_vma_behavior(vma)
madvise_update_vma(vma, ..., anon_name == vma->anon_name)
vma_merge(vma)
__vma_adjust(vma)<-- merges vma with adjacent one
vm_area_free(vma)<-- frees the original vma
replace_vma_anon_name(anon_name)<-- UAF ofvma->anon_name
Quoted 5 lines
Fix this by raising the name refcount and stabilizing it.
Fixes 9a10064f5625 ("mm: add a field to store names for private anonymous memory")Signed-off-by Suren Baghdasaryan <[email protected]>Reported-by [email protected]
Thanks!
Quoted 43 lines
---
changes in v5:
- Updated description, per Michal Hockomm/madvise.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)mm/madvise.c +7
-1@@ -131,6 +131,8 @@ static int replace_anon_vma_name(struct vm_area_struct *vma,/* * Update the vm_flags on region of a vma, splitting it or merging it as * necessary. Must be called with mmap_sem held for writing; +* Caller should ensure anon_name stability by raising its refcount even when +* anon_name belongs to a valid vma because this function might free that vma. */ static int madvise_update_vma(struct vm_area_struct *vma, struct vm_area_struct **prev, unsigned long start,@@ -945,6 +947,7 @@ static int madvise_vma_behavior(struct vm_area_struct *vma, unsigned long behavior) {int error; +struct anon_vma_name *anon_name;unsigned long new_flags = vma->vm_flags;switch (behavior) {@@ -1010,8 +1013,11 @@ static int madvise_vma_behavior(struct vm_area_struct *vma,break ; } + anon_name =anon_vma_name (vma); +anon_vma_name_get (anon_name); error =madvise_update_vma (vma, prev, start, end, new_flags, -anon_vma_name (vma)); + anon_name); +anon_vma_name_put (anon_name); out:/* Signature · 1 line
2.35.1.473.g83b2b277ed-goog
Signature · 2 lines
Michal Hocko SUSE Labs
Suren Baghdasaryan
reviewerPATCH v2 2/3 mm: prevent vm_area_struct::anon_name refcount saturation
In reply to Suren BaghdasaryanA deep process chain with many vmas could grow really high. With default sysctl_max_map_count (64k) and default pid_max (32k) the max number of vmas in the system is 2147450880 and the refcounter has headroom of 1073774592 before it reaches REFCOUNT_SATURATED (3221225472). Therefore it's unlikely that an anonymous name refcounter will overflow with these defaults. Currently the max for pid_max is PID_MAX_LIMIT (4194304) and for sysctl_max_map_count it's INT_MAX (2147483647). In this configuration anon_vma_name refcount overflow becomes theoretically possible (that still require heavy sharing of that anon_vma_name between processes).
kref refcounting interface used in anon_vma_name structure will detect a counter overflow when it reaches REFCOUNT_SATURATED value but will only generate a warning about broken refcounter. To ensure anon_vma_name refcount does not overflow, stop anon_vma_name sharing when the refcount reaches REFCOUNT_MAX (2147483647), which still leaves INT_MAX/2 (1073741823) values before the counter reaches REFCOUNT_SATURATED. This should provide enough headroom for raising the refcounts temporarily.
---
changes in v2:
- Updated description to include calculation details, per Michal Hocko
include/linux/mm_inline.h | 18 ++++++++++++++---- mm/madvise.c | 3 +-- 2 files changed, 15 insertions(+), 6 deletions(-)
include/linux/mm_inline.h +14 -4
@@ -161,15 +161,25 @@ static inline void anon_vma_name_put(struct anon_vma_name *anon_name)kref_put (&anon_name->kref, anon_vma_name_free); } +static inline +struct anon_vma_name *anon_vma_name_reuse (struct anon_vma_name *anon_name) +{ +/* Prevent anon_name refcount saturation early on */ +if (kref_read (&anon_name->kref) <REFCOUNT_MAX ) { +anon_vma_name_get (anon_name); +return anon_name; + + } +return anon_vma_name_alloc (anon_name->name); +} +static inline void dup_anon_vma_name (struct vm_area_struct *orig_vma,struct vm_area_struct *new_vma) {struct anon_vma_name *anon_name =anon_vma_name (orig_vma); -if (anon_name) { -anon_vma_name_get (anon_name); - new_vma->anon_name = anon_name; - } +if (anon_name) + new_vma->anon_name =anon_vma_name_reuse (anon_name); }static inline void free_anon_vma_name (struct vm_area_struct *vma)
mm/madvise.c +1 -2
@@ -113,8 +113,7 @@ static int replace_anon_vma_name(struct vm_area_struct *vma,if (anon_vma_name_eq (orig_name, anon_name))return 0 ; -anon_vma_name_get (anon_name); - vma->anon_name = anon_name; + vma->anon_name =anon_vma_name_reuse (anon_name);anon_vma_name_put (orig_name);return 0 ;
Signature · 1 line
2.35.1.473.g83b2b277ed-goog
Re: [PATCH v2 2/3] mm: prevent vm_area_struct::anon_name refcount saturation
Quoted 6 lines · Suren Baghdasaryan
A deep process chain with many vmas could grow really high. With default
sysctl_max_map_count(64k) and defaultpid_max(32k) the max number of vmas in the system is 2147450880 and the refcounter has headroom of 1073774592 before it reachesREFCOUNT_SATURATED(3221225472). Therefore it's unlikely that an anonymous name refcounter will overflow with these defaults.
Quoted 8 lines
Currently the max for
pid_maxisPID_MAX_LIMIT(4194304) and forsysctl_max_map_countit'sINT_MAX(2147483647). In this configurationanon_vma_namerefcount overflow becomes theoretically possible (that still require heavy sharing of thatanon_vma_namebetween processes).
kref refcounting interface used inanon_vma_namestructure will detect a counter overflow when it reachesREFCOUNT_SATURATEDvalue but will only generate a warning about broken refcounter.
If I am reading the refcounter code properly the "overflow" will simply make the ref counter frozen and the object will never be freed. A determined attacker could leak memory like that but it would be rather expensive and inefficient way to do so. Still good to have it covered.
Quoted 5 lines
To ensure
anon_vma_namerefcount does not overflow, stopanon_vma_namesharing when the refcount reachesREFCOUNT_MAX(2147483647), which still leaves INT_MAX/2 (1073741823) values before the counter reachesREFCOUNT_SATURATED. This should provide enough headroom for raising the refcounts temporarily.
I am not sure this is the intended way refcounter users should avoid overflows but I do not see other interface that would be usable. Maybe somebody else can come up with a better suggestion but this approach makes sense to me.
Quoted 3 lines
Suggested-by Michal Hocko <[email protected]>Signed-off-by Suren Baghdasaryan <[email protected]>
Thanks!
Quoted 58 lines
---
changes in v2:
- Updated description to include calculation details, per Michal Hockoinclude/linux/mm_inline.h | 18 ++++++++++++++---- mm/madvise.c | 3 +-- 2 files changed, 15 insertions(+), 6 deletions(-)include/linux/mm_inline.h +14
-4@@ -161,15 +161,25 @@ static inline void anon_vma_name_put(struct anon_vma_name *anon_name)kref_put (&anon_name->kref, anon_vma_name_free); } +static inline +struct anon_vma_name *anon_vma_name_reuse (struct anon_vma_name *anon_name) +{ +/* Prevent anon_name refcount saturation early on */ +if (kref_read (&anon_name->kref) <REFCOUNT_MAX ) { +anon_vma_name_get (anon_name); +return anon_name; + + } +return anon_vma_name_alloc (anon_name->name); +} +static inline void dup_anon_vma_name (struct vm_area_struct *orig_vma,struct vm_area_struct *new_vma) {struct anon_vma_name *anon_name =anon_vma_name (orig_vma); -if (anon_name) { -anon_vma_name_get (anon_name); - new_vma->anon_name = anon_name; - } +if (anon_name) + new_vma->anon_name =anon_vma_name_reuse (anon_name); }static inline void free_anon_vma_name (struct vm_area_struct *vma)mm/madvise.c +1
-2@@ -113,8 +113,7 @@ static int replace_anon_vma_name(struct vm_area_struct *vma,if (anon_vma_name_eq (orig_name, anon_name))return 0 ; -anon_vma_name_get (anon_name); - vma->anon_name = anon_name; + vma->anon_name =anon_vma_name_reuse (anon_name);anon_vma_name_put (orig_name);return 0 ;Signature · 1 line
2.35.1.473.g83b2b277ed-goog
Signature · 2 lines
Michal Hocko SUSE Labs
Quoted 8 lines · Suren Baghdasaryan
Avoid mixing strings and their
anon_vma_namereferenced pointers by using structanon_vma_namewhenever possible. This simplifies the code and allows easier sharing ofanon_vma_namestructures when they represent the same name.Suggested-by Matthew Wilcox <[email protected]>Suggested-by Michal Hocko <[email protected]>Signed-off-by Suren Baghdasaryan <[email protected]>
LGTM
Thanks and one minor nit below
[...]
include/linux/mm_inline.h static __always_inline void del_page_from_lru_list(struct page *page, · line 179
Quoted 6 lines
include/linux/mm_inline.h +4
-1+static inline void free_anon_vma_name (struct vm_area_struct *vma) { -const char *vma_name =vma_anon_name (vma); +/* +* Not using anon_vma_name because it generates a warning if vma->vm_mm +* is not held, which might be the case here.
s@vma->vm_mm@mmap_lock@
Quoted 7 lines
include/linux/mm_inline.h +4
-2+*/ +if (!vma->vm_file) +anon_vma_name_put (vma->anon_name); +} -/* either both NULL, or pointers to same string */ -if (vma_name == name)
Signature · 2 lines
Michal Hocko SUSE Labs
Suren Baghdasaryan
reviewerQuoted 7 lines · Michal Hocko
Quoted 5 lines · Suren Baghdasaryan
Avoid mixing strings and their
anon_vma_namereferenced pointers by using structanon_vma_namewhenever possible. This simplifies the code and allows easier sharing ofanon_vma_namestructures when they represent the same name.
Quoted 8 lines
Quoted 3 lines
Suggested-by Matthew Wilcox <[email protected]>Suggested-by Michal Hocko <[email protected]>Signed-off-by Suren Baghdasaryan <[email protected]>LGTM
Acked-by Michal Hocko <[email protected]>Thanks and one minor nit below
Addressed all the nits in the next version:
https://lore.kernel.org/all/[email protected]/
Thanks!
Quoted 22 lines
[...]
include/linux/mm_inline.h static __always_inline void del_page_from_lru_list(struct page *page, · line 179
Quoted 6 lines
include/linux/mm_inline.h +4
-1+static inline void free_anon_vma_name (struct vm_area_struct *vma) { -const char *vma_name =vma_anon_name (vma); +/* +* Not using anon_vma_name because it generates a warning if vma->vm_mm +* is not held, which might be the case here. s@vma->vm_mm@mmap_lock@
include/linux/mm_inline.h static __always_inline void del_page_from_lru_list(struct page *page, · line 169
Quoted 7 lines
include/linux/mm_inline.h +4
-2+*/ +if (!vma->vm_file) +anon_vma_name_put (vma->anon_name); +} -/* either both NULL, or pointers to same string */ -if (vma_name == name)--
Michal Hocko
SUSE Labs