Bug 289625 - rpcbind crashes when rpcinfo run.
Summary: rpcbind crashes when rpcinfo run.
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: bin (show other bugs)
Version: 15.0-CURRENT
Hardware: Any Any
: --- Affects Only Me
Assignee: Rick Macklem
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2025-09-15 13:56 UTC by David Gilbert
Modified: 2025-10-01 00:58 UTC (History)
2 users (show)

See Also:
rmacklem: mfc-stable15+


Attachments
Fix rpcbind from crashing when rpcinfo is done (429 bytes, patch)
2025-09-20 23:18 UTC, Rick Macklem
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description David Gilbert 2025-09-15 13:56:17 UTC
To test this, I'm running on:

FreeBSD vr.home.dclg.ca 15.0-PRERELEASE FreeBSD 15.0-PRERELEASE #0 main-n279821-f13a042a5711: Tue Aug 26 18:50:10 EDT 2025     root@vr.home.dclg.ca:/usr/obj/usr/src/amd64.amd64/sys/GENERIC-NODEBUG amd64

I run:

rpcbind -d

Then I run:

rpcinfo localhost

[2:25:325]root@vr:/vr1/backup/Acronis> rpcinfo localhost
rpcinfo: can't contact rpcbind: : RPC: Unable to receive; errno = Connection reset by peer

coming back to rpcbind, it says:

[2:51:351]root@vr:~> rpcbind -d
rpcbind debugging enabled.
Segmentation fault (core dumped)

... so I: 

[2:52:352]root@vr:~> gdb rpcbind rpcbind.core
GNU gdb (GDB) 15.1 [GDB v15.1 for FreeBSD]
Copyright (C) 2024 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "x86_64-portbld-freebsd14.2".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<https://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
    <http://www.gnu.org/software/gdb/documentation/>.

For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from rpcbind...
Reading symbols from /usr/lib/debug//usr/sbin/rpcbind.debug...
[New LWP 731146]
Core was generated by `rpcbind -d'.
Program terminated with signal SIGSEGV, Segmentation fault.
Address not mapped to object.
#0  ?? () at /usr/src/lib/libc/amd64/string/strlen.S:95 from /lib/libc.so.7
95              pcmpeqb (%rdi), %xmm1                   # compare head (with junk before string)
(gdb) bt
#0  ?? () at /usr/src/lib/libc/amd64/string/strlen.S:95 from /lib/libc.so.7
#1  0x00001d9c3c5273a8 in xdr_string (xdrs=xdrs@entry=0x3ba5fb06f808, cpp=cpp@entry=0x3ba5fb047460, maxsize=maxsize@entry=9000)
    at /usr/src/lib/libc/xdr/xdr.c:701
#2  0x00001d9c3c51b841 in xdr_rpcb (xdrs=0x3ba5fb06f808, objp=0x3ba5fb047450) at /usr/src/lib/libc/rpc/rpcb_prot.c:63
#3  0x00001d9c3c528df2 in xdr_reference (xdrs=xdrs@entry=0x3ba5fb06f808, pp=pp@entry=0x1d9418ba7140 <list_rbl>,
    size=size@entry=40, proc=proc@entry=0x1d9c3c51b7f0 <xdr_rpcb>) at /usr/src/lib/libc/xdr/xdr_reference.c:92
#4  0x00001d9c3c51b943 in xdr_rpcblist_ptr (xdrs=0x3ba5fb06f808, rp=0x1d9418ba7140 <list_rbl>)
    at /usr/src/lib/libc/rpc/rpcb_prot.c:124
#5  0x00001d9c3c5205e4 in svc_vc_reply (xprt=0x3ba5fb0208c0, msg=0x1d9c39a3d618) at /usr/src/lib/libc/rpc/svc_vc.c:646
#6  0x00001d9c3c51c7ee in svc_sendreply (xprt=0x0, xprt@entry=0x3ba5fb0208c0,
    xdr_results=xdr_results@entry=0x1d9c3c51b870 <xdr_rpcblist_ptr>, xdr_location=0x2328) at /usr/src/lib/libc/rpc/svc.c:368
#7  0x00001d9418ba0f52 in rpcb_service_3 (rqstp=0x1d9c39a3d740, transp=0x3ba5fb0208c0)
    at /usr/src/usr.sbin/rpcbind/rpcb_svc.c:175
#8  0x00001d9c3c51d08d in svc_getreq_common (fd=<optimized out>) at /usr/src/lib/libc/rpc/svc.c:664
#9  0x00001d9c3c51d118 in svc_getreq_poll (pfdp=pfdp@entry=0x1d9c39a3dcf0, pollretval=1) at /usr/src/lib/libc/rpc/svc.c:732
#10 0x00001d9418ba3069 in my_svc_run () at /usr/src/usr.sbin/rpcbind/rpcb_svc_com.c:1167
#11 0x00001d9418b9f835 in main (argc=<optimized out>, argv=0x1d9c39a40000) at /usr/src/usr.sbin/rpcbind/rpcbind.c:286
Comment 1 Rick Macklem freebsd_committer freebsd_triage 2025-09-20 23:18:00 UTC
Created attachment 263957 [details]
Fix rpcbind from crashing when rpcinfo is done

This patch fixes the crash, although I have
no idea what a netlink address string should
actually look like?
Comment 2 commit-hook freebsd_committer freebsd_triage 2025-09-28 15:00:50 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=70730cd21c9f2b0a80ff07e4491c0fe30f2d87c5

commit 70730cd21c9f2b0a80ff07e4491c0fe30f2d87c5
Author:     Rick Macklem <rmacklem@FreeBSD.org>
AuthorDate: 2025-09-28 14:56:17 +0000
Commit:     Rick Macklem <rmacklem@FreeBSD.org>
CommitDate: 2025-09-28 14:57:34 +0000

    rpc_generic.c: Fix a rpcbind core dump when rpcinfo is done

    Commit c5d671b added netlink support to
    server side rpcbind. However it did not add
    a case for AF_NETLINK to __rpc_taddr2uaddr_af().
    (Reported as PR#289625.)

    As such, without this patch the r_addr field of the
    netlink rbllist is NULL, which causes a crash in
    svc_sendreply() for a Dump query (what rpcinfo
    does).

    PR:     289625
    Reviewed by:    glebius
    MFC after:      3 days
    Differential Revision:  https://reviews.freebsd.org/D52651
    Fixes:  c5d671b711c3 ("libc/rpc: add userland side RPC server over netlink(4)")

 lib/libc/rpc/rpc_generic.c | 4 ++++
 1 file changed, 4 insertions(+)
Comment 3 Rick Macklem freebsd_committer freebsd_triage 2025-09-28 15:04:26 UTC
The patch has been committed to main
and will be MFC'd in 3 days.

Thanks for reporting it, rick
ps: I don't know where you are, but I'm
in Valemount BC these days. Nowhere near
UofG.
Comment 4 David Gilbert 2025-09-28 18:52:50 UTC
Patch works for me on both server and client.

PS.I'm still in Oshawa.  I have family out there, but crossing the country is expensive.  I do BSDCan pretty much every year, tho.  Not really near UoG, either, but everything is relative.
Comment 5 commit-hook freebsd_committer freebsd_triage 2025-10-01 00:57:24 UTC
A commit in branch stable/15 references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=4771b65fde4893ffbb36f53fcd20e3b850a50b6a

commit 4771b65fde4893ffbb36f53fcd20e3b850a50b6a
Author:     Rick Macklem <rmacklem@FreeBSD.org>
AuthorDate: 2025-09-28 14:56:17 +0000
Commit:     Rick Macklem <rmacklem@FreeBSD.org>
CommitDate: 2025-10-01 00:52:46 +0000

    rpc_generic.c: Fix a rpcbind core dump when rpcinfo is done

    Commit c5d671b added netlink support to
    server side rpcbind. However it did not add
    a case for AF_NETLINK to __rpc_taddr2uaddr_af().
    (Reported as PR#289625.)

    As such, without this patch the r_addr field of the
    netlink rbllist is NULL, which causes a crash in
    svc_sendreply() for a Dump query (what rpcinfo
    does).

    PR:     289625

    (cherry picked from commit 70730cd21c9f2b0a80ff07e4491c0fe30f2d87c5)

 lib/libc/rpc/rpc_generic.c | 4 ++++
 1 file changed, 4 insertions(+)
Comment 6 Rick Macklem freebsd_committer freebsd_triage 2025-10-01 00:58:55 UTC
The patch has been MFC'd.