Received: by 2002:a05:6500:1b8f:b0:1fa:5c73:8e2d with SMTP id df15csp898026lqb; Wed, 29 May 2024 14:04:43 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWhciglX1bbFzlS1x0SLdN+RQLbeUpqKPzI8dYb0ROcYeK6k4n1/qQY9kRpwV9Ase4WbIjLI21H1etVMNYbYJdBahSnd7inLbEvzSDdXg== X-Google-Smtp-Source: AGHT+IFcfr+LvgBDhmsDbtY/Ygbqrml2Uv55RW1Nm/FE6mDn00kN5zc+PtYpIhNu5umCw4vXWrAq X-Received: by 2002:a05:6512:2087:b0:523:99a4:a187 with SMTP id 2adb3069b0e04-52b7d426a9bmr183386e87.26.1717016683776; Wed, 29 May 2024 14:04:43 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717016683; cv=pass; d=google.com; s=arc-20160816; b=ETTajxwIB4pSSTipAj4mqcQI1sojqzld6aKnljGmhdc9orN/cf6jYxyMqw1ASIb1hC nbtcw+NK3lGJmAz9f8IETBTJeeLkJ1k6JQT1mnuKXYOGbD05ufhxP89K3TcvzDE0sdps BQE6ylUfqlKz06yE7f8s9hS5iEdKPHqLwEH/IYPLeE4ddabYVEIeBJZbNZtF7L4YvYDP 2t4+isTiDbdmlBARBQR3Fobd18buCVvsVAgb1ZQu5fVTLt/gf7vdi0XeorNdcd83bFZH acPYve+d/WIWkbZLnOKPXAEjhZtAHnsv716b464qUET7Ww+jg3wSzVy7yff8u8rJbB7n 4Pgw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :references:message-id:subject:cc:to:date:from; bh=P+puNQWIhN3C+GqdmA2e10/IperNv47bc7wOwHkEilU=; fh=9Orwu7NMwwaStR27Fuj1R2+KYre4R4kUvl7P7jjojq8=; b=zfLB5Brl2ESExPZ9PYJyMuarBasKOYOclmOkignRIQRIn7IgMwan+CfoahYvGnSFHl 8vrFCQFJtwiQ4OoXGeFYqz2zGzaQesanFCCyyv56AHtxhC+Coh/RJzZapGWIOGSflkIB PkCEHYqg7zEzTPZAVv/5b5RQ27/pTLHZf8603psP++OSFHfhGNOHVQgI/R1rrPbTTuwY zAd2SNufa2OqwgQAkVTjhk2KR3pXiUWR4o0UsTwReOuZ1W9Xw69Lqr2U+hRvdKFYJYrS 6XoWlOJaxYpnyY9Z/h34pUxx1sZyfwkqHYrwHPS2DOoOYaWQcnGwEvIHJtanR6+8s4/c oyFQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel+bounces-194691-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-194691-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id a640c23a62f3a-a626cdd072dsi660047166b.922.2024.05.29.14.04.43 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 May 2024 14:04:43 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-194691-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel+bounces-194691-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-194691-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 680311F244D3 for ; Wed, 29 May 2024 21:04:43 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3722D1C8FCE; Wed, 29 May 2024 21:04:35 +0000 (UTC) Received: from fgw20-7.mail.saunalahti.fi (fgw20-7.mail.saunalahti.fi [62.142.5.81]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4244D1C8FBB for ; Wed, 29 May 2024 21:04:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=62.142.5.81 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717016674; cv=none; b=mWXGry5f9+khZbXTSlsruHKpuL/j4OvtNY1NpBTRpQpq1OxAUmJgIcdUIqvfsFemAkxRCNX1XtgNXAPT4fv1i/FGWPLY0J2AS4enTyC5DTHHj+ZE4FaYmsHTOpkb+W0QA66Rph4Rl7lsmF8/QvgFFGUhIxxhWsFGiY3smhYS8fo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717016674; c=relaxed/simple; bh=QGN6nTaLRATuAanyY2JWCC/5zV4E2mNZXxlfOcaB6dE=; h=From:Date:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=CjsuRhGEiZ9uz8+w6Q5tGpmNFEW3k9bIgwFVCteEvnBpBiLjCTFbE3Hw9NbxaEl7CwQhvqNbInEhcNbl5kPwDtc4/79oESMqNqRqhnKl9th5VkCY7Qxxx/bMBsIaEcwkcF0fY5qyQy+VOQdrmhB3nF6NveDShKuaIsuejXObn1k= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com; spf=fail smtp.mailfrom=gmail.com; arc=none smtp.client-ip=62.142.5.81 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=gmail.com Received: from localhost (88-113-26-230.elisa-laajakaista.fi [88.113.26.230]) by fgw22.mail.saunalahti.fi (Halon) with ESMTP id 0a7d1c25-1dff-11ef-8e2d-005056bdf889; Thu, 30 May 2024 00:04:30 +0300 (EEST) From: Andy Shevchenko Date: Thu, 30 May 2024 00:04:30 +0300 To: =?iso-8859-1?Q?N=EDcolas_F=2E_R=2E_A=2E?= Prado Cc: Mark Brown , Andy Shevchenko , Neil Armstrong , kernel@collabora.com, linux-spi@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] spi: Assign dummy scatterlist to unidirectional transfers Message-ID: References: <20240529-dma-oops-dummy-v1-1-bb43aacfb11b@collabora.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20240529-dma-oops-dummy-v1-1-bb43aacfb11b@collabora.com> Wed, May 29, 2024 at 11:42:35AM -0400, N?colas F. R. A. Prado kirjoitti: > From: Andy Shevchenko > > Commit 8cc3bad9d9d6 ("spi: Remove unneded check for orig_nents") > introduced a regression: unmapped data could now be passed to the DMA > APIs, resulting in null pointer dereferences. Commit 9f788ba457b4 ("spi: > Don't mark message DMA mapped when no transfer in it is") and commit > da560097c056 ("spi: Check if transfer is mapped before calling DMA sync > APIs") addressed the problem, but only partially. Unidirectional > transactions will still result in null pointer dereference. To prevent > that from happening, assign a dummy scatterlist when no data is mapped, > so that the DMA API can be called and not result in a null pointer > dereference. I feel that with this the da560097c056 ("spi: Check if transfer is mapped before calling DMA sync APIs") can be reverted as unneeded. N?colas, can you check that? If it works, we better revert the unneeded checks. -- With Best Regards, Andy Shevchenko