Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 43B4536F90C; Sat, 17 Oct 2026 17:44:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1792259097; cv=none; b=hRdvs3Q24cT89GnJ+iEg/jSRST2cRT+OSc1CmRy25cC3JsfHT5xEc1xwPMC6eKMmDODc5+tYzeYoH2jMjGDpKBs3TXTOS+a5u3YPhpe67/pmQuSMRxm2JLVgSiPqEQGHYYlrFkxrBpIJO2ipBRB7CFoDutUmVjy4LlybsQPli6E= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1792259097; c=relaxed/simple; bh=qCE2V8t9yTBas/Cy8bA8DDOIpS8i5Dq4aybnFXf8VHc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=WKqYEgdokZRgG0UC3uH9v8oF9ATfw/8qjd4N16xSmQzmB6u3yEN+EYm/eJz4kGyb86X6+rYoDi8IuI+zUOUMersHzKugSaMrLqcnnFksuBd/SS/zhfK4vwIbvVXBIxxGBvKqDw44jfWl7P4Vkc91m/3U8cq/G8uA+WiWBIXYkKU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=DdNY5R+j; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="DdNY5R+j" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9DB201F000C4; Sat, 17 Oct 2026 17:44:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1792259096; bh=5vRx2uKzdB5Rxch/+IQVJQKrrF3YhQ43aH9vR0ET70k=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=DdNY5R+jHi5LxiQFpiz2oe3XNp9XOyoY91NxNMjsgW6Hzbfe62apGS5uclCQod9kx GuJ1NlT4kkT2HDIHinoixIKsdUGdUjT3pWkSdxzOWC96HavArDZ1w69U6Gm3Hy5Hgt qidsvHECjeUYe2uhqrYtl0q8gfyRhTp6vq6db1Y8= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Sudeep Holla , Mostafa Saleh , Sebastian Ene , Marc Zyngier , Sasha Levin Subject: [PATCH 6.6 1099/1674] firmware: arm_ffa: Fix out-of-bound writes in ffa_setup_and_transmit() Date: Sat, 17 Oct 2026 17:56:11 +0200 Message-ID: <20261017160459.339253285@linuxfoundation.org> X-Mailer: git-send-email 2.56.0 In-Reply-To: <20261017160431.119607952@linuxfoundation.org> References: <20261017160431.119607952@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev 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: Mostafa Saleh [ Upstream commit 3383ffb7ef937317361713ffcc21921a7848511a ] Sashiko (locally) reports multiple out-of-bound issues in ffa_setup_and_transmit: 1) Writing ep_mem_access->reserved can write out of bounds for FFA versions < 1.2 as ffa_emad_size_get() returns 16 bytes in that case while reserved has an offset of 24. Instead of zeroing fields, memset the struct to zero first based on the FFA version. 2) Make sure there is enough size to write constituents. While at it, convert the only sizeof() in the driver that uses a type instead of variable. Reviewed-by: Sudeep Holla Fixes: 111a833dc5cb ("firmware: arm_ffa: Set reserved/MBZ fields to zero in the memory descriptors") Signed-off-by: Mostafa Saleh Signed-off-by: Sebastian Ene Link: https://patch.msgid.link/20260702103848.1647249-2-sebastianene@google.com Signed-off-by: Marc Zyngier Signed-off-by: Sasha Levin --- drivers/firmware/arm_ffa/driver.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/firmware/arm_ffa/driver.c b/drivers/firmware/arm_ffa/driver.c index 2309a31549e25..8d6217a6b6231 100644 --- a/drivers/firmware/arm_ffa/driver.c +++ b/drivers/firmware/arm_ffa/driver.c @@ -481,7 +481,7 @@ ffa_setup_and_transmit(u32 func_id, void *buffer, u32 max_fragsize, constituents = buffer; } - if ((void *)constituents - buffer > max_fragsize) { + if ((void *)constituents + sizeof(*constituents) - buffer > max_fragsize) { pr_err("Memory Region Fragment > Tx Buffer size\n"); return -EFAULT; } @@ -490,7 +490,7 @@ ffa_setup_and_transmit(u32 func_id, void *buffer, u32 max_fragsize, constituents->pg_cnt = args->sg->length / FFA_PAGE_SIZE; constituents->reserved = 0; constituents++; - frag_len += sizeof(struct ffa_mem_region_addr_range); + frag_len += sizeof(*constituents); } while ((args->sg = sg_next(args->sg))); return ffa_transmit_fragment(func_id, addr, buf_sz, frag_len, -- 2.53.0