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, 27 Apr 2011 13:11:30 +0300
From:	Phil Carmody <ext-phil.2.carmody@...ia.com>
To:	ext Catalin Marinas <catalin.marinas@....com>
Cc:	linux-mm@...ck.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] kmemleak: Never return a pointer you didn't 'get'

On 27/04/11 10:31 +0100, ext Catalin Marinas wrote:
> On Thu, 2011-04-21 at 12:39 +0100, Phil Carmody wrote:
> > Old - If you don't get the last pointer that you looked at, then it will
> > still be put, as there's no way of knowing you didn't get it.
> > 
> > New - If you didn't get it, then it refers to something deleted, and
> > your work is done, so return NULL.
> > 
> > Signed-off-by: Phil Carmody <ext-phil.2.carmody@...ia.com>
> 
> Good catch. But I think the code may look slightly simpler as below:
> 
> diff --git a/mm/kmemleak.c b/mm/kmemleak.c
> index c1d5867..aacee45 100644
> --- a/mm/kmemleak.c
> +++ b/mm/kmemleak.c
> @@ -1414,9 +1414,12 @@ static void *kmemleak_seq_next(struct seq_file *seq, void *v, loff_t *pos)
>  	++(*pos);
>  
>  	list_for_each_continue_rcu(n, &object_list) {
> -		next_obj = list_entry(n, struct kmemleak_object, object_list);
> -		if (get_object(next_obj))
> +		struct kmemleak_object *obj =
> +			list_entry(n, struct kmemleak_object, object_list);
> +		if (get_object(obj)) {
> +			next_obj = obj;
>  			break;
> +		}
>  	}
>  
>  	put_object(prev_obj);

I did consider that way too, but had no strong preference. I think I now
prefer yours, so please add:

Signed-off-by: Phil Carmody <ext-phil.2.carmody@...ia.com>

Cheers,
Phil
--
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