Bug 27810

Summary: rpc.statd can loop
Product: Base System Reporter: Jean-Luc.Richier <Jean-Luc.Richier>
Component: miscAssignee: freebsd-bugs (Nobody) <bugs>
Status: Closed FIXED    
Severity: Affects Only Me    
Priority: Normal    
Version: Unspecified   
Hardware: Any   
OS: Any   

Description Jean-Luc.Richier 2001-06-01 11:10:00 UTC
When a host restarts after a crash, its rpc.statd daemon contacts
rpc.statd on other machines to inform them of recovery. But in some
cases the other machine (when FreeBSD) does not answer, therefore the
first rpc.statd deamon tries forever (24h) to make contact. This causes syslog
syslog error messages:
Jun  1 11:15:36 lagavulin rpc.statd: Failed to contact rpc.statd at host lagavulin.imag.fr
Jun  1 11:16:26 lagavulin rpc.statd: Failed to contact rpc.statd at host lagavulin.imag.fr
Jun  1 11:18:06 lagavulin last message repeated 2 times
Jun  1 11:27:26 lagavulin last message repeated 9 times

This bug is in all FreeBSD releases, but with the apparition of
nfs locking in FreeBSD5.0, rpc.statd is now useful to run

Fix: The problem is that the rpc server function sm_notify_1 in
usr/src/usr.sbin/rpc.statd/procs.c can return void, FALSE (that is NULL)
or &dummy pointer. But if the returned value is NULL the server
dispatcher does not send an answer, and the client will retry forever
To correct: sm_notify_1 should always return a dummy pointer
I suggest the patch
(There is one case in which return(NULL) may be correct, it is the case
of fork error, for future recovery )


--- 314,329 ----
    {
      /* Never heard of this host - why is it notifying us?             */
      syslog(LOG_ERR, "Unsolicited notification from host %s", arg->mon_name);
!     return (&dummy);
    }
    lp = hp->monList;
!   if (!lp) return (&dummy);   /* We know this host, but have no       */
                                /* outstanding requests.                */
    pid = fork();
    if (pid == -1)
    {
      syslog(LOG_ERR, "Unable to fork notify process - %s", strerror(errno));
!     return (NULL);            /* no answer, the client will retry */
    }
    if (pid) return (&dummy);   /* Parent returns                       */--Bm33ZgzRbGImiYkA6U7XTwQB4uCu6eiPbYgb2KaIY8rbdic4
Content-Type: text/plain; name="file.diff"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment; filename="file.diff"

*** usr.sbin/rpc.statd/procs.c.DIST     Sat Aug 28 06:47:17 1999
--- usr.sbin/rpc.statd/procs.c  Fri Jun  1 11:55:58 2001
***************
*** 314,329 ****
    {
      /* Never heard of this host - why is it notifying us?             */
      syslog(LOG_ERR, "Unsolicited notification from host %s", arg->mon_name);
!     return;
    }
    lp = hp->monList;
!   if (!lp) return (FALSE);    /* We know this host, but have no       */
                                /* outstanding requests.                */
    pid = fork();
    if (pid == -1)
    {
      syslog(LOG_ERR, "Unable to fork notify process - %s", strerror(errno));
!     return;
    }
    if (pid) return (&dummy);   /* Parent returns                       */
How-To-Repeat: This is a test run, but I saw the problem first on real cases.
On a FreeBSD machine (say xxx.imag.fr), compile the test rpc.statd
program
cd /usr/src/usr.sbin/rpc.statd
   cc -o test test.c -lrpcsvc
Do the following sequence
- kill any running rpc.statd, rpc.lockd
- rm /var/db/statd.status
- rpc.statd
- /usr/src/usr.sbin/rpc.statd/test xxx.imag.fr
- kill rpc.statd
- rpc.statd
Now you can see two rpc.statd processes running, and messages appear in
/var/log/messages after a few minutes
Comment 1 Alfred Perlstein freebsd_committer freebsd_triage 2002-07-11 18:41:59 UTC
State Changed
From-To: open->closed

fix has been committed to both 5.x and 4.x versions of FreeBSD, thank you.
Comment 2 commit-hook freebsd_committer freebsd_triage 2024-04-09 17:19:51 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/ports/commit/?id=6e5c3c7067c582416bead63f300004ce07e06a86

commit 6e5c3c7067c582416bead63f300004ce07e06a86
Author:     Dirk Meyer <dinoex@FreeBSD.org>
AuthorDate: 2024-04-09 17:19:05 +0000
Commit:     Dirk Meyer <dinoex@FreeBSD.org>
CommitDate: 2024-04-09 17:19:05 +0000

    graphics/gd: do not contract to FMA or thereabouts

    PR: 27810

 graphics/gd/Makefile | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)