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-next>] [day] [month] [year] [list]
Message-ID: <20241029054651.86356-2-mtodorovac69@gmail.com>
Date: Tue, 29 Oct 2024 06:46:52 +0100
From: Mirsad Todorovac <mtodorovac69@...il.com>
To: Alexander Gordeev <agordeev@...ux.ibm.com>,
	linux-kernel@...r.kernel.org,
	linux-fsdevel@...r.kernel.org
Cc: Mirsad Todorovac <mtodorovac69@...il.com>,
	Jakob Koschel <jakobkoschel@...il.com>,
	Mike Rapoport <rppt@...nel.org>,
	David Hildenbrand <david@...hat.com>,
	Oscar Salvador <osalvador@...e.de>,
	"Brian Johannesmeyer" <bjohannesmeyer@...il.com>,
	Cristiano Giuffrida <c.giuffrida@...nl>,
	"Bos, H.J." <h.j.bos@...nl>,
	Alexey Dobriyan <adobriyan@...il.com>,
	Andrew Morton <akpm@...ux-foundation.org>,
	Yang Li <yang.lee@...ux.alibaba.com>,
	Baoquan He <bhe@...hat.com>,
	Hari Bathini <hbathini@...ux.ibm.com>,
	Yan Zhen <yanzhen@...o.com>
Subject: [PATCH v1 1/1] fs/proc/kcore.c: fix coccinelle reported ERROR instances

Coccinelle complains about the nested reuse of the pointer `iter' with different
pointer type:

./fs/proc/kcore.c:515:26-30: ERROR: invalid reference to the index variable of the iterator on line 499
./fs/proc/kcore.c:534:23-27: ERROR: invalid reference to the index variable of the iterator on line 499
./fs/proc/kcore.c:550:40-44: ERROR: invalid reference to the index variable of the iterator on line 499
./fs/proc/kcore.c:568:27-31: ERROR: invalid reference to the index variable of the iterator on line 499
./fs/proc/kcore.c:581:28-32: ERROR: invalid reference to the index variable of the iterator on line 499
./fs/proc/kcore.c:599:27-31: ERROR: invalid reference to the index variable of the iterator on line 499
./fs/proc/kcore.c:607:38-42: ERROR: invalid reference to the index variable of the iterator on line 499
./fs/proc/kcore.c:614:26-30: ERROR: invalid reference to the index variable of the iterator on line 499

Replacing `struct kcore_list *iter' with `struct kcore_list *tmp' doesn't change the
scope and the functionality is the same and coccinelle seems happy.

NOTE: There was an issue with using `struct kcore_list *pos' as the nested iterator.
      The build did not work!

Fixes: 04d168c6d42d1 ("fs/proc/kcore.c: remove check of list iterator against head past the loop body")
Link: https://lore.kernel.org/all/CAHk-=wgRr_D8CB-D9Kg-c=EHreAsk5SqXPwr9Y7k9sA6cWXJ6w@mail.gmail.com/ [1]
Link: https://lkml.kernel.org/r/20220331223700.902556-1-jakobkoschel@gmail.com
Signed-off-by: Jakob Koschel <jakobkoschel@...il.com>
Cc: Mike Rapoport <rppt@...nel.org>
Cc: David Hildenbrand <david@...hat.com>
Cc: Oscar Salvador <osalvador@...e.de>
Cc: "Brian Johannesmeyer" <bjohannesmeyer@...il.com>
Cc: Cristiano Giuffrida <c.giuffrida@...nl>
Cc: "Bos, H.J." <h.j.bos@...nl>
Cc: Alexey Dobriyan <adobriyan@...il.com>
Cc: Andrew Morton <akpm@...ux-foundation.org>
Cc: Yang Li <yang.lee@...ux.alibaba.com>
Cc: Baoquan He <bhe@...hat.com>
Cc: Hari Bathini <hbathini@...ux.ibm.com>
Cc: Yan Zhen <yanzhen@...o.com>
Cc: Alexander Gordeev <agordeev@...ux.ibm.com>
Cc: linux-fsdevel@...r.kernel.org
Cc: linux-kernel@...r.kernel.org
Signed-off-by: Mirsad Todorovac <mtodorovac69@...il.com>
---
 v1: initial version

 fs/proc/kcore.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/fs/proc/kcore.c b/fs/proc/kcore.c
index 51446c59388f..25586ec4096a 100644
--- a/fs/proc/kcore.c
+++ b/fs/proc/kcore.c
@@ -493,13 +493,13 @@ static ssize_t read_kcore_iter(struct kiocb *iocb, struct iov_iter *iter)
 		 * the previous entry, search for a matching entry.
 		 */
 		if (!m || start < m->addr || start >= m->addr + m->size) {
-			struct kcore_list *iter;
+			struct kcore_list *tmp;
 
 			m = NULL;
-			list_for_each_entry(iter, &kclist_head, list) {
-				if (start >= iter->addr &&
-				    start < iter->addr + iter->size) {
-					m = iter;
+			list_for_each_entry(tmp, &kclist_head, list) {
+				if (start >= tmp->addr &&
+				    start < tmp->addr + tmp->size) {
+					m = tmp;
 					break;
 				}
 			}
-- 
2.43.0


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ