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 A36F831717D; Sat, 28 Feb 2026 17:43:01 +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=1772300581; cv=none; b=BycLEW7m2HBrkR9kOwYJeXi4N2cW2eM0nDMO7Ol667lcEb7y20tRcHcwwS/Q0EDBKH80CKE+Qa6BxrnWOzrpevL4NQnj3DrK2J4VzppqeqzOz8sci5cS2WgngIjwT93gXzqL/6H8H4wlbhjfgvMB2X3ASQPCyQrM3St4VR85/qM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772300581; c=relaxed/simple; bh=BmJESorZCNmwmXWKrpPOWGyF/Oq8LKKDxOzvYAgVGpQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=oFWq9qHIu+1TCS/nKbZ/j70EbbBGWu+r5m5Rr9NHNy0TDS4XSJ4svXxMalt0dyaSDGzvHQ7srTb6D2aJ3adTHtfZZy16r4NLp5W2RO7kEvHKBDZYoZDonnasdJbLZ1alpyLN+u5CzIag4Rpzu1f6zBYzoK46nuAv1akrDSFVQpc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=OE96oZuf; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="OE96oZuf" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9E230C116D0; Sat, 28 Feb 2026 17:43:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1772300581; bh=BmJESorZCNmwmXWKrpPOWGyF/Oq8LKKDxOzvYAgVGpQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OE96oZufj7DRIYbDjuiDVR4Rz7bF+MMgGuMFRMLWbfvoy3Rvhmlr1CtJJs6auVK7j OWhzwmbQk3Q4vk9+zertY/EQh0Ry2CbXtcEKfC3az+MqW8J/dTjGZoHn707A9Vmevy YyCuQG8a87FUDXU5knQrbYEYOKy5MSjuL4hEd+4ptA2RFGKZIsu4I4yCX8nkS6wEWK 1spPa/GRdv04OCfTzQrFgcxdMnWNRg/jZy6Ji71mCvUFbd1P9RMlw++tjzTjqYwU4q PSCBZRlHUK94mQ+7FfTlI6al0R93X6BmwgxA6PZiLEpRQW0obsDfIcWko7aMSCxmLd spRLRY43FGScw== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Joonwon Kang , Jassi Brar , Sasha Levin Subject: [PATCH 6.19 622/844] mailbox: Prevent out-of-bounds access in fw_mbox_index_xlate() Date: Sat, 28 Feb 2026 12:28:55 -0500 Message-ID: <20260228173244.1509663-623-sashal@kernel.org> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260228173244.1509663-1-sashal@kernel.org> References: <20260228173244.1509663-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit From: Joonwon Kang [ Upstream commit fcd7f96c783626c07ee3ed75fa3739a8a2052310 ] Although it is guided that `#mbox-cells` must be at least 1, there are many instances of `#mbox-cells = <0>;` in the device tree. If that is the case and the corresponding mailbox controller does not provide `fw_xlate` and of_xlate` function pointers, `fw_mbox_index_xlate()` will be used by default and out-of-bounds accesses could occur due to lack of bounds check in that function. Cc: stable@vger.kernel.org Signed-off-by: Joonwon Kang Signed-off-by: Jassi Brar Signed-off-by: Sasha Levin --- drivers/mailbox/mailbox.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/mailbox/mailbox.c b/drivers/mailbox/mailbox.c index 2acc6ec229a45..617ba505691d3 100644 --- a/drivers/mailbox/mailbox.c +++ b/drivers/mailbox/mailbox.c @@ -489,12 +489,10 @@ EXPORT_SYMBOL_GPL(mbox_free_channel); static struct mbox_chan *fw_mbox_index_xlate(struct mbox_controller *mbox, const struct fwnode_reference_args *sp) { - int ind = sp->args[0]; - - if (ind >= mbox->num_chans) + if (sp->nargs < 1 || sp->args[0] >= mbox->num_chans) return ERR_PTR(-EINVAL); - return &mbox->chans[ind]; + return &mbox->chans[sp->args[0]]; } /** -- 2.51.0