Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 20 May 2020 09:56:14 +0000
From:      bugzilla-noreply@freebsd.org
To:        bugs@FreeBSD.org
Subject:   [Bug 246597] Race condition on mountd
Message-ID:  <bug-246597-227@https.bugs.freebsd.org/bugzilla/>

next in thread | raw e-mail | index | archive | help
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D246597

            Bug ID: 246597
           Summary: Race condition on mountd
           Product: Base System
           Version: CURRENT
          Hardware: Any
                OS: Any
            Status: New
          Severity: Affects Many People
          Priority: ---
         Component: bin
          Assignee: bugs@FreeBSD.org
          Reporter: patrykkotlowski@gmail.com

While using mountd I noticed that if there is changes in exports file and
SIGHUP sent to mountd sometimes it omits some lines. It turned out that the=
re
is race condition in mountd.c file.

        /* Expand svc_run() here so that we can call get_exportlist(). */
        for (;;) {
                if (got_sighup) {
                        get_exportlist();
                        got_sighup =3D 0; //TODO raise!!!
                }
                readfds =3D svc_fdset;
                switch (select(svc_maxfd + 1, &readfds, NULL, NULL, NULL)) {
                case -1:
                        if (errno =3D=3D EINTR)
                                continue;
                        syslog(LOG_ERR, "mountd died: select: %m");
                        exit(1);
                case 0:
                        continue;
                default:
                        svc_getreqset(&readfds);
                }
        }

If mountd is processing get_exportlist and receives SIGHUP it will omit next
SIGHUP handle.

In my opinion this loop should look like this:

        /* Expand svc_run() here so that we can call get_exportlist(). */
        for (;;) {
                if (got_sighup) {
                        got_sighup =3D 0; //No race :)
                        get_exportlist();
                }
                readfds =3D svc_fdset;
                switch (select(svc_maxfd + 1, &readfds, NULL, NULL, NULL)) {
                case -1:
                        if (errno =3D=3D EINTR)
                                continue;
                        syslog(LOG_ERR, "mountd died: select: %m");
                        exit(1);
                case 0:
                        continue;
                default:
                        svc_getreqset(&readfds);
                }
        }

I tested it in my production environment.

--=20
You are receiving this mail because:
You are the assignee for the bug.=



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?bug-246597-227>