lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Thu, 24 Nov 2011 10:04:09 +0100
From:	Johannes Weiner <hannes@...xchg.org>
To:	KAMEZAWA Hiroyuki <kamezawa.hiroyu@...fujitsu.com>
Cc:	Andrew Morton <akpm@...ux-foundation.org>,
	Michal Hocko <mhocko@...e.cz>,
	Balbir Singh <bsingharora@...il.com>, cgroups@...r.kernel.org,
	linux-mm@...ck.org, linux-kernel@...r.kernel.org
Subject: Re: [patch 5/8] mm: memcg: remove unneeded checks from
 newpage_charge()

On Thu, Nov 24, 2011 at 09:04:43AM +0900, KAMEZAWA Hiroyuki wrote:
> On Wed, 23 Nov 2011 16:42:28 +0100
> Johannes Weiner <hannes@...xchg.org> wrote:
> 
> > From: Johannes Weiner <jweiner@...hat.com>
> > 
> > All callsites pass in freshly allocated pages and a valid mm.  As a
> > result, all checks pertaining the page's mapcount, page->mapping or
> > the fallback to init_mm are unneeded.
> > 
> > Signed-off-by: Johannes Weiner <jweiner@...hat.com>
> 
> Hmm, it's true now. But for making clear our assumption to all readers of code,
> 
> could you add
> VM_BUG_ON(!mm || page_mapped(page) || (page->mapping && !PageAnon(page)) ?

Of course.  Please find the delta patch below.  I broke them up into
three separate checks to make the problem easier to find if the BUG
triggers.

> Acked-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@...fujitsu.com>

Thank you.

---
From: Johannes Weiner <jweiner@...hat.com>
Subject: mm: memcg: remove unneeded checks from newpage_charge() fix

Document page state assumptions and catch if they are violated in
newpage_charge().

Signed-off-by: Johannes Weiner <jweiner@...hat.com>
---
 mm/memcontrol.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index 0d10be4..f338018 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -2679,6 +2679,9 @@ int mem_cgroup_newpage_charge(struct page *page,
 {
 	if (mem_cgroup_disabled())
 		return 0;
+	VM_BUG_ON(page_mapped(page));
+	VM_BUG_ON(page->mapping && !PageAnon(page));
+	VM_BUG_ON(!mm);
 	return mem_cgroup_charge_common(page, mm, gfp_mask,
 					MEM_CGROUP_CHARGE_TYPE_MAPPED);
 }
-- 
1.7.6.4
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ