* [PATCH] mm: Fix mem_cgroup_oom_disable() call missing
@ 2017-09-05 15:30 Laurent Dufour
2017-09-05 15:46 ` Kirill A. Shutemov
2017-09-05 16:43 ` Michal Hocko
0 siblings, 2 replies; 4+ messages in thread
From: Laurent Dufour @ 2017-09-05 15:30 UTC (permalink / raw)
To: linux-mm, akpm, kirill, linux-kernel
Seen while reading the code, in handle_mm_fault(), in the case
arch_vma_access_permitted() is failing the call to mem_cgroup_oom_disable()
is not made.
To fix that, move the call to mem_cgroup_oom_enable() after calling
arch_vma_access_permitted() as it should not have entered the memcg OOM.
Fixes: bae473a423f6 ("mm: introduce fault_env")
Signed-off-by: Laurent Dufour <ldufour@linux.vnet.ibm.com>
---
mm/memory.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/mm/memory.c b/mm/memory.c
index 56e48e4593cb..274547075486 100644
--- a/mm/memory.c
+++ b/mm/memory.c
@@ -3888,6 +3888,11 @@ int handle_mm_fault(struct vm_area_struct *vma, unsigned long address,
/* do counter updates before entering really critical section. */
check_sync_rss_stat(current);
+ if (!arch_vma_access_permitted(vma, flags & FAULT_FLAG_WRITE,
+ flags & FAULT_FLAG_INSTRUCTION,
+ flags & FAULT_FLAG_REMOTE))
+ return VM_FAULT_SIGSEGV;
+
/*
* Enable the memcg OOM handling for faults triggered in user
* space. Kernel faults are handled more gracefully.
@@ -3895,11 +3900,6 @@ int handle_mm_fault(struct vm_area_struct *vma, unsigned long address,
if (flags & FAULT_FLAG_USER)
mem_cgroup_oom_enable();
- if (!arch_vma_access_permitted(vma, flags & FAULT_FLAG_WRITE,
- flags & FAULT_FLAG_INSTRUCTION,
- flags & FAULT_FLAG_REMOTE))
- return VM_FAULT_SIGSEGV;
-
if (unlikely(is_vm_hugetlb_page(vma)))
ret = hugetlb_fault(vma->vm_mm, vma, address, flags);
else
--
2.7.4
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] mm: Fix mem_cgroup_oom_disable() call missing
2017-09-05 15:30 [PATCH] mm: Fix mem_cgroup_oom_disable() call missing Laurent Dufour
@ 2017-09-05 15:46 ` Kirill A. Shutemov
2017-09-05 15:54 ` Laurent Dufour
2017-09-05 16:43 ` Michal Hocko
1 sibling, 1 reply; 4+ messages in thread
From: Kirill A. Shutemov @ 2017-09-05 15:46 UTC (permalink / raw)
To: Laurent Dufour; +Cc: linux-mm, akpm, linux-kernel
On Tue, Sep 05, 2017 at 05:30:39PM +0200, Laurent Dufour wrote:
> Seen while reading the code, in handle_mm_fault(), in the case
> arch_vma_access_permitted() is failing the call to mem_cgroup_oom_disable()
> is not made.
>
> To fix that, move the call to mem_cgroup_oom_enable() after calling
> arch_vma_access_permitted() as it should not have entered the memcg OOM.
>
> Fixes: bae473a423f6 ("mm: introduce fault_env")
> Signed-off-by: Laurent Dufour <ldufour@linux.vnet.ibm.com>
Ouch. Sorry for this.
Acked-by: Kirill A. Shutemov <kirill@shutemov.name>
Cc: stable@ is needed too.
It's strange we haven't seen reports of warning from
mem_cgroup_oom_enable().
--
Kirill A. Shutemov
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] mm: Fix mem_cgroup_oom_disable() call missing
2017-09-05 15:46 ` Kirill A. Shutemov
@ 2017-09-05 15:54 ` Laurent Dufour
0 siblings, 0 replies; 4+ messages in thread
From: Laurent Dufour @ 2017-09-05 15:54 UTC (permalink / raw)
To: Kirill A. Shutemov, akpm; +Cc: linux-mm, linux-kernel
On 05/09/2017 17:46, Kirill A. Shutemov wrote:
> On Tue, Sep 05, 2017 at 05:30:39PM +0200, Laurent Dufour wrote:
>> Seen while reading the code, in handle_mm_fault(), in the case
>> arch_vma_access_permitted() is failing the call to mem_cgroup_oom_disable()
>> is not made.
>>
>> To fix that, move the call to mem_cgroup_oom_enable() after calling
>> arch_vma_access_permitted() as it should not have entered the memcg OOM.
>>
>> Fixes: bae473a423f6 ("mm: introduce fault_env")
>> Signed-off-by: Laurent Dufour <ldufour@linux.vnet.ibm.com>
>
> Ouch. Sorry for this.
>
> Acked-by: Kirill A. Shutemov <kirill@shutemov.name>
>
> Cc: stable@ is needed too.
Andrew, should I resent it with stable in copy ?
>
> It's strange we haven't seen reports of warning from
> mem_cgroup_oom_enable().
AFAIU, arch_vma_access_permitted() is only defined for x86 and it is
failing only in the case of the protection key mismatch, not so much used
for now...
Cheers,
Laurent.
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] mm: Fix mem_cgroup_oom_disable() call missing
2017-09-05 15:30 [PATCH] mm: Fix mem_cgroup_oom_disable() call missing Laurent Dufour
2017-09-05 15:46 ` Kirill A. Shutemov
@ 2017-09-05 16:43 ` Michal Hocko
1 sibling, 0 replies; 4+ messages in thread
From: Michal Hocko @ 2017-09-05 16:43 UTC (permalink / raw)
To: Laurent Dufour; +Cc: linux-mm, akpm, kirill, linux-kernel
On Tue 05-09-17 17:30:39, Laurent Dufour wrote:
> Seen while reading the code, in handle_mm_fault(), in the case
> arch_vma_access_permitted() is failing the call to mem_cgroup_oom_disable()
> is not made.
>
> To fix that, move the call to mem_cgroup_oom_enable() after calling
> arch_vma_access_permitted() as it should not have entered the memcg OOM.
>
> Fixes: bae473a423f6 ("mm: introduce fault_env")
> Signed-off-by: Laurent Dufour <ldufour@linux.vnet.ibm.com>
Acked-by: Michal Hocko <mhocko@suse.com>
> ---
> mm/memory.c | 10 +++++-----
> 1 file changed, 5 insertions(+), 5 deletions(-)
>
> diff --git a/mm/memory.c b/mm/memory.c
> index 56e48e4593cb..274547075486 100644
> --- a/mm/memory.c
> +++ b/mm/memory.c
> @@ -3888,6 +3888,11 @@ int handle_mm_fault(struct vm_area_struct *vma, unsigned long address,
> /* do counter updates before entering really critical section. */
> check_sync_rss_stat(current);
>
> + if (!arch_vma_access_permitted(vma, flags & FAULT_FLAG_WRITE,
> + flags & FAULT_FLAG_INSTRUCTION,
> + flags & FAULT_FLAG_REMOTE))
> + return VM_FAULT_SIGSEGV;
> +
> /*
> * Enable the memcg OOM handling for faults triggered in user
> * space. Kernel faults are handled more gracefully.
> @@ -3895,11 +3900,6 @@ int handle_mm_fault(struct vm_area_struct *vma, unsigned long address,
> if (flags & FAULT_FLAG_USER)
> mem_cgroup_oom_enable();
>
> - if (!arch_vma_access_permitted(vma, flags & FAULT_FLAG_WRITE,
> - flags & FAULT_FLAG_INSTRUCTION,
> - flags & FAULT_FLAG_REMOTE))
> - return VM_FAULT_SIGSEGV;
> -
> if (unlikely(is_vm_hugetlb_page(vma)))
> ret = hugetlb_fault(vma->vm_mm, vma, address, flags);
> else
> --
> 2.7.4
>
> --
> To unsubscribe, send a message with 'unsubscribe linux-mm' in
> the body to majordomo@kvack.org. For more info on Linux MM,
> see: http://www.linux-mm.org/ .
> Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
--
Michal Hocko
SUSE Labs
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2017-09-05 16:43 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-09-05 15:30 [PATCH] mm: Fix mem_cgroup_oom_disable() call missing Laurent Dufour
2017-09-05 15:46 ` Kirill A. Shutemov
2017-09-05 15:54 ` Laurent Dufour
2017-09-05 16:43 ` Michal Hocko
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).