mount_nfs does not like exports longer then 88 chars

Mark Saad nonesuch at longcount.org
Fri Apr 20 03:27:28 UTC 2012



On Apr 19, 2012, at 8:58 PM, Rick Macklem <rmacklem at uoguelph.ca> wrote:

> Mark Saad wrote:
>> On Thu, Apr 19, 2012 at 3:51 PM, Andrew Duane <aduane at juniper.net>
>> wrote:
>>> MNAMELEN is used to bound the Mount NAMe LENgth, and is used in many
>>> many places. It may seem to work fine, but there are lots of
>>> utilities and such that will almost certainly fail managing it.
>>> Search the source code for MNAMELEN.....
>> 
>> I see that this is used in a number of Mount and fs bits. Do you know
>> why mount_nfs would care how long the exported path and hostname are ?
>> 
> Well, it's copied to f_mntfromname in "struct statfs". If one longer
> than MNAMELEN is allowed, it gets truncated when copied. I have no idea
> which userland apps. will get upset with a truncated value in
> f_mntfromname. (To change the size of f_mntfromname would require a new
> revision of the statfs syscall, I think?)
> 
> Does this answer what you were asking? rick
> 


Yes and no, it smells like a bug ,in so far as its not mentioned anywhere out there . A one line addition to mount_nfs man page stipulating that there is a known limit on the length of the host name and source export would be helpful.  

On the other hand 88 bytes seams like an odd size to me .  The check for the size happens twice in the 7-stable code ,for mount_nfs, and only once in the 9-stable code  . Not sure why either, and i did bot research it yet. In the mean time I am going to take a peak at the other bsd's and see if there is a solution . 



>>> 
>>>  ...................................
>>> Andrew Duane
>>> Juniper Networks
>>> +1 978-589-0551 (o)
>>> +1 603-770-7088 (m)
>>> aduane at juniper.net
>>> 
>>> 
>>> 
>>> 
>>>> -----Original Message-----
>>>> From: owner-freebsd-hackers at freebsd.org [mailto:owner-freebsd-
>>>> hackers at freebsd.org] On Behalf Of Mark Saad
>>>> Sent: Thursday, April 19, 2012 3:46 PM
>>>> To: freebsd-hackers at freebsd.org
>>>> Subject: mount_nfs does not like exports longer then 88 chars
>>>> 
>>>> Hello Hackers
>>>>   I was wondering if anyone has come across this issue. This exists
>>>>   in
>>>> FreeBSD 6, 7, and 9 , and probably in 8 but I am not using it at
>>>> this time.
>>>> When a nfs export path and host name total to more then 88
>>>> characters
>>>> mount_nfs bombs out with the following error when it attempts to
>>>> mount it.
>>>> 
>>>> mount_nfs:
>>>> nyisilon2-13.grp2:/ifs/clients/www/csar884520456/files_cms-
>>>> stage-BK/imagefield_default_images:
>>>> File name too long
>>>> 
>>>> I traced this down to a check in mount_nfs.c . This is about line
>>>> 560
>>>> in the 7-STABLE version and 734 in the 9-STABLE version
>>>> 
>>>> 
>>>>         /*
>>>>          * If there has been a trailing slash at mounttime it seems
>>>>          * that some mountd implementations fail to remove the
>>>>          mount
>>>>          * entries from their mountlist while unmounting.
>>>>          */
>>>>         for (speclen = strlen(spec);
>>>>                 speclen > 1 && spec[speclen - 1] == '/';
>>>>                 speclen--)
>>>>                 spec[speclen - 1] = '\0';
>>>>         if (strlen(hostp) + strlen(spec) + 1 > MNAMELEN) {
>>>>                 warnx("%s:%s: %s", hostp, spec,
>>>>                 strerror(ENAMETOOLONG));
>>>>                 return (0);
>>>>         }
>>>> 
>>>> Does any one know why the check for hostp + spec +1 to be less then
>>>> MNAMELEN is there for ?
>>>> 
>>>>  I removed the check on my 9-STABLE box and it mounts the long
>>>>  mounts fine
>>>> 
>>>> I submitted a pr for this its kern/167105
>>>> http://www.freebsd.org/cgi/query-pr.cgi?pr=167105 as there is no
>>>> mention of this in the man page and I cant find any reason for the
>>>> check at all.
>>>> 
>>>> 
>>>> --
>>>> mark saad | nonesuch at longcount.org
>>>> _______________________________________________
>>>> freebsd-hackers at freebsd.org mailing list
>>>> http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
>>>> To unsubscribe, send any mail to "freebsd-hackers-
>>>> unsubscribe at freebsd.org"
>> 
>> 
>> 
>> --
>> mark saad | nonesuch at longcount.org
>> _______________________________________________
>> freebsd-hackers at freebsd.org mailing list
>> http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
>> To unsubscribe, send any mail to
>> "freebsd-hackers-unsubscribe at freebsd.org"


More information about the freebsd-hackers mailing list