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, 25 Aug 2021 16:08:06 +0000
From:   "Li,Rongqing" <lirongqing@...du.com>
To:     Peter Zijlstra <peterz@...radead.org>,
        Michel Lespinasse <michel@...pinasse.org>
CC:     "dbueso@...e.de" <dbueso@...e.de>,
        "mingo@...nel.org" <mingo@...nel.org>,
        "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: 答复: [PATCH] rbtree: stop iteration early in rb_find_first



>> 
>>  
>>                          10
>>                        /
>>                       5
>>                        \
>>                         10
>>  
>> The search would stop after visiting node 5, and miss the leaf which
>> is the expected node to be returned.

 thanks for explanation.

> Just to clarify; the current code *does* work here. The proposed patch
> breaks it.

true, my patch is wrong.

but rb_find_first seems have other issue.  when the key is equal, we should search right leaf, not left leaf
rb_find_first should like below

	while (node) {
		int c = cmp(key, node);

		if (c < 0) {
			node = node->rb_left;
		} else {
			if (!c)
				match = node;
			node = node->rb_right;
		}
	}
 
since the node  is inserted to right when the key is equal, see rb_add()

 -Li

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ