From nobody Tue Sep 16 12:33:37 2025 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 B4370C4708E for ; Tue, 3 Jan 2023 10:29:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237046AbjACK2w (ORCPT ); Tue, 3 Jan 2023 05:28:52 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53880 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237294AbjACK2e (ORCPT ); Tue, 3 Jan 2023 05:28:34 -0500 Received: from domac.alu.hr (domac.alu.unizg.hr [161.53.235.3]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 28256FADB; Tue, 3 Jan 2023 02:28:27 -0800 (PST) Received: from localhost (localhost [127.0.0.1]) by domac.alu.hr (Postfix) with ESMTP id 5643F604F0; Tue, 3 Jan 2023 11:28:25 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=alu.unizg.hr; s=mail; t=1672741705; bh=mcsm3HVgNlvKRe0tp2pfP9pVcQV/6pvNR2zOemEzmzM=; h=Date:To:Cc:From:Subject:From; b=Sl0ubp0FW2YpNZlfOu0MvHin+EEJTNsAelAKq6/IO03P37Ybf1UuMkfmXm9kvJ2PX Wj7fKgphHKmDDyy8XBakWNXECSmfk9g7v7YQDiJWDkdVqfSBWci6PV8mFpuY6y1s6S lYXsSgi0a+gI60aM5B3LkUiR1gpXJXHY3DECPUlnwdqoHBybxk45folaWadpNOmFUo zfXLgnYlIjOMucCXImNFcxOB540dl6yn38eMA3nRAq1T1ZRWYwCYdLbXvWUVKhxlLK bwYqAlqh7yuxZe8FQrontKJwmNLDUPC1AJoduvTHTx4sp2OZLjQ/umakn7wgLIWKAc 8dqBFa6MWudWQ== 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 J8G14a8dvJs9; Tue, 3 Jan 2023 11:28:23 +0100 (CET) Received: from [192.168.0.12] (unknown [188.252.196.35]) by domac.alu.hr (Postfix) with ESMTPSA id 75940604EE; Tue, 3 Jan 2023 11:28:21 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=alu.unizg.hr; s=mail; t=1672741703; bh=mcsm3HVgNlvKRe0tp2pfP9pVcQV/6pvNR2zOemEzmzM=; h=Date:To:Cc:From:Subject:From; b=XQEX8JF41e8VN7dxnZuIFYEZRCjg3A3/V4fFW6sb6/9O1tPmkk+ZSRvecjZe87FFB tFRN6A3qu2cl9VXXhsZ5ZA4irbylZD418ihvM2c56QGIoSiG2BbXvmRr4ObkRsrb/X Tt5zfBYifg411Bm63IcyWCRTI0wRDLq0zLC/eCNB5q2VzZoByOtW9num6qptC3iwsk V6gWwrybolD7fl1XZ4Y7Vj+4SdDZOzM4qKkb6V8d9K2PbL9UFOLIMqbGS4mzMhWv8r ZsjR/9C+RnrZMcstHxs3j5joaJZ2UfoiyqAJgXsso1Tx0eBH/1gwKnMlvYwPcJLmql JuXhhWDd/3YCQ== Message-ID: <9e809447-bde6-7376-5431-ea200064f957@alu.unizg.hr> Date: Tue, 3 Jan 2023 11:28:19 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.4.2 Content-Language: en-US To: linux-kselftest@vger.kernel.org Cc: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Shuah Khan , Kuniyuki Iwashima , netdev@vger.kernel.org, linux-kernel@vger.kernel.org From: Mirsad Goran Todorovac Subject: PATCH [1/1]: Bug with sockaddr size in net/af_unix/test_unix_oob.c Content-Type: text/plain; charset="utf-8"; format="flowed" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi all, There is a minor issue that prevents self test net/af_unix to run on my pla= tform: # ./test_unix_oob Connect failed: No such file or directory Terminated Tracing reveals that bind tried to open a shorter AF_UNIX socket address: # strace -f ./test_unix_oob =2E =2E =2E socket(AF_UNIX, SOCK_STREAM, 0) =3D 3 getpid() =3D 453059 unlink("unix_oob_453059") =3D -1 ENOENT (No such file or dire= ctory) bind(3, {sa_family=3DAF_UNIX, sun_path=3D"unix_oob_453059"}, 110) =3D 0 pipe2([4, 5], 0) =3D 0 listen(3, 1) =3D 0 clone(child_stack=3DNULL, flags=3DCLONE_CHILD_CLEARTID|CLONE_CHILD_SETTID|S= IGCHLD, child_tidptr=3D0x7fa6a6577a10) =3D 453060 rt_sigaction(SIGURG, {sa_handler=3D0x5601e2d014c9, sa_mask=3D[], sa_flags= =3DSA_RESTORER|SA_RESTART|SA_SIGINFO,=20 sa_restorer=3D0x7fa6a623bcf0}, NULL, 8) =3D 0 write(5, "S", 1) =3D 1 accept(3, strace: Process 453060 attached [pid 453060] set_robust_list(0x7fa6a6577a20, 24) =3D 0 [pid 453060] socket(AF_UNIX, SOCK_STREAM, 0) =3D 6 [pid 453060] read(4, "S", 5) =3D 1 [pid 453060] connect(6, {sa_family=3DAF_UNIX, sun_path=3D"unix_oob_45305"},= 16) =3D -1 ENOENT (No such file or directory) =2E =2E =2E NOTE: bind used UNIX_AF addr "unix_oob_453059", while producer tries to con= nect to "unix_oob_45305". When pids were up to 5 digits it probably did not manifest, but logically t= he size of the consumer_addr is sizeof(struct sockaddr_un). Please find the patch attached: Thanks, Mirsad ---------------------------------------------------------------------------= --------------------- diff --git a/tools/testing/selftests/net/af_unix/test_unix_oob.c b/tools/te= sting/selftests/net/af_unix/test_unix_oob.c index b57e91e1c3f2..7ea733239cd9 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)) !=3D 0) { + sizeof(struct sockaddr_un)) !=3D 0) { perror("Connect failed"); kill(0, SIGTERM); exit(1); -- Mirsad Goran Todorovac Sistem in=C5=BEenjer Grafi=C4=8Dki fakultet | Akademija likovnih umjetnosti Sveu=C4=8Dili=C5=A1te u Zagrebu --=20 System engineer Faculty of Graphic Arts | Academy of Fine Arts University of Zagreb, Republic of Croatia The European Union