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: <2024111804-doze-reflected-0feb@gregkh>
Date: Mon, 18 Nov 2024 15:02:11 +0100
From: Greg KH <gregkh@...uxfoundation.org>
To: Ekansh Gupta <quic_ekangupt@...cinc.com>
Cc: srinivas.kandagatla@...aro.org, linux-arm-msm@...r.kernel.org,
	quic_bkumar@...cinc.com, linux-kernel@...r.kernel.org,
	quic_chennak@...cinc.com, dri-devel@...ts.freedesktop.org,
	arnd@...db.de
Subject: Re: [PATCH v1 4/4] misc: fastrpc: Add debugfs support for fastrpc

On Mon, Nov 18, 2024 at 02:10:46PM +0530, Ekansh Gupta wrote:
> Add changes to support debugfs. The fastrpc directory will be
> created which will carry debugfs files for all fastrpc processes.
> The information of fastrpc user and channel contexts are getting
> captured as part of this change.
> 
> Signed-off-by: Ekansh Gupta <quic_ekangupt@...cinc.com>
> ---
>  drivers/misc/fastrpc/Makefile        |   3 +-
>  drivers/misc/fastrpc/fastrpc_debug.c | 156 +++++++++++++++++++++++++++
>  drivers/misc/fastrpc/fastrpc_debug.h |  31 ++++++
>  drivers/misc/fastrpc/fastrpc_main.c  |  18 +++-
>  4 files changed, 205 insertions(+), 3 deletions(-)
>  create mode 100644 drivers/misc/fastrpc/fastrpc_debug.c
>  create mode 100644 drivers/misc/fastrpc/fastrpc_debug.h
> 
> diff --git a/drivers/misc/fastrpc/Makefile b/drivers/misc/fastrpc/Makefile
> index 020d30789a80..4ff6b64166ae 100644
> --- a/drivers/misc/fastrpc/Makefile
> +++ b/drivers/misc/fastrpc/Makefile
> @@ -1,3 +1,4 @@
>  # SPDX-License-Identifier: GPL-2.0
>  obj-$(CONFIG_QCOM_FASTRPC)	+= fastrpc.o
> -fastrpc-objs	:= fastrpc_main.o
> \ No newline at end of file
> +fastrpc-objs	:= fastrpc_main.o \
> +		fastrpc_debug.o

Only build this file if debugfs is enabled.

And again, "debug.c"?

> diff --git a/drivers/misc/fastrpc/fastrpc_debug.c b/drivers/misc/fastrpc/fastrpc_debug.c
> new file mode 100644
> index 000000000000..cdb4fc6845a8
> --- /dev/null
> +++ b/drivers/misc/fastrpc/fastrpc_debug.c
> @@ -0,0 +1,156 @@
> +// SPDX-License-Identifier: GPL-2.0
> +// Copyright (c) 2024 Qualcomm Innovation Center.
> +
> +#include <linux/debugfs.h>
> +#include <linux/seq_file.h>
> +#include "fastrpc_shared.h"
> +#include "fastrpc_debug.h"
> +
> +#ifdef CONFIG_DEBUG_FS

Please put the #ifdef in the .h file, not in the .c file.

> +void fastrpc_create_user_debugfs(struct fastrpc_user *fl)
> +{
> +	char cur_comm[TASK_COMM_LEN];
> +	int domain_id, size;
> +	char *debugfs_buf;
> +	struct dentry *debugfs_dir = fl->cctx->debugfs_dir;
> +
> +	memcpy(cur_comm, current->comm, TASK_COMM_LEN);
> +	cur_comm[TASK_COMM_LEN-1] = '\0';
> +	if (debugfs_dir != NULL) {
> +		domain_id = fl->cctx->domain_id;
> +		size = snprintf(NULL, 0, "%.10s_%d_%d_%d", cur_comm,
> +				current->pid, fl->tgid, domain_id) + 1;
> +		debugfs_buf = kzalloc(size, GFP_KERNEL);
> +		if (debugfs_buf == NULL)
> +			return;
> +		/*
> +		 * Use HLOS process name, HLOS PID, fastrpc user TGID,
> +		 * domain_id in debugfs filename to create unique file name
> +		 */
> +		snprintf(debugfs_buf, size, "%.10s_%d_%d_%d",
> +			cur_comm, current->pid, fl->tgid, domain_id);
> +		fl->debugfs_file = debugfs_create_file(debugfs_buf, 0644,
> +				debugfs_dir, fl, &fastrpc_debugfs_fops);

Why are you saving the debugfs file?  What do you need to do with it
that you can't just delete the whole directory, or look up the name
again in the future when removing it?

> +		kfree(debugfs_buf);
> +	}
> +}
> +
> +void fastrpc_remove_user_debugfs(struct fastrpc_user *fl)
> +{
> +	debugfs_remove(fl->debugfs_file);

Why remove just the file and not the whole directory?

> +}
> +
> +struct dentry *fastrpc_create_debugfs_dir(const char *name)
> +{
> +	return debugfs_create_dir(name, NULL);

At the root of debugfs?  Why is this function even needed?

> +}
> +
> +void fastrpc_remove_debugfs_dir(struct dentry *cctx_debugfs)
> +{
> +	debugfs_remove_recursive(cctx_debugfs);

See, you don't need the debugfs file reference at all, you don't do
anything with it.

And again, why are you wrapping basic debugfs functions with your own
version?  Please don't do that.

thanks,

greg k-h

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ