Subject: Re: [PATCH v3 net-next 05/14] af_unix: Detect Strongly Connected Components.

From: Jakub Kicinski <[email-masked]>
Date: Sat, 24 Feb 2024 16:34:30 -0800

On Fri, 23 Feb 2024 13:39:54 -0800 Kuniyuki Iwashima wrote:
> +	list_for_each_entry(edge, &vertex->edges, vertex_entry) {
> +		struct unix_vertex *next_vertex = edge->successor->vertex;
> +
> +		if (!next_vertex)
> +			continue;
> +
> +		if (next_vertex->index == UNIX_VERTEX_INDEX_UNVISITED) {
> +			list_add(&edge->stack_entry, &edge_stack);
> +
> +			vertex = next_vertex;
> +			goto next_vertex;
> +prev_vertex:
> +			next_vertex = vertex;
> +
> +			edge = list_first_entry(&edge_stack, typeof(*edge), stack_entry);
> +			list_del_init(&edge->stack_entry);
> +
> +			vertex = edge->predecessor->vertex;
> +
> +			vertex->lowlink = min(vertex->lowlink, next_vertex->lowlink);
> +		} else if (edge->successor->vertex->on_stack) {
> +			vertex->lowlink = min(vertex->lowlink, next_vertex->index);
> +		}
> +	}
> +
> +	if (vertex->index == vertex->lowlink) {
> +		struct list_head scc;
> +
> +		__list_cut_position(&scc, &vertex_stack, &vertex->scc_entry);
> +
> +		list_for_each_entry_reverse(vertex, &scc, scc_entry) {
> +			list_move_tail(&vertex->entry, &unix_visited_vertices);
> +
> +			vertex->on_stack = false;
> +		}
> +
> +		list_del(&scc);
> +	}
> +
> +	if (!list_empty(&edge_stack))
> +		goto prev_vertex;

coccicheck says:

net/unix/garbage.c:406:17-23: ERROR: invalid reference to the index variable of the iterator on line 425

this code looks way to complicated to untangle on a quick weekend scan,
so please LMK if this is a false positive, I'll hide the patches from
patchwork for now ;)