From nobody Thu Oct 10 13:30:25 2024 X-Original-To: bugs@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4XPVxZ20Mcz5Z34L for ; Thu, 10 Oct 2024 13:30:26 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R11" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4XPVxY3Z2tz4Xw0 for ; Thu, 10 Oct 2024 13:30:25 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1728567025; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=0jeWhYhfprmMcc6mD3+bUBz9gBuGwjRTjuw6BXKChxc=; b=HnnzUxiizYFP50DaUp+Usdv2hG5/MOPmlh8ofySofVQtcyJkbJd9McLcF4BFxwSmo/C8c6 BiobWRN8Nd1wM6XghvrJhxl0Q3lDARQCT8/gBIaC9x64LCAFrqenHXLIJG6pNL8tScueyW KiZ6GQSGwaWecqj498CslIfMuNNiDBB0fV3ZPoe05u1uSSeAOu7aZ28Dsl/VMLPduXUMNb t3ZFPDTwBrKFuZQZpJD33UEkMTdgYyIoT7btu1Qh03REZLtQN00pUMjQO/reEw+41xevWI ja2ZlOZ/kTY9sXUwGq/7Dl5YOg2NE+Qluq+lr5zYpFfzsaK2P/zD+Djur7XRZw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1728567025; a=rsa-sha256; cv=none; b=LfurheMOh8GxygAL8zVlgA4PUHtxh+C2Cnuh6dKwKBwSF4eJztA/3z5WbpbI8j5hZWYhQ1 N9vhUB5lFILWHS4jzCa8AocU84DqgsznC4nwoTf3/qXityrmKMXjZ/BjXwqdcH7XGCGcdM cVHcdWOgiDE/oOrac9MoOxyprN0E+T2pIp6RJAvWietNuWTNvQOVpTb57KlcQgUimRvCqQ gGbaJ4Snm+WXpvuh0q/YBxHWd8+1WuiN4GjZSG8QwZ1rlAJEEKslfcbvg9b3+3RFJtDLzB ZF4a4dXzh3i2MgkIKek9B5S+hOT+oKwSv4lP4NEqrajAVnV6Kodo0nrC1GVHuw== Received: from kenobi.freebsd.org (kenobi.freebsd.org [IPv6:2610:1c1:1:606c::50:1d]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4XPVxY39lBz10H1 for ; Thu, 10 Oct 2024 13:30:25 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from kenobi.freebsd.org ([127.0.1.5]) by kenobi.freebsd.org (8.15.2/8.15.2) with ESMTP id 49ADUPRA016267 for ; Thu, 10 Oct 2024 13:30:25 GMT (envelope-from bugzilla-noreply@freebsd.org) Received: (from www@localhost) by kenobi.freebsd.org (8.15.2/8.15.2/Submit) id 49ADUPCW016266 for bugs@FreeBSD.org; Thu, 10 Oct 2024 13:30:25 GMT (envelope-from bugzilla-noreply@freebsd.org) X-Authentication-Warning: kenobi.freebsd.org: www set sender to bugzilla-noreply@freebsd.org using -f From: bugzilla-noreply@freebsd.org To: bugs@FreeBSD.org Subject: [Bug 281990] offset of sa_family in sockaddr_ib inconsistent with sockaddr Date: Thu, 10 Oct 2024 13:30:25 +0000 X-Bugzilla-Reason: AssignedTo X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: Base System X-Bugzilla-Component: bin X-Bugzilla-Version: 14.1-RELEASE X-Bugzilla-Keywords: X-Bugzilla-Severity: Affects Some People X-Bugzilla-Who: bmueller@panasas.com X-Bugzilla-Status: New X-Bugzilla-Resolution: X-Bugzilla-Priority: --- X-Bugzilla-Assigned-To: bugs@FreeBSD.org X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version rep_platform op_sys bug_status bug_severity priority component assigned_to reporter Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: https://bugs.freebsd.org/bugzilla/ Auto-Submitted: auto-generated List-Id: Bug reports List-Archive: https://lists.freebsd.org/archives/freebsd-bugs List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-bugs@FreeBSD.org MIME-Version: 1.0 https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D281990 Bug ID: 281990 Summary: offset of sa_family in sockaddr_ib inconsistent with sockaddr Product: Base System Version: 14.1-RELEASE Hardware: amd64 OS: Any Status: New Severity: Affects Some People Priority: --- Component: bin Assignee: bugs@FreeBSD.org Reporter: bmueller@panasas.com My system has a RoCE-enabled Broadcom NIC that uses the bnxt_re driver. To test whether libfabric can see the device, I ran 'fi_info -p verbs' which t= rips an assert in the libfabric library. (gdb) where #0 0x00000008007d810a in thr_kill () from /lib/libc.so.7 #1 0x0000000800751404 in raise () from /lib/libc.so.7 #2 0x00000008008049d9 in abort () from /lib/libc.so.7 #3 0x00000008007345f1 in __assert () from /lib/libc.so.7 #4 0x0000000800502253 in ofi_addr_set_port (addr=3D0x800e27510, port=3D0) = at ./include/ofi_net.h:832 #5 0x000000080050557e in vrb_alloc_ib_addrinfo (port_num=3D1 '\001', gid=3D0x7fffffffe3f0, pkey=3D65535) at prov/verbs/src/verbs_info.c:1045 #6 0x00000008005057b4 in vrb_get_sib (verbs_devs=3D0x8005f4380 ) at prov/verbs/src/verbs_info.c:1096 #7 0x0000000800506380 in vrb_init_info (all_infos=3D0x8005f3e08 ) at prov/verbs/src/verbs_info.c:1400 #8 0x0000000800507c99 in vrb_getinfo (version=3D65555, node=3D0x0, service= =3D0x0, flags=3D0, hints=3D0x800e1b000, info=3D0x7fffffffe640) at prov/verbs/src/verbs_info.c:1892 #9 0x000000080045fa2f in fi_getinfo_ (version=3D65555, node=3D0x0, service= =3D0x0, flags=3D0, hints=3D0x800e1b000, info=3D0x7fffffffe6b0) at src/fabric.c:1279 #10 0x0000000000401e22 in run (hints=3D0x800e1b000, node=3D0x0, port=3D0x0,= flags=3D0) at util/info.c:323 #11 0x000000000040227d in main (argc=3D3, argv=3D0x7fffffffe790) at util/in= fo.c:447 (gdb) frame 5 #5 0x000000080050557e in vrb_alloc_ib_addrinfo (port_num=3D1 '\001', gid=3D0x7fffffffe3f0, pkey=3D65535) at prov/verbs/src/verbs_info.c:1045 1045 ofi_addr_set_port((struct sockaddr *)sib, 0); (gdb) x/16xb sib 0x800e27510: 0x1b 0x00 0xff 0xff 0x00 0x00 0x00 0x00 0x800e27518: 0xfe 0x80 0x00 0x00 0x00 0x00 0x00 0x00 The code below expects to be able to cast a sockaddr_ib to a sockaddr so it= can call appropriate branch of switch statement based on the value of sa_family= .=20 This code only works properly if sa_family is at the same offset in both structures. vrb_alloc_ib_addrinfo(...) { struct sockaddr_ib *sib; ... ofi_addr_set_port((struct sockaddr *)sib, 0); } static inline void ofi_addr_set_port(struct sockaddr *addr, uint16_t port) { struct ofi_sockaddr_ib *sib; switch (ofi_sa_family(addr)) { case AF_INET: ofi_sin_port(addr) =3D htons(port); break; case AF_INET6: ofi_sin6_port(addr) =3D htons(port); break; case AF_IB: sib =3D (struct ofi_sockaddr_ib *)addr; sib->sib_sid =3D htonll(((uint64_t)OFI_RDMA_PS_IB << 16) + ntohs(po= rt)); sib->sib_sid_mask =3D htonll(OFI_IB_IP_PS_MASK | OFI_IB_IP_PORT_MAS= K); break; default: FI_WARN(&core_prov, FI_LOG_FABRIC, "Unknown address format\n"); assert(0); } } #define ofi_sa_family(addr) ((struct sockaddr *)(addr))->sa_family To correct the issue, sockaddr_ib would be changed to match sockaddr: Old: struct sockaddr_ib { unsigned short int sib_family; /* AF_IB */ ... } New: struct sockaddr_ib { unsigned char sib_len; sa_family sib_family; /* AF_IB */ ... } The change will need to be made in two locations: sys/ofed/include/rdma/ib.h contrib/ofed/librdmacm/ib.h --=20 You are receiving this mail because: You are the assignee for the bug.=