kern/161481: mount fails with ENAMETOOLONG with path shorter than 255 // 1023 characters

Garrett Cooper yanegomi at gmail.com
Tue Oct 11 07:40:02 UTC 2011


>Number:         161481
>Category:       kern
>Synopsis:       mount fails with ENAMETOOLONG with path shorter than 255 // 1023 characters
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Tue Oct 11 07:40:01 UTC 2011
>Closed-Date:
>Last-Modified:
>Originator:     Garrett Cooper
>Release:        10-CURRENT
>Organization:
n/a
>Environment:
FreeBSD fallout.local 10.0-CURRENT FreeBSD 10.0-CURRENT #2 r226242M: Mon Oct 10 20:50:51 PDT 2011     gcooper at fallout.local:/usr/obj/usr/src/sys/FALLOUT  amd64
>Description:
mount(2) claims that it should fail with ENAMETOOLONG if the path is <= 255 or 1023 characters:

     [ENAMETOOLONG]     A component of a pathname exceeded 255 characters, or
                        the entire length of a path name exceeded 1023 charac-
                        ters.

In practice, that isn't true:

# mount -t nullfs -o noatime /nfs/scratch/freenas-2/freenas/projects/freenas8-plugins/obj.amd64/ports/distfiles /nfs/scratch/freenas-2/freenas/projects/freenas8-plugins/obj.amd64/_.w/usr/ports/distfiles
mount_nullfs: File name too long
# echo mount -t nullfs -o noatime /nfs/scratch/freenas-2/freenas/projects/freenas8-plugins/obj.amd64/ports/distfiles/ /nfs/scratch/freenas-2/freenas/projects/freenas8-plugins/obj.amd64/_.w/usr/ports/distfiles | awk '{ print length($(NF - 1)), length($NF) }'
83 90
#

It's failing a bounds check in nmount and its callees. I've seen this issue with both nullfs and UFS, so it's most likely a problem in vfs_mount.c, etc.

I've seen this issue on 8.2-RELEASE (FreeNAS), as well as 9-CURRENT and 10-CURRENT.
>How-To-Repeat:
#!/bin/sh

set -e

mkdir -p /nfs/scratch/freenas-2/freenas/projects/freenas8-plugins/obj.amd64/_.w/usr/ports/distfiles/
md=$(mdconfig -a -t swap -s 512m)
newfs /dev/$md
mount /dev/$md /nfs/scratch/freenas-2/freenas/projects/freenas8-plugins/obj.amd64/_.w/usr/ports/distfiles/
>Fix:


>Release-Note:
>Audit-Trail:
>Unformatted:


More information about the freebsd-bugs mailing list