All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrea Arcangeli <aarcange@redhat.com>
To: akpm@linux-foundation.org
Cc: hugh@veritas.com, linux-kernel@vger.kernel.org,
	Izik Eidus <ieidus@redhat.com>,
	nickpiggin@yahoo.com.au, chrisw@redhat.com, linux-mm@kvack.org,
	riel@redhat.com
Subject: [PATCH] ksm: fix losing visibility of part of rmap_item->next list
Date: Wed, 3 Jun 2009 16:47:23 +0200	[thread overview]
Message-ID: <20090603144723.GC30426@random.random> (raw)
In-Reply-To: <20090603144552.GB30426@random.random>

From: Andrea Arcangeli <aarcange@redhat.com>

The tree_item->rmap_item is the head of the list and as such it must
not be overwritten except in the case that the element we removed
(rmap_item) was the previous head of the list, in which case it would
also have rmap_item->prev set to null.

Signed-off-by: Andrea Arcangeli <aarcange@redhat.com>
---

diff --git a/mm/ksm.c b/mm/ksm.c
index 74d921b..6d8dfee 100644
--- a/mm/ksm.c
+++ b/mm/ksm.c
@@ -397,10 +397,10 @@ static void remove_rmap_item_from_tree(struct rmap_item *rmap_item)
 				free_tree_item(tree_item);
 				nnodes_stable_tree--;
 			} else if (!rmap_item->prev) {
+				BUG_ON(tree_item->rmap_item != rmap_item);
 				tree_item->rmap_item = rmap_item->next;
-			} else {
-				tree_item->rmap_item = rmap_item->prev;
-			}
+			} else
+				BUG_ON(tree_item->rmap_item == rmap_item);
 		} else {
 			/*
 			 * We dont rb_erase(&tree_item->node) here, beacuse

WARNING: multiple messages have this Message-ID (diff)
From: Andrea Arcangeli <aarcange@redhat.com>
To: akpm@linux-foundation.org
Cc: hugh@veritas.com, linux-kernel@vger.kernel.org,
	Izik Eidus <ieidus@redhat.com>,
	nickpiggin@yahoo.com.au, chrisw@redhat.com, linux-mm@kvack.org,
	riel@redhat.com
Subject: [PATCH] ksm: fix losing visibility of part of rmap_item->next list
Date: Wed, 3 Jun 2009 16:47:23 +0200	[thread overview]
Message-ID: <20090603144723.GC30426@random.random> (raw)
In-Reply-To: <20090603144552.GB30426@random.random>

From: Andrea Arcangeli <aarcange@redhat.com>

The tree_item->rmap_item is the head of the list and as such it must
not be overwritten except in the case that the element we removed
(rmap_item) was the previous head of the list, in which case it would
also have rmap_item->prev set to null.

Signed-off-by: Andrea Arcangeli <aarcange@redhat.com>
---

diff --git a/mm/ksm.c b/mm/ksm.c
index 74d921b..6d8dfee 100644
--- a/mm/ksm.c
+++ b/mm/ksm.c
@@ -397,10 +397,10 @@ static void remove_rmap_item_from_tree(struct rmap_item *rmap_item)
 				free_tree_item(tree_item);
 				nnodes_stable_tree--;
 			} else if (!rmap_item->prev) {
+				BUG_ON(tree_item->rmap_item != rmap_item);
 				tree_item->rmap_item = rmap_item->next;
-			} else {
-				tree_item->rmap_item = rmap_item->prev;
-			}
+			} else
+				BUG_ON(tree_item->rmap_item == rmap_item);
 		} else {
 			/*
 			 * We dont rb_erase(&tree_item->node) here, beacuse

--
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>

  reply	other threads:[~2009-06-03 15:07 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-06-03 14:45 [PATCH] ksm: fix rmap_item use after free Andrea Arcangeli
2009-06-03 14:45 ` Andrea Arcangeli
2009-06-03 14:47 ` Andrea Arcangeli [this message]
2009-06-03 14:47   ` [PATCH] ksm: fix losing visibility of part of rmap_item->next list Andrea Arcangeli

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20090603144723.GC30426@random.random \
    --to=aarcange@redhat.com \
    --cc=akpm@linux-foundation.org \
    --cc=chrisw@redhat.com \
    --cc=hugh@veritas.com \
    --cc=ieidus@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=nickpiggin@yahoo.com.au \
    --cc=riel@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.