mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Michal Simek <michal.simek@amd.com>
To: <linux-kernel@vger.kernel.org>, <monstr@monstr.eu>,
	<michal.simek@amd.com>, <git@amd.com>
Cc: Jay Buddhabhatti <jay.buddhabhatti@amd.com>,
	Jolly Shah <jollys@xilinx.com>, Rajan Vaja <rajanv@xilinx.com>,
	"moderated list:ARM/ZYNQ ARCHITECTURE"
	<linux-arm-kernel@lists.infradead.org>
Subject: [PATCH 6/6] firmware: xilinx: Bound debugfs clock name formatting
Date: Thu, 19 Nov 2026 14:17:30 +0100	[thread overview]
Message-ID: <c2dcbb74fa6ad3c716daa747c024fb73e5f5109b.1795094242.git.michal.simek@amd.com> (raw)
In-Reply-To: <cover.1795094242.git.michal.simek@amd.com>

From: Jay Buddhabhatti <jay.buddhabhatti@amd.com>

PM_QID_CLOCK_GET_NAME returns up to 16 name bytes with no guaranteed NUL
terminator. Copy the response into a bounded local buffer before formatting
to prevent kernel stack data from leaking via debugfs.

Fixes: e60f02ddb4d2 ("firmware: xilinx: Add debugfs for query data API")
Signed-off-by: Jay Buddhabhatti <jay.buddhabhatti@amd.com>
Signed-off-by: Michal Simek <michal.simek@amd.com>
---

 drivers/firmware/xilinx/zynqmp-debug.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/drivers/firmware/xilinx/zynqmp-debug.c b/drivers/firmware/xilinx/zynqmp-debug.c
index f7751912d80a..77b35a525b96 100644
--- a/drivers/firmware/xilinx/zynqmp-debug.c
+++ b/drivers/firmware/xilinx/zynqmp-debug.c
@@ -21,6 +21,7 @@
 #include "zynqmp-debug.h"
 
 #define PM_API_NAME_LEN			50
+#define CLK_GET_NAME_RESP_LEN		16
 
 struct pm_api_info {
 	u32 api_id;
@@ -279,10 +280,14 @@ static int process_api_request(u32 pm_id, u64 *pm_api_arg, u32 *pm_api_ret)
 			break;
 
 		switch (qdata.qid) {
-		case PM_QID_CLOCK_GET_NAME:
-			sprintf(debugfs_buf, "Clock name = %s\n",
-				(char *)pm_api_ret);
+		case PM_QID_CLOCK_GET_NAME: {
+			char name[CLK_GET_NAME_RESP_LEN + 1];
+
+			memcpy(name, pm_api_ret, CLK_GET_NAME_RESP_LEN);
+			name[CLK_GET_NAME_RESP_LEN] = '\0';
+			sprintf(debugfs_buf, "Clock name = %s\n", name);
 			break;
+		}
 		case PM_QID_CLOCK_GET_FIXEDFACTOR_PARAMS:
 			sprintf(debugfs_buf, "Multiplier = %d, Divider = %d\n",
 				pm_api_ret[1], pm_api_ret[2]);
-- 
2.43.0


      parent reply	other threads:[~2026-11-19 13:18 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-19 13:17 [PATCH 0/6] firmware: xilinx: cleanups and debugfs fixes Michal Simek
2026-11-19 13:17 ` [PATCH 1/6] firmware: xilinx: Use late_initcall for pm_init_finalize Michal Simek
2026-11-19 13:17 ` [PATCH 2/6] firmware: xilinx: Call va_start after pm feature check Michal Simek
2026-11-19 13:17 ` [PATCH 3/6] firmware: xilinx: Add comments about number of arguments Michal Simek
2026-11-19 13:17 ` [PATCH 4/6] firmware: xilinx: Call pm sysfs out of dev_groups Michal Simek
2026-11-19 13:17 ` [PATCH 5/6] firmware: xilinx: Change debugfs pm_api_ret size to PAYLOAD_ARG_CNT Michal Simek
2026-11-19 13:17 ` Michal Simek [this message]

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=c2dcbb74fa6ad3c716daa747c024fb73e5f5109b.1795094242.git.michal.simek@amd.com \
    --to=michal.simek@amd.com \
    --cc=git@amd.com \
    --cc=jay.buddhabhatti@amd.com \
    --cc=jollys@xilinx.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=monstr@monstr.eu \
    --cc=rajanv@xilinx.com \
    /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®