From patchwork Sat Jan 7 03:40:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Mirsad Todorovac X-Patchwork-Id: 13091963 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3F7ABC46467 for ; Sat, 7 Jan 2023 03:40:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236714AbjAGDk2 (ORCPT ); Fri, 6 Jan 2023 22:40:28 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41006 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236776AbjAGDk0 (ORCPT ); Fri, 6 Jan 2023 22:40:26 -0500 Received: from domac.alu.hr (domac.alu.unizg.hr [161.53.235.3]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AACA18D5C8; Fri, 6 Jan 2023 19:40:24 -0800 (PST) Received: from localhost (localhost [127.0.0.1]) by domac.alu.hr (Postfix) with ESMTP id 43B47604F1; Sat, 7 Jan 2023 04:40:23 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=alu.hr; s=mail; t=1673062823; bh=j01mQb8I5u689YuQw+ChwSxg7IB7KBCJmP6hGzSe+so=; h=Date:From:To:cc:Subject:In-Reply-To:References:From; b=fcu4HcuzuZ/P9jRH6RNpZubOP0xy9Tqn4dSo6j3CGQxmFZGhjfQG+Mys9uGCWCBKm DJ3c5FaRZ/EbntEbtvzYQW2PTdtLUtDko9Vz0/x/crn5Fwepklv3JyyF4C/+L4UZXI CseqPJig+KY5aAMgg+eQaDFIvEta/MJNLMyeDEsRNX1r16KTZJPj9UiTvwFmVtUwf/ 4WnucXvoS0K+/HthKcQ+jmop+lK7NWPdlJF+54CpbGndAM5xmPjk46Bb1kmA/mEgKl XninS0jUdwYpuYlTZxA0DHd1dbMa2RObEIFDihr4vYKb/py8UchrMDUdyhu03fPJri bBuy1yVAs6YeQ== X-Virus-Scanned: Debian amavisd-new at domac.alu.hr Received: from domac.alu.hr ([127.0.0.1]) by localhost (domac.alu.hr [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id UgvktLthh6J8; Sat, 7 Jan 2023 04:40:20 +0100 (CET) Received: by domac.alu.hr (Postfix, from userid 1014) id AB762604F2; Sat, 7 Jan 2023 04:40:20 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=alu.hr; s=mail; t=1673062820; bh=j01mQb8I5u689YuQw+ChwSxg7IB7KBCJmP6hGzSe+so=; h=Date:From:To:cc:Subject:In-Reply-To:References:From; b=Byfgq7kO0qX1Vp0niERdxBYNDVVrBuM1JUY1zAaDnpV7uFjrb3E4+eeTJC1e/FaaS I3Nnk0lqf+oV7rcFMYzeiPX+rkQwcwos2p9HGhpGUPz7l73/BhawOFKxVXVnisQeqj nYT+5H8Js9zUElqI/sZhpWk7kHe/6ec5O0RlC4jw8MrzMt5a0HCZc67leIYxbAEx8v B6/VPQ+6YaOw+ui2NxisGHBesc2GM9KTteqwzPYRiVXEiWU8/VPxWQmPlsJ0oUlVf7 NZYZFBqlf6nwJ+8GJRANkR6/O1Y/Ef14KqMsEryghQrP4NyqSyaawOOuEX3w+jFX65 cujLnUJ3hy72w== Received: from localhost (localhost [127.0.0.1]) by domac.alu.hr (Postfix) with ESMTP id A612E604F1; Sat, 7 Jan 2023 04:40:20 +0100 (CET) Date: Sat, 7 Jan 2023 04:40:20 +0100 (CET) From: Mirsad Goran Todorovac To: Jakub Kicinski , Mirsad Goran Todorovac cc: Kuniyuki Iwashima , davem@davemloft.net, edumazet@google.com, fw@strlen.de, kuniyu@amazon.co.jp, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, netdev@vger.kernel.org, pabeni@redhat.com, shuah@kernel.org Subject: [PATCH net v4] af_unix: selftest: Fix the size of the parameter to connect() In-Reply-To: <20230106180808.51550e82@kernel.org> Message-ID: References: <20230106175828.13333-1-kuniyu@amazon.com> <20230106161450.1d5579bf@kernel.org> <8fb1a2c5-ee35-67eb-ef3c-e2673061850d@alu.unizg.hr> <20230106180808.51550e82@kernel.org> User-Agent: Alpine 2.21 (DEB 202 2017-01-01) MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org From: Mirsad Goran Todorovac Adjust size parameter in connect() to match the type of the parameter, to fix "No such file or directory" error in selftests/net/af_unix/ test_oob_unix.c:127. The existing code happens to work provided that the autogenerated pathname is shorter than sizeof (struct sockaddr), which is why it hasn't been noticed earlier. Visible from the trace excerpt: bind(3, {sa_family=AF_UNIX, sun_path="unix_oob_453059"}, 110) = 0 clone(child_stack=NULL, flags=CLONE_CHILD_CLEARTID|CLONE_CHILD_SETTID|SIGCHLD, child_tidptr=0x7fa6a6577a10) = 453060 [pid ] connect(6, {sa_family=AF_UNIX, sun_path="unix_oob_45305"}, 16) = -1 ENOENT (No such file or directory) BUG: The filename is trimmed to sizeof (struct sockaddr). Cc: "David S. Miller" Cc: Eric Dumazet Cc: Jakub Kicinski Cc: Paolo Abeni Cc: Shuah Khan Cc: Kuniyuki Iwashima Cc: Florian Westphal Reviewed-by: Florian Westphal Fixes: 314001f0bf92 ("af_unix: Add OOB support") Signed-off-by: Mirsad Goran Todorovac Reviewed-by: Kuniyuki Iwashima --- The patch is generated against the "vanilla" Torvalds mainline tree 6.2-rc2. (Tested and applies against the net.git tree.) tools/testing/selftests/net/af_unix/test_unix_oob.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- Mirsad Goran Todorovac Sistem inženjer Grafički fakultet | Akademija likovnih umjetnosti Sveučilište u Zagrebu System engineer Faculty of Graphic Arts | Academy of Fine Arts University of Zagreb, Republic of Croatia The European Union diff --git a/tools/testing/selftests/net/af_unix/test_unix_oob.c b/tools/testing/selftests/net/af_unix/test_unix_oob.c index b57e91e1c3f2..532459a15067 100644 --- a/tools/testing/selftests/net/af_unix/test_unix_oob.c +++ b/tools/testing/selftests/net/af_unix/test_unix_oob.c @@ -124,7 +124,7 @@ void producer(struct sockaddr_un *consumer_addr) wait_for_signal(pipefd[0]); if (connect(cfd, (struct sockaddr *)consumer_addr, - sizeof(struct sockaddr)) != 0) { + sizeof(*consumer_addr)) != 0) { perror("Connect failed"); kill(0, SIGTERM); exit(1);