From patchwork Tue Apr 23 10:26:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geliang Tang X-Patchwork-Id: 13639721 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 0D033481D1; Tue, 23 Apr 2024 10:26:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713868001; cv=none; b=bw40MsIfDrnTyuiAP1CyOEB+Votsfqilw/jWcQAn4nsKIcKJAxO8rHdhfW4cmL0DnGVq0sj+ku3JEwhl/VjaUQYTm+W3DXR3Rfo38jKb+0JJnTEOJtuNfO/cisRCN8OciXXk5B1gCA1LckdffmEoKs9zMU4jLKmwwBimiouvc3c= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713868001; c=relaxed/simple; bh=9HXfbycHwqXmAKZDBEaimP6Gs01ML6b9Mr8ArWmc5sQ=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=ihDPcAgaJw4cjsCldSd3vUjZdERQi/YeZxy28FN+Ni8uO3+qKe/Q8QIuee5Sk47Ue9jwIlSD4q5aEd9if9w11lk1dhxNE5QEapP1xL2/kt0oj3WFC9EAHqTGZ2GayX56K8aea33agHF9uDpoIbrV77mXgbGQlDHX2+j758cRzxY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=HUdLp2va; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="HUdLp2va" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 774B8C4AF07; Tue, 23 Apr 2024 10:26:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1713868000; bh=9HXfbycHwqXmAKZDBEaimP6Gs01ML6b9Mr8ArWmc5sQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HUdLp2vaosudp7Vptnmtwg5Ie6CPqqDyiXrxwr4ei1WvKFkt/KHpebM0ko69cABJ/ 14pO38LaEWhNxj1IDyIfM0hRrVvbZ4FzTsT8aBGznxVkcFJrseCtaZASBtvdKJIlUq ZQjvmftlADtj98EDR3b7y07R38pE35wEopy2T11KoIYWhLbgaZ2iN56B0LJZlEyjoJ NSOUZYMfXWV1yqkDHGHlXEn6PTrPV9uK211ysKehmlUwxt+m5lTO5Q6Hy3y8Al5d++ Fd4Hd4+e+e/QlGjXoJ0UWDl/BSqPyWORQ2qUTJckNZWoiFsnA24a7BV5+w6v5/9c7/ JR5xuPtGF+pCA== From: Geliang Tang To: Andrii Nakryiko , Eduard Zingerman , Mykola Lysenko , Alexei Starovoitov , Daniel Borkmann , Martin KaFai Lau , Song Liu , Yonghong Song , John Fastabend , KP Singh , Stanislav Fomichev , Hao Luo , Jiri Olsa , Shuah Khan , Jakub Sitnicki Cc: Geliang Tang , bpf@vger.kernel.org, linux-kselftest@vger.kernel.org, Geliang Tang Subject: [PATCH bpf-next v5 2/2] selftests/bpf: Add F_SETFL for fcntl in test_sockmap Date: Tue, 23 Apr 2024 18:26:15 +0800 Message-Id: X-Mailer: git-send-email 2.40.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Geliang Tang Incorrect arguments are passed to fcntl() in test_sockmap.c when invoking it to set file status flags. If O_NONBLOCK is used as 2nd argument and passed into fcntl, -EINVAL will be returned (See do_fcntl() in fs/fcntl.c). The correct approach is to use F_SETFL as 2nd argument, and O_NONBLOCK as 3rd one. Fixes: 16962b2404ac ("bpf: sockmap, add selftests") Signed-off-by: Geliang Tang Acked-by: Yonghong Song --- tools/testing/selftests/bpf/test_sockmap.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tools/testing/selftests/bpf/test_sockmap.c b/tools/testing/selftests/bpf/test_sockmap.c index 24b55da9d4af..74a2c6e74fae 100644 --- a/tools/testing/selftests/bpf/test_sockmap.c +++ b/tools/testing/selftests/bpf/test_sockmap.c @@ -603,7 +603,9 @@ static int msg_loop(int fd, int iov_count, int iov_length, int cnt, struct timeval timeout; fd_set w; - fcntl(fd, fd_flags); + if (fcntl(fd, F_SETFL, fd_flags)) + goto out_errno; + /* Account for pop bytes noting each iteration of apply will * call msg_pop_data helper so we need to account for this * by calculating the number of apply iterations. Note user