Skip to contentSkip to conversation

PATCH [email protected] 1 participant 1 message May 24, 2005

Subsystems (2)
lore
Share & tools
lore
#0 lore raw
	by smtp.nexlab.net (Postfix) with ESMTP id 8F97FFB6E

	for <[email protected]>; Tue, 24 May 2005 10:01:44 +0200 (CEST)

Received: ([email protected]) by vger.kernel.org via listexpand

	id S261343AbVEXCtD (ORCPT <rfc822;[email protected]>);

	Mon, 23 May 2005 22:49:03 -0400

Received: ([email protected]) by vger.kernel.org id S261344AbVEXCtC

	(ORCPT <rfc822;linux-kernel-outgoing>);

	Mon, 23 May 2005 22:49:02 -0400

Received: from holomorphy.com ([66.93.40.71]:36253 "EHLO holomorphy.com")

	by vger.kernel.org with ESMTP id S261343AbVEXCsx (ORCPT

	<rfc822;[email protected]>);

	Mon, 23 May 2005 22:48:53 -0400

Received: from wli by holomorphy.com with local (Exim 3.36 #1 (Debian))

	id 1DaPTN-0001dX-00; Mon, 23 May 2005 19:48:49 -0700

Date: Mon, 23 May 2005 19:48:49 -0700

From: William Lee Irwin III <[email protected]>
To: Andrew Morton <[email protected]>
Cc: [email protected], [email protected],
Hugh Dickins <[email protected]>
Subject: Re: [bugfix] try_to_unmap_cluster() passes out-of-bounds pte to pte_unmap()

Message-ID: <[email protected]>

References: <[email protected]> <[email protected]> <[email protected]>

Mime-Version: 1.0

Content-Type: text/plain; charset=us-ascii

Content-Disposition: inline

In-Reply-To: <[email protected]>

Organization: The Domain of Holomorphy

User-Agent: Mutt/1.5.9i

Sender: [email protected]
Precedence: bulk

X-Mailing-List: [email protected]

Quoted 2 lines · William Lee Irwin III
Quoted 2 lines
mm/rmap.c renamed from mm/rmap.c.orig +0 -0

[...]

Quoted 8 lines · Andrew Morton

I must say that I continue to find this approach a bit queazifying. After some reading of the code I'd agree that yes, it's not possible for us to get here with `pte' pointing at the first slot of the pte page, but it's not 100% obvious and it's possible that someone will come along later and will change things in try_to_unmap_cluster() which cause this unmap to suddenly do the wrong thing in rare circumstances.
IOW: I'd sleep better at night if we took a temporary and actually unmapped the thing which we we got back from pte_offset_map().. Am I being silly?

Not at all. I merely attempt to minimize diffsize by default. An alternative implementation follows (changelog etc. to be taken from the prior patch) in case it saves the time (however short) needed to write it yourself.

-- wli

mm/rmap.c +3 -3
Index: mm2-2.6.12-rc4/mm/rmap.c
===================================================================
@@ -626,7 +626,7 @@
 	pgd_t *pgd;
 	pud_t *pud;
 	pmd_t *pmd;
-	pte_t *pte;
+	pte_t *pte, *original_pte;
 	pte_t pteval;
 	struct page *page;
 	unsigned long address;
@@ -658,7 +658,7 @@
 	if (!pmd_present(*pmd))
 		goto out_unlock;
 
-	for (pte = pte_offset_map(pmd, address);
+	for (original_pte = pte = pte_offset_map(pmd, address);
 			address < end; pte++, address += PAGE_SIZE) {
 
 		if (!pte_present(*pte))
@@ -694,7 +694,7 @@
 		(*mapcount)--;
 	}
 
-	pte_unmap(pte);
+	pte_unmap(original_pte);
 out_unlock:
 	spin_unlock(&mm->page_table_lock);
 }

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/