bin/153600: Path length restrictions in mount/umount tools prevent filesystem mount/unmount

Roger Leigh rleigh at debian.org
Sat Jan 1 18:54:08 UTC 2011


On Sun, Jan 02, 2011 at 05:13:16AM +1100, Bruce Evans wrote:
> On Sat, 1 Jan 2011, Roger Leigh wrote:
>
>> t at mason.cse.buffalo.edu:/usr/obj/usr/src/sys/GENERIC  amd64
>>> Description:
>> When mount is asked to mount a filesystem on a node whose absolute path is longer than 85 characters in length, the mount fails.  Umount also fails under some circumstances, though the testcase attached below doesn't show this.
>> ...
>>> Fix:
>> I suspect that the mount/umount tools are using a fixed-length buffer and/or are truncating the path at some point.
>>
>> The mount(2) manual page documents the max path length at 1023 characters, and the maximum length of any single component at 255 characters.  These limits have not been exceeded, unless the documentation is incorrect.
>>
>> The practical upper limit of 80-85 characters demonstrated in this bug report is very low.  The documented [ENAMETOOLONG] limit in mount(2) is sensible, but does not appear to reflect the practical reality at the present time.  If the 80-85 character limit could be eliminated to allow this to work as documented, this would remove a significant limitation in the FreeBSD system which is breaking software which requires longer paths to function.
>
> Mount name lengths are in practice limited to (MNAMELEN - 1) = 87.  See
> <sys/mount.h>.  This isn't easy to fix, since MNAMELEN is in critical APIs
> (mainly struct statfs).  struct statfs has already been changed once too
> often.  MNAMELEN used to be (80 - 2 * sizeof(long)), which is 80 or 72,
> but was changed to 88.  MNAMELEN is of course mentioned in statfs(2), but
> it isn't mentioned in mount(2) because it doesn't apply to the actual mount
> operation but only to determining what is mounted using statfs(2).  The
> buffer gets truncated at mount time by mount in the kernel copying the
> file name to the statfs buffer with blind truncation.
>
> In practice, this means that you should never use the feature of mounting
> pathnames with length between MNAMELEN and (PATH_MAX - 1), since it is too
> hard to manage the resulting mountpoints.

I see, thanks.  This does make things somewhat more complex to fix.

As a longer term (rather than immediate) solution, could I suggest
taking a look at the GNU libc/linux versions of the statfs structure in
<bits/statfs.h>?  In this version, the fixed-length fields are entirely
absent, and so the length limitations are a non-issue here.  Of course,
the structures are not compatible, and the missing information would
need to be obtained via other means such as getmntent of /proc/mounts
(for example).  But, the getmntent interface is also equally
unrestricted, so in practice on GNU/Linux this problem does not exist.


Kind regards,
Roger

-- 
  .''`.  Roger Leigh
 : :' :  Debian GNU/Linux             http://people.debian.org/~rleigh/
 `. `'   Printing on GNU/Linux?       http://gutenprint.sourceforge.net/
   `-    GPG Public Key: 0x25BFB848   Please GPG sign your mail.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: Digital signature
Url : http://lists.freebsd.org/pipermail/freebsd-bugs/attachments/20110101/376a9b58/attachment.pgp


More information about the freebsd-bugs mailing list