summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorDon Mullis <don.mullis@gmail.com>2010-09-30 15:15:32 -0700
committerLinus Torvalds <torvalds@linux-foundation.org>2010-10-01 10:50:58 -0700
commitf015ac3edd84ad72f88e08a4d83c56c360aae404 (patch)
tree87f88c4e502d69752776dd36451d0ece5416f9f1 /lib
parent982f7c2b2e6a28f8f266e075d92e19c0dd4c6e56 (diff)
downloadop-kernel-dev-f015ac3edd84ad72f88e08a4d83c56c360aae404.zip
op-kernel-dev-f015ac3edd84ad72f88e08a4d83c56c360aae404.tar.gz
lib/list_sort: do not pass bad pointers to cmp callback
If the original list is a POT in length, the first callback from line 73 will pass a==b both pointing to the original list_head. This is dangerous because the 'list_sort()' user can use 'container_of()' and accesses the "containing" object, which does not necessary exist for the list head. So the user can access RAM which does not belong to him. If this is a write access, we can end up with memory corruption. Signed-off-by: Don Mullis <don.mullis@gmail.com> Tested-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com> Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com> Cc: <stable@kernel.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'lib')
-rw-r--r--lib/list_sort.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/lib/list_sort.c b/lib/list_sort.c
index 4b5cb79..a7616fa 100644
--- a/lib/list_sort.c
+++ b/lib/list_sort.c
@@ -70,7 +70,7 @@ static void merge_and_restore_back_links(void *priv,
* element comparison is needed, so the client's cmp()
* routine can invoke cond_resched() periodically.
*/
- (*cmp)(priv, tail, tail);
+ (*cmp)(priv, tail->next, tail->next);
tail->next->prev = tail;
tail = tail->next;
OpenPOWER on IntegriCloud