mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Hyunjung Ko <hj351016@gmail.com>
To: Madhavan Srinivasan <maddy@linux.ibm.com>
Cc: Michael Ellerman <mpe@ellerman.id.au>,
	Nicholas Piggin <npiggin@gmail.com>,
	Ritesh Harjani <ritesh.list@gmail.com>,
	linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org,
	stable@vger.kernel.org, Hyunjung Ko <hj351016@gmail.com>
Subject: [PATCH] powerpc/papr_scm: initialise metadata_size before reading it
Date: Thu, 19 Nov 2026 12:47:45 +0900	[thread overview]
Message-ID: <20261119034745.1460361-1-hj351016@gmail.com> (raw)

papr_scm_probe() reads "ibm,metadata-size" into metadata_size without
checking the return value, and the property is optional, as the comment
right above the call says.  of_property_read_u32() only writes the output
when it can decode a value, so for a device tree without that property
p->metadata_size is set from an uninitialised stack value.

p->metadata_size is the bound for the metadata get/set commands:

	if ((hdr->in_offset + hdr->in_length) > p->metadata_size)

so a garbage value decides which metadata accesses are accepted.
Initialise it to zero, which makes those commands reject every access
when the platform does not advertise a metadata area.

Signed-off-by: Hyunjung Ko <hj351016@gmail.com>
Cc: stable@vger.kernel.org
---
 arch/powerpc/platforms/pseries/papr_scm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/powerpc/platforms/pseries/papr_scm.c b/arch/powerpc/platforms/pseries/papr_scm.c
index 5c3bf06bb59b..e9895e9b070c 100644
--- a/arch/powerpc/platforms/pseries/papr_scm.c
+++ b/arch/powerpc/platforms/pseries/papr_scm.c
@@ -1361,7 +1361,7 @@ static struct notifier_block mce_ue_nb =
 static int papr_scm_probe(struct platform_device *pdev)
 {
 	struct device_node *dn = pdev->dev.of_node;
-	u32 drc_index, metadata_size;
+	u32 drc_index, metadata_size = 0;
 	u64 blocks, block_size;
 	struct papr_scm_priv *p;
 	u8 uuid_raw[UUID_SIZE];
-- 
2.51.0


                 reply	other threads:[~2026-11-19  3:48 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261119034745.1460361-1-hj351016@gmail.com \
    --to=hj351016@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=maddy@linux.ibm.com \
    --cc=mpe@ellerman.id.au \
    --cc=npiggin@gmail.com \
    --cc=ritesh.list@gmail.com \
    --cc=stable@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®