From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id ACFACC4708E for ; Thu, 5 Jan 2023 20:24:02 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 559DA8E0003; Thu, 5 Jan 2023 15:24:02 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 5092C8E0001; Thu, 5 Jan 2023 15:24:02 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3D1348E0003; Thu, 5 Jan 2023 15:24:02 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 2E7258E0001 for ; Thu, 5 Jan 2023 15:24:02 -0500 (EST) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id F0CCA1404B9 for ; Thu, 5 Jan 2023 20:24:01 +0000 (UTC) X-FDA: 80321871882.29.C3A93CD Received: from ale.deltatee.com (ale.deltatee.com [204.191.154.188]) by imf06.hostedemail.com (Postfix) with ESMTP id EF97C180016 for ; Thu, 5 Jan 2023 20:23:57 +0000 (UTC) Authentication-Results: imf06.hostedemail.com; dkim=pass header.d=deltatee.com header.s=20200525 header.b=UguTRvNX; spf=pass (imf06.hostedemail.com: domain of logang@deltatee.com designates 204.191.154.188 as permitted sender) smtp.mailfrom=logang@deltatee.com; dmarc=pass (policy=none) header.from=deltatee.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1672950240; a=rsa-sha256; cv=none; b=6O3AzweC7Z7p5eW7BHy1L9QVmPg2tc+5GJbYsY/4/RWfRnCoI5rui4aE5t4LIz04VSvmdK ZiFgGlIWkWY1aDjpsqyzf0/D69t4ZKYnGYQaMidfQ0MCP3I6mkccRdS+vWtoG18azXwrnC IUm0dNbKtsEqCqRnMYumXgtke8fSr7s= ARC-Authentication-Results: i=1; imf06.hostedemail.com; dkim=pass header.d=deltatee.com header.s=20200525 header.b=UguTRvNX; spf=pass (imf06.hostedemail.com: domain of logang@deltatee.com designates 204.191.154.188 as permitted sender) smtp.mailfrom=logang@deltatee.com; dmarc=pass (policy=none) header.from=deltatee.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1672950240; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=AwykE9t8HX+ccqioZoqmMDcWX+0113uDvxTCtog81Go=; b=4zO5yFN2iQi64mvo44k9wBWl2OKGjvDpF6gMJq6aFJKoAYZMBoOmKlLesZN2nsYq3sx1RX aUpcaPPVEUcdSOIWO9kOq5U1ye2kQc6zYAUgiZHMCZwI0iwRT+o5Ju9mMzvNLwq27lM9I0 HND0TQZbBU9yjQ+jyENQItxN+IeSICw= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=deltatee.com; s=20200525; h=Subject:In-Reply-To:From:References:Cc:To: MIME-Version:Date:Message-ID:content-disposition; bh=AwykE9t8HX+ccqioZoqmMDcWX+0113uDvxTCtog81Go=; b=UguTRvNXENnlhVuV+CHKQ3KBf7 pqRNf6pmcyqhWx4Zy8Rc+0zeh8EJETQMs67dpbSR6dnOji4xjs/Q6gszpnSAgv9i0n7v/pRgFHtQt K1PyJ98q3eyNuDBriKer+LOhx2/Ff+ijOiv2rawPei1j8B+LATZ7ZGhsg5nn2xN72pL7i66ARYzbj 3GAyhGPS0ByzsF0OxReHVMr0WXj1OeGqiyb49FSaxN+Yu/FXvq3kFXeRv3REr2II/uTm2Z0FvyUsX Nxbj5mCw3z7bY+v5M9TGaY0iHcr0lfolMmFbPG5XB9Ba3umN8wR/JeNjZZXWqT18CEjCupbL1md93 Jnm9cfVA==; Received: from s0106a84e3fe8c3f3.cg.shawcable.net ([24.64.144.200] helo=[192.168.0.10]) by ale.deltatee.com with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1pDWmI-0085pV-7d; Thu, 05 Jan 2023 13:23:55 -0700 Message-ID: <81470f28-2bcf-b3cc-4824-6e45343dbd77@deltatee.com> Date: Thu, 5 Jan 2023 13:23:52 -0700 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.6.0 Content-Language: en-CA To: Jason Gunthorpe , Yishai Hadas Cc: linux-kernel@vger.kernel.org, linux-block@vger.kernel.org, linux-mm@kvack.org, axboe@kernel.dk, hch@lst.de, alex.williamson@redhat.com, leonro@nvidia.com, maorg@nvidia.com References: <20230105112339.107969-1-yishaih@nvidia.com> From: Logan Gunthorpe In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-SA-Exim-Connect-IP: 24.64.144.200 X-SA-Exim-Rcpt-To: jgg@nvidia.com, yishaih@nvidia.com, linux-kernel@vger.kernel.org, linux-block@vger.kernel.org, linux-mm@kvack.org, axboe@kernel.dk, hch@lst.de, alex.williamson@redhat.com, leonro@nvidia.com, maorg@nvidia.com X-SA-Exim-Mail-From: logang@deltatee.com Subject: Re: [PATCH] lib/scatterlist: Fix to merge contiguous pages into the last SG properly X-SA-Exim-Version: 4.2.1 (built Sat, 13 Feb 2021 17:57:42 +0000) X-SA-Exim-Scanned: Yes (on ale.deltatee.com) X-Rspam-User: X-Rspamd-Queue-Id: EF97C180016 X-Rspamd-Server: rspam01 X-Stat-Signature: ggptygbzih7tj1fp8jx91m8bsw9k5ynb X-HE-Tag: 1672950237-309062 X-HE-Meta: U2FsdGVkX1+SnqRM2Nexq3R4nRmHgKYEGbnnPjf3rIwdYePphybvkeY1N7Zp1d6yS4hYFfsGgTG/wXRP1tXl3N/gIc3Zwg38yrWe67/0bkTxH3xcKNLmoo9KurEfgZ1czOoJ5VJ6MJU4WsU/wAecAn4lUvYlHeb8g9kRjWjagArPWRbYVTru5/3KPDtMpYghg9vGWeRgFhM2F+VjspArTVUiPC90itTdm6zozrFO/ZItXKDmA7l9gOGuee9laRHlC5sHrMZG/UJ0VnglPo1//TPUx6pkUUoHVE1O7EBWokhIVTr/zZe8GPolUIrKvMb1i33XGaLG4e6pc3A01y9NK1MtSWM8zP5rByFEQGlZIA0ZfE7TyRIYoVJeKPYjoyEu0KNKxukTXHe3Rh+UEqcsAE+fTLHFFRSuotGluzKtsyqvJnt97nGteVYZc/zYLcuuXU0CFpDLo4XtXf9H2rifpTiphFFoeUCejHMe83aS0DD68mhlWWB0jdUtkXquxlvKB86nkDwvL1fPY6rjCOasXP1Im85L7xhRwUtd3lOY/YLGCTI+YoADibGw/7IBzmE6BjN5AKNEVkSw5y2po7BFQbgm4vd4lhrWrVeXKmDk3KmTK18KNePNJifTJ97/57O/A4PcyfFntGwpqKLGgi5hMwPs5GHDLFSucMhmd0/2EaVs/mNYNiZoyGZDXLZ851mrwzPB/Jio+ThC4OJZMQc1HyszeAS8JRO7kIThDzSDPXPJ/EeGuEh+Gg5CW8CcoaEQwOjY8DV28TOjXYYFbIQWH9OhGIteFHiGlPgEgghy2fD4n7cac6PygZ7fAl9a4vFZzU5dWh+C5HOIftplfWy41BdvM7rFazv2Mr1cTi6pMstVoU0yGl6FpP6l+kspPHjVwquFIzf4jjLToeJbxH9xKwQA7vleFWs7 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On 2023-01-05 13:06, Jason Gunthorpe wrote: > On Thu, Jan 05, 2023 at 01:23:39PM +0200, Yishai Hadas wrote: >> When sg_alloc_append_table_from_pages() calls to pages_are_mergeable() >> in its 'sgt_append->prv' flow to check whether it can merge contiguous >> pages into the last SG, it passes the page arguments in the wrong order. >> >> The first parameter should be the next candidate page to be merged to >> the last page and not the opposite. >> >> The current code leads to a corrupted SG which resulted in OOPs and >> unexpected errors when non-contiguous pages are merged wrongly. >> >> Fix to pass the page parameters in the right order. >> >> Fixes: 1567b49d1a40 ("lib/scatterlist: add check when merging zone device pages") >> Signed-off-by: Yishai Hadas >> --- >> lib/scatterlist.c | 2 +- >> 1 file changed, 1 insertion(+), 1 deletion(-) > > rdma is pretty much the only user of this API and this bug is causing > bad data corruption, so I'm going to take it to the rdma tree and send > it tomorrow. > > Which raises the question why the original patch was done at all, > nothing ever inputs pgmap pages into this function? It was done solely because you had suggested it was necessary. https://lore.kernel.org/all/20210929224653.GZ964074@nvidia.com/ Though when the patch was correct when I originally wrote it and it looks like I merged it poorly somewhere along the line (roughly v5 of the series) when the paddr stuff was added. Sorry about that. The paddr stuff was messy and really hard to understand. Anyway, Yishai's first patch looks correct to me, but I guess we need to fix it further. For what it's worth: Reviewed-by: Logan Gunthorpe Logan