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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Tue, 11 Jun 2019 11:44:53 -0700
From:   Kees Cook <keescook@...omium.org>
To:     Greg Kroah-Hartman <gregkh@...uxfoundation.org>
Cc:     Arnd Bergmann <arnd@...db.de>, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] lkdtm: no need to check return value of debugfs_create
 functions

On Tue, Jun 11, 2019 at 08:32:13PM +0200, Greg Kroah-Hartman 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.

What is the user-visible feedback when, say, debugfs_create_file()
fails? And what happens when debugfs_create_file() passes in a NULL
root?

-Kees

> 
> Cc: Kees Cook <keescook@...omium.org>
> Cc: Arnd Bergmann <arnd@...db.de>
> Cc: linux-kernel@...r.kernel.org
> Signed-off-by: Greg Kroah-Hartman <gregkh@...uxfoundation.org>
> ---
>  drivers/misc/lkdtm/core.c | 13 ++-----------
>  1 file changed, 2 insertions(+), 11 deletions(-)
> 
> diff --git a/drivers/misc/lkdtm/core.c b/drivers/misc/lkdtm/core.c
> index 1972dad966f5..bae3b3763f3e 100644
> --- a/drivers/misc/lkdtm/core.c
> +++ b/drivers/misc/lkdtm/core.c
> @@ -429,22 +429,13 @@ static int __init lkdtm_module_init(void)
>  
>  	/* Register debugfs interface */
>  	lkdtm_debugfs_root = debugfs_create_dir("provoke-crash", NULL);
> -	if (!lkdtm_debugfs_root) {
> -		pr_err("creating root dir failed\n");
> -		return -ENODEV;
> -	}
>  
>  	/* Install debugfs trigger files. */
>  	for (i = 0; i < ARRAY_SIZE(crashpoints); i++) {
>  		struct crashpoint *cur = &crashpoints[i];
> -		struct dentry *de;
>  
> -		de = debugfs_create_file(cur->name, 0644, lkdtm_debugfs_root,
> -					 cur, &cur->fops);
> -		if (de == NULL) {
> -			pr_err("could not create crashpoint %s\n", cur->name);
> -			goto out_err;
> -		}
> +		debugfs_create_file(cur->name, 0644, lkdtm_debugfs_root, cur,
> +				    &cur->fops);
>  	}
>  
>  	/* Install crashpoint if one was selected. */
> -- 
> 2.22.0
> 

-- 
Kees Cook

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ