From nobody Wed Apr 15 13:17:36 2026 Received: from mail-pj1-f74.google.com (mail-pj1-f74.google.com [209.85.216.74]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 172C834D3B8 for ; Wed, 4 Mar 2026 07:30:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.74 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772609458; cv=none; b=fwbPXb1kaXu4KaQC/6MDXLNHoYZ8beUerM+bybmmVH0CtL4sotFEvsLbWN0jTkqlXor9FbRqfHSNRjw65hCaR+1UAmxft32uAhlOOOs42aW/ofQ0WtkcTCoEQrqhWWlbK4DNWiolb8GVXdbWsZMs1Uh76lAmnm1JU8NtT1FB/ic= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772609458; c=relaxed/simple; bh=GUi9iRwTf4ZFEs3U2Iil4IHwEQGUGzOmPWn7Txv8Qyk=; h=Date:Mime-Version:Message-ID:Subject:From:To:Cc:Content-Type; b=tpUxMqSkuIGNry4LU0mPo7GqXLSdeveeAQkzQFY6nF0SIPz1js/sy/WeE44RRfHIvquZwqwsyP/T2FkzFzNNdscLlHV1Rqo+gsihU38m4K/gZQNeb2omzVJpiQiPYpXKPfPbHCbUvIdo5IUFDbbVi6m7V34FDcqUW+WXMmqC5YQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--joonwonkang.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=xKahmvAG; arc=none smtp.client-ip=209.85.216.74 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--joonwonkang.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="xKahmvAG" Received: by mail-pj1-f74.google.com with SMTP id 98e67ed59e1d1-358e95e81aeso30837387a91.0 for ; Tue, 03 Mar 2026 23:30:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1772609456; x=1773214256; darn=vger.kernel.org; h=cc:to:from:subject:message-id:mime-version:date:from:to:cc:subject :date:message-id:reply-to; bh=yrFMT0TXW/spEw/ZubXnVYULM8dGErCPWbCJGWKhVQg=; b=xKahmvAGyNTXyHgI2vsz40J8FX+CJFNp75lrQarGODGiMRFPym9S0tnYQT/6ge7Bb9 QuDqR7BCJLYtolVg/qyl4SIO8LO7Pl31jaLSQPwKasg3/x9mAfumjw5SQdxyktzgTmgQ 3C1ZvMkjuvgLHnU5JTayw+m8/y/oaML4FKJn8vRVxpgYwBkOQFHqcptTBtMscIwsXE0S qU963HYxdQWJxoJhi+HWFJ9k/tp3QgRELlzsZU8rI7G75zHPI3+apFrfy6Sln67YPrKX Z+jl/QUp+fZQmlL+T43W2JVwqdeszxn/bzpUD4Fhgw3dPNL8mCQnuKAr0SSsxRm/Hujg q5/Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1772609456; x=1773214256; h=cc:to:from:subject:message-id:mime-version:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=yrFMT0TXW/spEw/ZubXnVYULM8dGErCPWbCJGWKhVQg=; b=uP5Rf7nli2KyWSbmnhgtxSpEhiYmasD490pe7Jk+SczzJF+Ztj8zfEGoTMDzbcGZIL yMeb7+Zj3h0+P7rMX2oGye4LLqENQDX22gwTXFWYBC3TS3Y3ais/D35AhauZRdxEk4Kb ZTspj6xiZwSXUwPwwxfjco+FX71+jYW9JMSu4v/BY2wErBBadrPMZ/CtEyMAA/clM70L cvPfvg7L8Ahek5EmbBEgVuiK7+WagNMeu3XUBjGkV7z7CiBwuUmTDCgbwhP58VTYXd1a dWLlDuZ/gh/nfoX681YXRSE7AKK5kb9vwM64YhxpVZvKzBG235cDeX3UuDbljSd1c0eb GwQg== X-Gm-Message-State: AOJu0Yyy3AgAJYs7yn/h8pwEOS+cqShDaI85+tU1Ai9tjK+76AY3zpLS wce1ryFgcL1umIXatfOs9ssG3DW6R8gDrU7fArd+8t1lhSWu+Dg7xaWwJn4g/OUTa/X5nL3ebJb kXP3zLwIPGkn01tjo6HhuR5BVRg== X-Received: from pjbx93.prod.google.com ([2002:a17:90a:38e6:b0:359:8242:e73d]) (user=joonwonkang job=prod-delivery.src-stubby-dispatcher) by 2002:a17:90b:3952:b0:339:ec9c:b275 with SMTP id 98e67ed59e1d1-359a69aec32mr1270980a91.6.1772609456213; Tue, 03 Mar 2026 23:30:56 -0800 (PST) Date: Wed, 4 Mar 2026 07:30:52 +0000 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 X-Mailer: git-send-email 2.53.0.473.g4a7958ca14-goog Message-ID: <20260304073052.3224244-1-joonwonkang@google.com> Subject: [PATCH] mailbox: Prevent out-of-bounds access in of_mbox_index_xlate() From: Joonwon Kang To: stable@vger.kernel.org, jassisinghbrar@gmail.com Cc: linux-kernel@vger.kernel.org, sashal@kernel.org, Joonwon Kang Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" [ Upstream commit fcd7f96c783626c07ee3ed75fa3739a8a2052310 ] Although it is guided that `#mbox-cells` must be at least 1, there are many instances of `#mbox-cells =3D <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, `of_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 [ changed sp->nargs to sp->args_count in the code and fw_mbox_index_xlate() to of_mbox_index_xlate() in the commit message. ] Signed-off-by: Joonwon Kang --- 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 d3d26a2c9895..66cdadbd3d75 100644 --- a/drivers/mailbox/mailbox.c +++ b/drivers/mailbox/mailbox.c @@ -498,12 +498,10 @@ static struct mbox_chan * of_mbox_index_xlate(struct mbox_controller *mbox, const struct of_phandle_args *sp) { - int ind =3D sp->args[0]; - - if (ind >=3D mbox->num_chans) + if (sp->args_count < 1 || sp->args[0] >=3D mbox->num_chans) return ERR_PTR(-EINVAL); =20 - return &mbox->chans[ind]; + return &mbox->chans[sp->args[0]]; } =20 /** --=20 2.53.0.473.g4a7958ca14-goog