From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 81C7F26F292; Tue, 21 Oct 2025 19:55:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1761076533; cv=none; b=EFhSYiNrsx/ZjeGQhld+O8JmCaC4zyqGrlU6V1K/LIS7Qk96+Pr2MTw3k3TWnrbOhqCppkyyawNVYJa4fhAcPwbxACYV8t0QW4rI44rKW4/NZexA/UYjaK6HTVm+WUujF4egEfxbBEPzZkS4GmVbRtIP5YfW7Z/DDVfKDf+03Qs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1761076533; c=relaxed/simple; bh=Q8+d9nzzCOa1zHnanRVDVB3a0X97Aqux6VPILTyPB2g=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=nxo2XqsV45BV0M6zdParjB4WoiptTI52aZu0HF3YPuncstxGLwPEmgnM/jEo4V8PTv/WOclo88Idhn5THiM2NTU4ovPISpcCZB3oOz9p72UVbXTRaF7IJ7SUVERGTGSB51aLOvaM31HRWUs1/INZ/zlML5NosQitCysnK5s4JW8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=VZ+Xcge9; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="VZ+Xcge9" Received: by smtp.kernel.org (Postfix) with ESMTPSA id B5121C4CEF1; Tue, 21 Oct 2025 19:55:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1761076533; bh=Q8+d9nzzCOa1zHnanRVDVB3a0X97Aqux6VPILTyPB2g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VZ+Xcge9kOGsstOxA2zuL3lkh0WpcRF2wm48Cse+gpP8/V8ho4lNfgD3SB0eEbLwu dHN4YZ/jXakCKIGVbLK9yzhZZTpOWTHtYE/Je5SuzkgSA0u+LU3vCHJrZUdROKDdMz M/AbSkQB/2Ncq+3D/rxdbyxrFdRt71arJfGWrK9M= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Youssef Samir , Youssef Samir , Jeff Hugo , Carl Vanderlip , Sasha Levin Subject: [PATCH 6.6 065/105] accel/qaic: Treat remaining == 0 as error in find_and_map_user_pages() Date: Tue, 21 Oct 2025 21:51:14 +0200 Message-ID: <20251021195023.211289832@linuxfoundation.org> X-Mailer: git-send-email 2.51.1 In-Reply-To: <20251021195021.492915002@linuxfoundation.org> References: <20251021195021.492915002@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.6-stable review patch. If anyone has any objections, please let me know. ------------------ From: Youssef Samir [ Upstream commit 11f08c30a3e4157305ba692f1d44cca5fc9a8fca ] Currently, if find_and_map_user_pages() takes a DMA xfer request from the user with a length field set to 0, or in a rare case, the host receives QAIC_TRANS_DMA_XFER_CONT from the device where resources->xferred_dma_size is equal to the requested transaction size, the function will return 0 before allocating an sgt or setting the fields of the dma_xfer struct. In that case, encode_addr_size_pairs() will try to access the sgt which will lead to a general protection fault. Return an EINVAL in case the user provides a zero-sized ALP, or the device requests continuation after all of the bytes have been transferred. Fixes: 96d3c1cadedb ("accel/qaic: Clean up integer overflow checking in map_user_pages()") Signed-off-by: Youssef Samir Signed-off-by: Youssef Samir Reviewed-by: Jeff Hugo Reviewed-by: Carl Vanderlip Signed-off-by: Jeff Hugo Link: https://lore.kernel.org/r/20251007122320.339654-1-youssef.abdulrahman@oss.qualcomm.com Signed-off-by: Sasha Levin --- drivers/accel/qaic/qaic_control.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/accel/qaic/qaic_control.c b/drivers/accel/qaic/qaic_control.c index f3db3fa91dd52..08b78f5678532 100644 --- a/drivers/accel/qaic/qaic_control.c +++ b/drivers/accel/qaic/qaic_control.c @@ -407,7 +407,7 @@ static int find_and_map_user_pages(struct qaic_device *qdev, return -EINVAL; remaining = in_trans->size - resources->xferred_dma_size; if (remaining == 0) - return 0; + return -EINVAL; if (check_add_overflow(xfer_start_addr, remaining, &end)) return -EINVAL; -- 2.51.0