From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out-185.mta0.migadu.com (out-185.mta0.migadu.com [91.218.175.185]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9BDBA25D216 for ; Fri, 20 Feb 2026 22:26:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.185 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771626409; cv=none; b=QIG+MUplj/7awO6TvLSdRtpS0kGhjAhcDuS93xBtTBnKmF5oJZoTE0V2MXQwZ73hAcA5UPdTh1Qm1blOGroJtsPqLWr9mhUlic+fw7pohXR4pPS5MJSdQPlp+tWzjiqYiY91uDu7yuejm4HUOqRyf+5PgyYEc8T3Ww2/3w0uS6c= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771626409; c=relaxed/simple; bh=ObsMtcRRjv9Zj6rFWk3J31bqxVbLTticfINT6Fj0dx8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=GFyPfz30MuASBzoQqbUdBDT17f6u4/oHXQm863SG9qMsCGsk6RgZzlWLjEAY1Z3wfvL/ZhbDDwJHelXThbeFFuEKYHnyX8bslyZbdcqmkE36pTvgf9/3Q+OiycOfh0xotlxLVUOKKuKFpxQ3w7CjeiK3cLt4NPY2RHfbafb/WHg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=MzyEazbI; arc=none smtp.client-ip=91.218.175.185 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="MzyEazbI" X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1771626404; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=pa0F2SW5cYTzCEHbVS+ffKXWQRWV1EBeihritj2o+XI=; b=MzyEazbIKdSbCZHOcdQ3QCQJJ+mwvh4AuEYuu4q1oM9AJNmjPeY+KgXsyBI2kNGZBZP3jF 558pHkBWUX8h79Wz7uQPvWoPCBcBPYuqijnZ0O0KU+cYk3H69+udlHeGLpe74yzk+6rTqM 3aiA57aDhAGJbZsWp0m5d+GEwhvBB0c= From: Ihor Solodrai To: Alexei Starovoitov , Andrii Nakryiko , Daniel Borkmann , Eduard Zingerman , Jiri Olsa , Mykyta Yatsenko , =?UTF-8?q?Alexis=20Lothor=C3=A9?= Cc: Amery Hung , bpf@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-team@meta.com Subject: [PATCH bpf v3 06/15] selftests/bpf: Fix cleanup in check_fd_array_cnt__fd_array_too_big() Date: Fri, 20 Feb 2026 14:25:55 -0800 Message-ID: <20260220222604.1155148-7-ihor.solodrai@linux.dev> In-Reply-To: <20260220222604.1155148-1-ihor.solodrai@linux.dev> References: <20260220222604.1155148-1-ihor.solodrai@linux.dev> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Migadu-Flow: FLOW_OUT The Close() macro uses the passed in expression three times, which leads to repeated execution in case it has side effects. That is, Close(i--) would decrement i three times. ASAN caught a stack-buffer-undeflow error at a point where this was overlooked. Fix it. Acked-by: Eduard Zingerman Signed-off-by: Ihor Solodrai --- tools/testing/selftests/bpf/prog_tests/fd_array.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/testing/selftests/bpf/prog_tests/fd_array.c b/tools/testing/selftests/bpf/prog_tests/fd_array.c index c534b4d5f9da..3078d8264deb 100644 --- a/tools/testing/selftests/bpf/prog_tests/fd_array.c +++ b/tools/testing/selftests/bpf/prog_tests/fd_array.c @@ -412,8 +412,8 @@ static void check_fd_array_cnt__fd_array_too_big(void) ASSERT_EQ(prog_fd, -E2BIG, "prog should have been rejected with -E2BIG"); cleanup_fds: - while (i > 0) - Close(extra_fds[--i]); + while (i-- > 0) + Close(extra_fds[i]); } void test_fd_array_cnt(void) -- 2.53.0