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]
Message-Id: <A23914B0-BFD7-48D6-ADCF-42062E1D9887@gmail.com>
Date:   Fri, 1 Apr 2022 09:19:57 +0200
From:   Jakob Koschel <jakobkoschel@...il.com>
To:     Andrew Morton <akpm@...ux-foundation.org>
Cc:     Mike Rapoport <rppt@...nel.org>,
        David Hildenbrand <david@...hat.com>,
        Oscar Salvador <osalvador@...e.de>,
        linux-kernel@...r.kernel.org, linux-fsdevel@...r.kernel.org,
        Brian Johannesmeyer <bjohannesmeyer@...il.com>,
        Cristiano Giuffrida <c.giuffrida@...nl>,
        "Bos, H.J." <h.j.bos@...nl>
Subject: Re: [PATCH] fs/proc/kcore.c: remove check of list iterator against
 head past the loop body


> On 1. Apr 2022, at 01:48, Andrew Morton <akpm@...ux-foundation.org> wrote:
> 
> On Fri,  1 Apr 2022 00:37:00 +0200 Jakob Koschel <jakobkoschel@...il.com> wrote:
> 
>> When list_for_each_entry() completes the iteration over the whole list
>> without breaking the loop, the iterator value will be a bogus pointer
>> computed based on the head element.
>> 
>> While it is safe to use the pointer to determine if it was computed
>> based on the head element, either with list_entry_is_head() or
>> &pos->member == head, using the iterator variable after the loop should
>> be avoided.
>> 
>> In preparation to limit the scope of a list iterator to the list
>> traversal loop, use a dedicated pointer to point to the found element [1].
>> 
>> ...
>> 
> 
> Speaking of limiting scope...

Fair point :-)

I see you have applied this already to the -mm tree. Shall I still move the iterator?
The hope is to remove the 'iter' variable altogether when there are no uses after
the loop anymore.

> 
> --- a/fs/proc/kcore.c~fs-proc-kcorec-remove-check-of-list-iterator-against-head-past-the-loop-body-fix
> +++ a/fs/proc/kcore.c
> @@ -316,7 +316,6 @@ read_kcore(struct file *file, char __use
> 	size_t page_offline_frozen = 1;
> 	size_t phdrs_len, notes_len;
> 	struct kcore_list *m;
> -	struct kcore_list *iter;
> 	size_t tsz;
> 	int nphdr;
> 	unsigned long start;
> @@ -480,6 +479,8 @@ read_kcore(struct file *file, char __use
> 		 * the previous entry, search for a matching entry.
> 		 */
> 		if (!m || start < m->addr || start >= m->addr + m->size) {
> +			struct kcore_list *iter;
> +
> 			m = NULL;
> 			list_for_each_entry(iter, &kclist_head, list) {
> 				if (start >= iter->addr &&
> _
> 

	Jakob

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ