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, 5 Jun 2013 16:32:44 +0200
From:	David Sterba <dsterba@...e.cz>
To:	Jörn Engel <joern@...fs.org>
Cc:	Arne Jansen <sensille@....net>, Chris Mason <clmason@...ionio.com>,
	Christoph Hellwig <hch@...radead.org>,
	"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
	"linux-btrfs@...r.kernel.org" <linux-btrfs@...r.kernel.org>
Subject: Re: [PATCH 1/2] list: add while_list_drain_entry

On Tue, Jun 04, 2013 at 10:03:41PM -0400, Jörn Engel wrote:
> I have seen a lot of boilerplate code that either follows the pattern of
> 	while (!list_empty(head)) {
> 		pos = list_entry(head->next, struct foo, list);
> 		list_del(pos->list);
> 		...
> 	}
> or some variant thereof.
> 
> With this patch in, people can use
> 	while_list_drain_entry(pos, head, list) {
> 		...
> 	}

The while_list_drain_entry way changes the semantics: the list link is
deleted before the {...} body starts, so it's not possible to access the
list anymore. None of the code you've converted uses this, from that
point it's safe, but if this is about to be a public interface, it
should be (at least) documented.

Macro trickery to postpone list_del after the {...} finishes does not
work if kfree/kmem_cache_free/rcu_string_free/... is used.


david
--
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