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] [day] [month] [year] [list]
Date:	Wed, 5 Sep 2012 14:37:00 -0700
From:	Andrew Morton <akpm@...ux-foundation.org>
To:	yan <clouds.yan@...il.com>
Cc:	linux-kernel@...r.kernel.org
Subject: Re: [PATCH 3/3 v2] proc: use kzalloc instead of kmalloc and memset

On Wed,  5 Sep 2012 20:17:17 +0800
yan <clouds.yan@...il.com> wrote:

> Part of the memory will be written twice after this change, but that 
> should be negligible.
> 
> ...
>
> --- a/fs/proc/generic.c
> +++ b/fs/proc/generic.c
> @@ -616,10 +616,9 @@ static struct proc_dir_entry *__proc_create(struct proc_dir_entry **parent,
>  
>  	len = strlen(fn);
>  
> -	ent = kmalloc(sizeof(struct proc_dir_entry) + len + 1, GFP_KERNEL);
> +	ent = kzalloc(sizeof(struct proc_dir_entry) + len + 1, GFP_KERNEL);
>  	if (!ent) goto out;
>  
> -	memset(ent, 0, sizeof(struct proc_dir_entry));
>  	memcpy(ent->name, fn, len + 1);
>  	ent->namelen = len;
>  	ent->mode = mode;

I'm not sure that I really like the idea of adding this additional
overhead.  But sure, it won't matter to anyone at all.

While we're digging around in __proc_create(), how about we fix a few
other things?


From: Andrew Morton <akpm@...ux-foundation.org>
Subject: proc-use-kzalloc-instead-of-kmalloc-and-memset-fix

fix __proc_create() coding-style issues, remove unneeded zero-initialisations

Cc: yan <clouds.yan@...il.com>
Signed-off-by: Andrew Morton <akpm@...ux-foundation.org>
---

 fs/proc/generic.c |   10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff -puN fs/proc/generic.c~proc-use-kzalloc-instead-of-kmalloc-and-memset-fix fs/proc/generic.c
--- a/fs/proc/generic.c~proc-use-kzalloc-instead-of-kmalloc-and-memset-fix
+++ a/fs/proc/generic.c
@@ -605,7 +605,8 @@ static struct proc_dir_entry *__proc_cre
 	unsigned int len;
 
 	/* make sure name is valid */
-	if (!name || !strlen(name)) goto out;
+	if (!name || !strlen(name))
+		goto out;
 
 	if (xlate_proc_name(name, parent, &fn) != 0)
 		goto out;
@@ -617,18 +618,17 @@ static struct proc_dir_entry *__proc_cre
 	len = strlen(fn);
 
 	ent = kzalloc(sizeof(struct proc_dir_entry) + len + 1, GFP_KERNEL);
-	if (!ent) goto out;
+	if (!ent)
+		goto out;
 
 	memcpy(ent->name, fn, len + 1);
 	ent->namelen = len;
 	ent->mode = mode;
 	ent->nlink = nlink;
 	atomic_set(&ent->count, 1);
-	ent->pde_users = 0;
 	spin_lock_init(&ent->pde_unload_lock);
-	ent->pde_unload_completion = NULL;
 	INIT_LIST_HEAD(&ent->pde_openers);
- out:
+out:
 	return ent;
 }
 
_

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ