lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <aMGYUALGv283tnV7@lizhi-Precision-Tower-5810>
Date: Wed, 10 Sep 2025 11:25:04 -0400
From: Frank Li <Frank.li@....com>
To: Peng Fan <peng.fan@....com>
Cc: Sudeep Holla <sudeep.holla@....com>,
	Cristian Marussi <cristian.marussi@....com>,
	Shawn Guo <shawnguo@...nel.org>,
	Sascha Hauer <s.hauer@...gutronix.de>,
	Pengutronix Kernel Team <kernel@...gutronix.de>,
	Fabio Estevam <festevam@...il.com>, arm-scmi@...r.kernel.org,
	imx@...ts.linux.dev, linux-arm-kernel@...ts.infradead.org,
	linux-kernel@...r.kernel.org
Subject: Re: [PATCH 2/2] firmware: imx: sm-misc: Dump syslog info

On Wed, Sep 10, 2025 at 10:28:18PM +0800, Peng Fan wrote:
> Add debugfs interface to read System Manager syslog info
>
> Signed-off-by: Peng Fan <peng.fan@....com>
> ---
>  drivers/firmware/imx/sm-misc.c | 42 ++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 42 insertions(+)
>
> diff --git a/drivers/firmware/imx/sm-misc.c b/drivers/firmware/imx/sm-misc.c
> index fc3ee12c2be878e0285183e3381c9514a63d5142..4678d76b7dd6907533b5131c15ff0edcb66f43b2 100644
> --- a/drivers/firmware/imx/sm-misc.c
> +++ b/drivers/firmware/imx/sm-misc.c
> @@ -3,12 +3,15 @@
>   * Copyright 2024 NXP
>   */
>
> +#include <linux/debugfs.h>
> +#include <linux/device/devres.h>
>  #include <linux/firmware/imx/sm.h>
>  #include <linux/module.h>
>  #include <linux/of.h>
>  #include <linux/platform_device.h>
>  #include <linux/scmi_protocol.h>
>  #include <linux/scmi_imx_protocol.h>
> +#include <linux/seq_file.h>
>
>  static const struct scmi_imx_misc_proto_ops *imx_misc_ctrl_ops;
>  static struct scmi_protocol_handle *ph;
> @@ -44,10 +47,43 @@ static int scmi_imx_misc_ctrl_notifier(struct notifier_block *nb,
>  	return 0;
>  }
>
> +static int syslog_show(struct seq_file *file, void *priv)
> +{
> +	struct device *dev = file->private;
> +	/* 4KB is large enough for syslog */
> +	void *syslog __free(kfree) = kmalloc(SZ_4K, GFP_KERNEL);
> +	/* syslog API use num words, not num bytes */
> +	u16 size = SZ_4K / 4;
> +	int ret;
> +
> +	if (!ph)
> +		return -ENODEV;
> +
> +	ret = imx_misc_ctrl_ops->misc_syslog(ph, &size, syslog);
> +	if (ret) {
> +		if (size > SZ_4K / 4) {
> +			dev_err(dev, "syslog size is larger than 4KB, please enlarge\n");
> +			return ret;

suppose it is never happen, you pass down size to misc_syslog, it should
never write data more than size.

I am not sure what means of misc_syslog() return value. Generally it should
be how many data in pointer 'syslog' if return value > 0.

So seq_hex_dump() should use ret value. Then only dump validate data,
instead of the whole buffer.

Frank

> +		}
> +	}
> +
> +	seq_hex_dump(file, " ", DUMP_PREFIX_NONE, 16, sizeof(u32), syslog, size * 4, false);
> +	seq_putc(file, '\n');
> +
> +	return 0;
> +}
> +DEFINE_SHOW_ATTRIBUTE(syslog);
> +
> +static void scmi_imx_misc_put(void *p)
> +{
> +	debugfs_remove((struct dentry *)p);
> +}
> +
>  static int scmi_imx_misc_ctrl_probe(struct scmi_device *sdev)
>  {
>  	const struct scmi_handle *handle = sdev->handle;
>  	struct device_node *np = sdev->dev.of_node;
> +	struct dentry *scmi_imx_dentry;
>  	u32 src_id, flags;
>  	int ret, i, num;
>
> @@ -98,6 +134,12 @@ static int scmi_imx_misc_ctrl_probe(struct scmi_device *sdev)
>  		}
>  	}
>
> +	scmi_imx_dentry = debugfs_create_dir("scmi_imx", NULL);
> +	if (!IS_ERR(scmi_imx_dentry))
> +		debugfs_create_file("syslog", 0444, scmi_imx_dentry, &sdev->dev, &syslog_fops);
> +
> +	devm_add_action_or_reset(&sdev->dev, scmi_imx_misc_put, scmi_imx_dentry);
> +
>  	return 0;
>  }
>
>
> --
> 2.37.1
>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ