From nobody Sun Apr 19 09:18:14 2026 Received: from mail-pl1-f201.google.com (mail-pl1-f201.google.com [209.85.214.201]) (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 0DDA834B1BE for ; Wed, 4 Mar 2026 07:35:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772609725; cv=none; b=VAUh7yEF5KRnVuC5DPOCRVGGdFECMNaMQ6vdJs3vaMjcgqZ/m78oo3tJccvo1637Uv7b5ACRmXrXkDG4SNVgO/M/SNulEkwtFy+UzHxs4nkvQS9mJCzyaOoHykhaDstCtqtj+e+ye+v4aKu6bsKrq6LzoLzuI/NLE4wya9O5cMM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772609725; c=relaxed/simple; bh=GUi9iRwTf4ZFEs3U2Iil4IHwEQGUGzOmPWn7Txv8Qyk=; h=Date:Mime-Version:Message-ID:Subject:From:To:Cc:Content-Type; b=V7D4TaYyKuSDCFAEXy6TMZEx0GUGoimwjropLtnLlTyPrajHJnODRfsNSuzT0ADV0GnOsn6CutEr4E/XZEpDnMyPQBWP7oHm6r6sJEtfweOPgt7Qc1u8zdrl6/NgFTl4iRGw4xwxJLyxVWHM46hnuYNWoREJRtfY+F6I2tEg/c4= 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=Yv9WFkCN; arc=none smtp.client-ip=209.85.214.201 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="Yv9WFkCN" Received: by mail-pl1-f201.google.com with SMTP id d9443c01a7336-2ae61939fa5so38644615ad.0 for ; Tue, 03 Mar 2026 23:35:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1772609723; x=1773214523; 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=Yv9WFkCNutY3a1JgOxAQT4JJipctmyOxq9zbJcKHsygTv/5lu5OPcuhkw0cP6toIJf HK2WQEdsz2rRU4Sph5sC2RfHiC7FZTmvRIrdPhSqU0l7vxRMCtluPOoybm286UU2zTq7 LazZA4Y9gTDqmiqZECd7U1mBHPEJTLqvMvQkCykrQbL56hfymURECsUp5zlVBidpSzZU ddlo/2eSp6rQyV6s72KOA+RhQi7B0Aqd7dyAOaJoz9K/F0CnGuJ9pa1sxs7qsyQSiwTM S2vYHj0qTmVGeBhoXxPwIshyVs+zvHwlu1EXW7kFWxU0zRWwP4XDi9a8+izNauCcZCb6 J7qg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1772609723; x=1773214523; 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=c2PuuF/IrcNX7DFQO9+MsgluqZ2u+Jkv7zK60N4Jm/NP7Q9zzvqSIbAH4M5o4+edPC I1hqcE9u85eNHutZ9Zpda6XTXY5O5P46inO2vh5U/GKxIOOP3UhPS6VPSe6cc1jxjqjw iTMubUa/m/2F/48vFdtkU5aFNTn37WqNDFuiNl5figGRWj6ss1F/4NNwOnSahFiKM8HZ 7X+/jFEaZlkYkvd/exGLwvfrOHSwCFKWa+pgG45INYugw3kwdnCAphv/ysqE6L2VbsfU vCiSeJG2INP4Frt2uTNV9VlkvDQjlCCO5UcFvV8G5/0vrIsOyQpYnAM2MVFNJCrNO/QO 55Wg== X-Gm-Message-State: AOJu0YwxmcEBj41Z6WVEiPBeyUBOvtgGPSEPlG8K+n5NfTaf1v+kr5so ezxmAHOyLD1nsdd7Q27W6hNv1XypH6mIxeNbsLatYM4csl4R5ZUolg1mZ3raoQXTUDhY5Qw37cw zFxjciL/oiaApfyK5fSjqA4hbhw== X-Received: from pgkk127.prod.google.com ([2002:a63:2485:0:b0:c65:e24e:cef1]) (user=joonwonkang job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6a21:608a:b0:392:e5ab:3125 with SMTP id adf61e73a8af0-3982e20233amr1243999637.66.1772609723317; Tue, 03 Mar 2026 23:35:23 -0800 (PST) Date: Wed, 4 Mar 2026 07:35:15 +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: <20260304073515.3227465-1-joonwonkang@google.com> Subject: [PATCH 6.1] 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