Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1946256AbXBCCiI (ORCPT ); Fri, 2 Feb 2007 21:38:08 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1946255AbXBCChz (ORCPT ); Fri, 2 Feb 2007 21:37:55 -0500 Received: from 216-99-217-87.dsl.aracnet.com ([216.99.217.87]:52885 "EHLO sous-sol.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1946259AbXBCCha (ORCPT ); Fri, 2 Feb 2007 21:37:30 -0500 Message-Id: <20070203023916.739906000@sous-sol.org> References: <20070203023504.435051000@sous-sol.org> User-Agent: quilt/0.45-1 Date: Fri, 02 Feb 2007 18:35:15 -0800 From: Chris Wright To: linux-kernel@vger.kernel.org, stable@kernel.org Cc: Justin Forbes , Zwane Mwaikambo , "Theodore Ts'o" , Randy Dunlap , Dave Jones , Chuck Wolber , Chris Wedgwood , Michael Krufky , torvalds@linux-foundation.org, akpm@linux-foundation.org, alan@lxorguk.ukuu.org.uk, Roland Dreier , "Michael S. Tsirkin" , openib-general@openib.org, Roland Dreier Subject: [patch 11/59] [stable] [PATCH] IB/mthca: Fix off-by-one in FMR handling on memfree Content-Disposition: inline; filename=ib-mthca-fix-off-by-one-in-fmr-handling-on-memfree.patch Sender: linux-kernel-owner@vger.kernel.org X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1730 Lines: 46 -stable review patch. If anyone has any objections, please let us know. ------------------ From: Michael S. Tsirkin mthca_table_find() will return the wrong address when the table entry being searched for is exactly at the beginning of a sglist entry (other than the first), because it uses >= when it should use >. Example: assume we have 2 entries in scatterlist, 4K each, offset is 4K. The current code will return first entry + 4K when we really want the second entry. In particular this means mapping an FMR on a memfree HCA may end up writing the page table into the wrong place, leading to memory corruption and also causing the HCA to use an incorrect address translation table. Signed-off-by: Michael S. Tsirkin Signed-off-by: Roland Dreier Signed-off-by: Chris Wright --- This is upstream, and fixes a data corruption/crash bug with storage over SRP. drivers/infiniband/hw/mthca/mthca_memfree.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- linux-2.6.19.2.orig/drivers/infiniband/hw/mthca/mthca_memfree.c +++ linux-2.6.19.2/drivers/infiniband/hw/mthca/mthca_memfree.c @@ -232,7 +232,7 @@ void *mthca_table_find(struct mthca_icm_ list_for_each_entry(chunk, &icm->chunk_list, list) { for (i = 0; i < chunk->npages; ++i) { - if (chunk->mem[i].length >= offset) { + if (chunk->mem[i].length > offset) { page = chunk->mem[i].page; goto out; } -- - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/