From patchwork Thu Oct 24 16:10:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Konstantin Shkolnyy X-Patchwork-Id: 13849361 Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) (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 9E1581F76A7; Thu, 24 Oct 2024 16:11:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.158.5 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729786309; cv=none; b=hoS7kwNLwhbclxoiFFgUzdGJLRqsddLAXk/8Jgcbjn2det4CSuSEM9TX4QL1bP2Ic4zVti7RncpQEUnUO5iCpjfMUMMXi4iOWCamwf5SjPUZJtjD7X5tfv0yDQf+/s1zaRlQe+GEhPAXQzxwtC2aqKuHXcmBDz7UH9egx8o/ljs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729786309; c=relaxed/simple; bh=NKpEWZqAF/Dy/vUCLRqDWShtGWbDcafcntb+ACzuvIE=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=WFXnIphBskKvCPkIxu4XdI7v7AviDlU2m9voUllS+UaHE+oZQaNtFBxK+m8cHhBHRKgYHfaAG3t1UjNXdS7tASlPipUaHrUqnETAVQKjm9xM7a6jRPE3854H5D3Gez1V4t6b/9YEhrwxxfPg0iUbmgO9QdCMQkN/xmwigEfesyU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com; spf=pass smtp.mailfrom=linux.ibm.com; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b=IEL8GPA+; arc=none smtp.client-ip=148.163.158.5 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="IEL8GPA+" Received: from pps.filterd (m0353725.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 49OElnNL016718; Thu, 24 Oct 2024 16:11:42 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc :content-transfer-encoding:date:from:message-id:mime-version :subject:to; s=pp1; bh=cjShAnZwpuDy1jrqifitN/jWZ/9nldAQHa2uMuir6 uk=; b=IEL8GPA+GJejxMEDQj7xFZSqyDKvdIV++Nxu7VORzaoyJJ5SFlWJVgbdW uwTX7i4cfAtC2k9G6RfcA6UZXB3BXhwlsdu23HC9RguClM6qQKXE3rjoQ7ZaalcC rMt4pTGdxGgf/WbpzZwW2etg4M96FhFT9RlE4sCwbiBu/MKlK+xdrvExgEMOT3Jh Q8P4IY5EquwtQIdSY6zB/N65Ziehwih8XdnwMJL8OtGTojpcxebu7KdLyJVXg6pX OMh1eEcBTFLuF+GYCRt1SEvgwFQQ5JTmIOaKeEsrXbwpKvl1s93fEQ8zGAlR+Lqi nxLfCfokw0O+MfFc6PAv+rseVez8w== Received: from ppma11.dal12v.mail.ibm.com (db.9e.1632.ip4.static.sl-reverse.com [50.22.158.219]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 42emajshkd-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 24 Oct 2024 16:11:42 +0000 (GMT) Received: from pps.filterd (ppma11.dal12v.mail.ibm.com [127.0.0.1]) by ppma11.dal12v.mail.ibm.com (8.18.1.2/8.18.1.2) with ESMTP id 49OEWTYW008796; Thu, 24 Oct 2024 16:11:22 GMT Received: from smtprelay03.wdc07v.mail.ibm.com ([172.16.1.70]) by ppma11.dal12v.mail.ibm.com (PPS) with ESMTPS id 42emkas89u-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 24 Oct 2024 16:11:22 +0000 Received: from smtpav04.dal12v.mail.ibm.com (smtpav04.dal12v.mail.ibm.com [10.241.53.103]) by smtprelay03.wdc07v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 49OGBLqu15794782 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 24 Oct 2024 16:11:21 GMT Received: from smtpav04.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 14FA65805A; Thu, 24 Oct 2024 16:11:21 +0000 (GMT) Received: from smtpav04.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id D0EE458063; Thu, 24 Oct 2024 16:11:20 +0000 (GMT) Received: from WIN-DU0DFC9G5VV.austin.ibm.com (unknown [9.41.105.143]) by smtpav04.dal12v.mail.ibm.com (Postfix) with ESMTP; Thu, 24 Oct 2024 16:11:20 +0000 (GMT) From: Konstantin Shkolnyy To: sgarzare@redhat.com Cc: virtualization@lists.linux.dev, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, mjrosato@linux.ibm.com, Konstantin Shkolnyy Subject: [PATCH v2] vsock/test: fix failures due to wrong SO_RCVLOWAT parameter Date: Thu, 24 Oct 2024 11:10:58 -0500 Message-Id: <20241024161058.435469-1-kshk@linux.ibm.com> X-Mailer: git-send-email 2.34.1 Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: o4xWv7fO9kP9QVrkwJLQ6NMNRSaMhM4K X-Proofpoint-GUID: o4xWv7fO9kP9QVrkwJLQ6NMNRSaMhM4K X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1051,Hydra:6.0.680,FMLib:17.12.62.30 definitions=2024-10-15_01,2024-10-11_01,2024-09-30_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 malwarescore=0 mlxscore=0 phishscore=0 priorityscore=1501 suspectscore=0 impostorscore=0 lowpriorityscore=0 spamscore=0 mlxlogscore=999 bulkscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2409260000 definitions=main-2410240133 This happens on 64-bit big-endian machines. SO_RCVLOWAT requires an int parameter. However, instead of int, the test uses unsigned long in one place and size_t in another. Both are 8 bytes long on 64-bit machines. The kernel, having received the 8 bytes, doesn't test for the exact size of the parameter, it only cares that it's >= sizeof(int), and casts the 4 lower-addressed bytes to an int, which, on a big-endian machine, contains 0. 0 doesn't trigger an error, SO_RCVLOWAT returns with success and the socket stays with the default SO_RCVLOWAT = 1, which results in test failures. Fixes: b1346338fbae ("vsock_test: POLLIN + SO_RCVLOWAT test") Fixes: 542e893fbadc ("vsock/test: two tests to check credit update logic") Signed-off-by: Konstantin Shkolnyy Reviewed-by: Stefano Garzarella --- Notes: The problem was found on s390 (big endian), while x86-64 didn't show it. After this fix, all tests pass on s390. Changes for v2: - add "Fixes:" lines to the commit message tools/testing/vsock/vsock_test.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/testing/vsock/vsock_test.c b/tools/testing/vsock/vsock_test.c index 8d38dbf8f41f..7fd25b814b4b 100644 --- a/tools/testing/vsock/vsock_test.c +++ b/tools/testing/vsock/vsock_test.c @@ -835,7 +835,7 @@ static void test_stream_poll_rcvlowat_server(const struct test_opts *opts) static void test_stream_poll_rcvlowat_client(const struct test_opts *opts) { - unsigned long lowat_val = RCVLOWAT_BUF_SIZE; + int lowat_val = RCVLOWAT_BUF_SIZE; char buf[RCVLOWAT_BUF_SIZE]; struct pollfd fds; short poll_flags; @@ -1357,7 +1357,7 @@ static void test_stream_rcvlowat_def_cred_upd_client(const struct test_opts *opt static void test_stream_credit_update_test(const struct test_opts *opts, bool low_rx_bytes_test) { - size_t recv_buf_size; + int recv_buf_size; struct pollfd fds; size_t buf_size; void *buf;