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]
Date:   Wed, 23 Jan 2019 09:11:41 +0900
From:   Masami Hiramatsu <mhiramat@...nel.org>
To:     Greg Kroah-Hartman <gregkh@...uxfoundation.org>
Cc:     linux-kernel@...r.kernel.org,
        Masami Hiramatsu <mhiramat@...nel.org>,
        Kees Cook <keescook@...omium.org>, Josef Bacik <jbacik@...com>,
        Thomas Gleixner <tglx@...utronix.de>,
        "Naveen N. Rao" <naveen.n.rao@...ux.vnet.ibm.com>,
        zhong jiang <zhongjiang@...wei.com>
Subject: Re: [PATCH] fail_function: no need to check return value of
 debugfs_create functions

On Tue, 22 Jan 2019 16:21:44 +0100
Greg Kroah-Hartman <gregkh@...uxfoundation.org> wrote:

> When calling debugfs functions, there is no need to ever check the
> return value.  The function can work or not, but the code logic should
> never do something different based on this.

Ah, OK. It simplifies the code. But I have a question below,

> 
> Cc: Masami Hiramatsu <mhiramat@...nel.org>
> Cc: Kees Cook <keescook@...omium.org>
> Cc: Josef Bacik <jbacik@...com>
> Cc: Thomas Gleixner <tglx@...utronix.de>
> Cc: "Naveen N. Rao" <naveen.n.rao@...ux.vnet.ibm.com>
> Cc: zhong jiang <zhongjiang@...wei.com>
> Signed-off-by: Greg Kroah-Hartman <gregkh@...uxfoundation.org>
> ---
>  kernel/fail_function.c | 23 +++++------------------
>  1 file changed, 5 insertions(+), 18 deletions(-)
> 
> diff --git a/kernel/fail_function.c b/kernel/fail_function.c
> index 17f75b545f66..afc779be5ebb 100644
> --- a/kernel/fail_function.c
> +++ b/kernel/fail_function.c
> @@ -152,20 +152,13 @@ static int fei_retval_get(void *data, u64 *val)
>  DEFINE_DEBUGFS_ATTRIBUTE(fei_retval_ops, fei_retval_get, fei_retval_set,
>  			 "%llx\n");
>  
> -static int fei_debugfs_add_attr(struct fei_attr *attr)
> +static void fei_debugfs_add_attr(struct fei_attr *attr)
>  {
>  	struct dentry *dir;
>  
>  	dir = debugfs_create_dir(attr->kp.symbol_name, fei_debugfs_dir);
> -	if (!dir)
> -		return -ENOMEM;
> -
> -	if (!debugfs_create_file("retval", 0600, dir, attr, &fei_retval_ops)) {
> -		debugfs_remove_recursive(dir);
> -		return -ENOMEM;
> -	}
>  
> -	return 0;

Don't we need to check dir here? If above debugfs_create_dir() returns NULL,
it seems we will create "retval" under root directory of debugfs.

Thank you,

> +	debugfs_create_file("retval", 0600, dir, attr, &fei_retval_ops);
>  }
>  
>  static void fei_debugfs_remove_attr(struct fei_attr *attr)
> @@ -306,7 +299,7 @@ static ssize_t fei_write(struct file *file, const char __user *buffer,
>  
>  	ret = register_kprobe(&attr->kp);
>  	if (!ret)
> -		ret = fei_debugfs_add_attr(attr);
> +		fei_debugfs_add_attr(attr);
>  	if (ret < 0)
>  		fei_attr_remove(attr);
>  	else {
> @@ -337,19 +330,13 @@ static int __init fei_debugfs_init(void)
>  		return PTR_ERR(dir);
>  
>  	/* injectable attribute is just a symlink of error_inject/list */
> -	if (!debugfs_create_symlink("injectable", dir,
> -				    "../error_injection/list"))
> -		goto error;
> +	debugfs_create_symlink("injectable", dir, "../error_injection/list");
>  
> -	if (!debugfs_create_file("inject", 0600, dir, NULL, &fei_ops))
> -		goto error;
> +	debugfs_create_file("inject", 0600, dir, NULL, &fei_ops);
>  
>  	fei_debugfs_dir = dir;
>  
>  	return 0;
> -error:
> -	debugfs_remove_recursive(dir);
> -	return -ENOMEM;
>  }
>  
>  late_initcall(fei_debugfs_init);
> -- 
> 2.20.1
> 


-- 
Masami Hiramatsu <mhiramat@...nel.org>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ