mysterious sysctl failure on nullfs mount

Kamil Choudhury kamil.choudhury at anserinae.net
Sat Dec 10 16:15:21 UTC 2011


Hi all:

I've been trying to figure out what's going on with this bug for a few days now:

http://docs.freebsd.org/cgi/getmsg.cgi?fetch=899628+0+current/freebsd-ports-bugs

Summary: you mount the virtualbox binaries to /usr/local/ via nullfs, and
execution fails with a syctl error.

I've figured out the bit of code that's causing the error, and I've
encapsulated it in the following (small) program:

#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <sys/param.h>
#include <sys/sysctl.h>

int main( void )
{
        char g_szSupLibHardenedExePath[5000];
        int aiName[4];
        aiName[0] = CTL_KERN;
        aiName[1] = KERN_PROC;
        aiName[2] = KERN_PROC_PATHNAME;
        aiName[3] = getpid();

        size_t cbPath = sizeof( g_szSupLibHardenedExePath );
        printf( "%d\n", cbPath );
        if(sysctl(aiName, 4, g_szSupLibHardenedExePath, &cbPath, NULL, 0) < 0)
                printf( "sysctl failed" );
        else
                printf( "sysctl succeeded" );

        return( 0 );
}

Here's where it gets weird: if the code is executed in in
/usr/local/lib/virtualbox, it fails with the sysctl error. If the code is
executed in another location on the *same* nullfs mount (say,
/usr/local/bin/), it executes fine.

There seems to be a something at a filesystem level that's preventing
execution -- does anyone on the list know what that something may be?

Thanks,
Kamil



More information about the freebsd-fs mailing list