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:   Thu, 29 Nov 2018 13:30:39 +0100
From:   Peter Zijlstra <peterz@...radead.org>
To:     Bart Van Assche <bvanassche@....org>
Cc:     mingo@...hat.com, tj@...nel.org, johannes.berg@...el.com,
        linux-kernel@...r.kernel.org
Subject: Re: [PATCH 23/27] locking/lockdep: Check data structure consistency

On Wed, Nov 28, 2018 at 03:43:21PM -0800, Bart Van Assche wrote:

> +static bool in_list(struct list_head *e, struct list_head *h)
> +{
> +	struct list_head *f;
> +
> +	list_for_each(f, h)
> +		if (e == f)
> +			return true;

Coding style wants { } around any multi line block, even if C doesn't
strictly require it.

> +
> +	return false;
> +}

> +static bool check_lock_chain_key(struct lock_chain *chain)
> +{
> +	u64 chain_key = 0;
> +	int i;
> +
> +	for (i = chain->base; i < chain->base + chain->depth; i++)
> +		chain_key = iterate_chain_key(chain_key, chain_hlocks[i] + 1);
> +	/*
> +	 * The 'unsigned long long' casts avoid that a compiler warning
> +	 * is reported when building tools/lib/lockdep.
> +	 */
> +	if (chain->chain_key != chain_key)
> +		printk(KERN_INFO "chain %lld: key %#llx <> %#llx\n",
> +		       (unsigned long long)(chain - lock_chains),
> +		       (unsigned long long)chain->chain_key,
> +		       (unsigned long long)chain_key);

Idem on the { }

> +	return chain->chain_key == chain_key;
> +}
> +
> +static bool check_data_structures(void)
> +{
> +	struct lock_class *class;
> +	struct lock_chain *chain;
> +	struct hlist_head *head;
> +	struct lock_list *e;
> +	int i;
> +
> +	/*
> +	 * Check whether all list entries that are in use occur in a class
> +	 * lock list.
> +	 */
> +	list_for_each_entry(e, &all_list_entries, alloc_entry) {
> +		if (!in_any_class_list(&e->lock_order_entry)) {
> +			printk(KERN_INFO "list entry %ld is not in any class list; class %s <> %s\n",
> +			       e - list_entries,
> +			       e->class->name ? : "(?)",
> +			       e->links_to->name ? : "(?)");
> +			return false;
> +		}
> +	}
> +
> +	/*
> +	 * Check whether all list entries that are not in use do not occur in
> +	 * a class lock list.
> +	 */
> +	list_for_each_entry(e, &free_list_entries, alloc_entry) {
> +		if (in_any_class_list(&e->lock_order_entry)) {
> +			printk(KERN_INFO "list entry %ld occurs in a class list; class %s <> %s\n",
> +			       e - list_entries,
> +			       e->class && e->class->name ? e->class->name :
> +			       "(?)",
> +			       e->links_to && e->links_to->name ?
> +			       e->links_to->name : "(?)");
> +			return false;
> +		}
> +	}
> +
> +	/* Check whether all classes have valid lock lists. */
> +	for (i = 0; i < ARRAY_SIZE(lock_classes); i++) {
> +		class = &lock_classes[i];
> +		if (!class->locks_before.next)
> +			continue;
> +		if (!class_lock_list_valid(class, &class->locks_before))
> +			return false;
> +		if (!class_lock_list_valid(class, &class->locks_after))
> +			return false;
> +	}
> +
> +	/* Check the chain_key of all lock chains. */
> +	for (i = 0; i < ARRAY_SIZE(chainhash_table); i++) {
> +		head = chainhash_table + i;
> +		hlist_for_each_entry_rcu(chain, head, entry)
> +			if (!check_lock_chain_key(chain))
> +				return false;

And again.

> +	}
> +
> +	return true;
> +}

IIRC there were a few other sites in the series, please check them all.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ