Bug 167612 - [portalfs] The portal file system gets stuck inside portal_open(). ("1 extra fds")
Summary: [portalfs] The portal file system gets stuck inside portal_open(). ("1 extra ...
Status: Open
Alias: None
Product: Base System
Classification: Unclassified
Component: kern (show other bugs)
Version: 9.0-STABLE
Hardware: Any Any
: Normal Affects Only Me
Assignee: freebsd-bugs (Nobody)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-05-05 14:00 UTC by jau
Modified: 2017-12-31 22:29 UTC (History)
0 users

See Also:


Attachments
portal_vnops.c.diff (1.35 KB, patch)
2012-05-10 16:33 UTC, jau
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description jau 2012-05-05 14:00:21 UTC
All attempts to refer to any file under the mounted portal file system end up waiting indefinitely.
Actually the portal ends up reading STDIN while it should be reading from a command.
E.g. the following command should simply list the output from who, but instead it does nothing until ctrl-D is given on the tty...

cat /p/pipe/usr/bin/who

At the same time the following complaint gets written to syslog...

May  5 15:28:36 sleipnir kernel: portal_open: 1 extra fds

Apparently the faulty takes place and gets also partially handled within the following snippet of code in portal_vnops.c ...

        cmsg = mtod(cm, struct cmsghdr *);
        newfds = (cmsg->cmsg_len - sizeof(*cmsg)) / sizeof (int);
        if (newfds == 0) {
                error = ECONNREFUSED;
                goto bad;
        }
        /*
         * At this point the rights message consists of a control message
         * header, followed by a data region containing a vector of
         * integer file descriptors.  The fds were allocated by the action
         * of receiving the control message.
         */
        ip = (int *) (cmsg + 1);
        fd = *ip++;
        if (newfds > 1) {
                /*
                 * Close extra fds.
                 */
                int i;
                printf("portal_open: %d extra fds\n", newfds - 1);
                for (i = 1; i < newfds; i++) {
                        portal_closefd(td, *ip);
                        ip++;
                }
        }

It seems that newfds gets calculated wrong and fd gets picked too early in the message.
After that the correct fd gets treated as extra and closed.

Fix: 

Apparently some further jugglery with the control message is needed to get the data alignment right.
At the time of this writing I do not have a patch.
How-To-Repeat: See full description above.
Comment 1 Mark Linimon freebsd_committer freebsd_triage 2012-05-07 19:55:01 UTC
Responsible Changed
From-To: freebsd-bugs->freebsd-fs

Over to maintainer(s).
Comment 2 jau 2012-05-10 16:33:49 UTC
This really was an alignment issue.

The old code was not in sync with the alignment done in

the CMSG_* macros.


Find a patch attached.

--jau

Comment 3 jau 2012-06-03 07:25:40 UTC
Now the patch has been tested to work on...
- AMD64
- Sparc64
Comment 4 Eitan Adler freebsd_committer freebsd_triage 2017-12-31 07:59:55 UTC
For bugs matching the following criteria:

Status: In Progress Changed: (is less than) 2014-06-01

Reset to default assignee and clear in-progress tags.

Mail being skipped