Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 21 May 2017 16:03:55 +0200
From:      Jilles Tjoelker <jilles@stack.nl>
To:        Konstantin Belousov <kostikbel@gmail.com>
Cc:        freebsd-current@freebsd.org, freebsd-fs@freebsd.org, freebsd-ports@freebsd.org, emaste@freebsd.org, Kirk McKusick <mckusick@mckusick.com>
Subject:   Re: 64-bit inodes (ino64) Status Update and Call for Testing
Message-ID:  <20170521140355.GC21613@stack.nl>
In-Reply-To: <20170521123118.GH1622@kib.kiev.ua>
References:  <20170420194314.GI1788@kib.kiev.ua> <20170521121456.GA21613@stack.nl> <20170521123118.GH1622@kib.kiev.ua>

next in thread | previous in thread | raw e-mail | index | archive | help
On Sun, May 21, 2017 at 03:31:18PM +0300, Konstantin Belousov wrote:
> On Sun, May 21, 2017 at 02:14:56PM +0200, Jilles Tjoelker wrote:
> > We have another type in this area which is too small in some situations:
> > uint8_t for struct dirent.d_namlen. For filesystems that store filenames
> > as upto 255 UTF-16 code units, the name to be stored in d_name may be
> > upto 765 bytes long in UTF-8. This was reported in PR 204643. The code
> > currently handles this by returning the short (8.3) name, but this name
> > may not be present or usable, leaving the file inaccessible.

> > Actually allowing longer names seems too complicated to add to the ino64
> > change, but changing d_namlen to uint16_t (using d_pad0 space) and
> > skipping entries with d_namlen > 255 in libc may be helpful.

> > Note that applications using the deprecated readdir_r() will not be able
> > to read such long names, since the API does not allow specifying that a
> > larger buffer has been provided. (This could be avoided by making struct
> > dirent.d_name 766 bytes long instead of 256.)

> > Unfortunately, the existence of readdir_r() also prevents changing
> > struct dirent.d_name to the more correct flexible array.

> Yes, changing the size of d_name at this stage of the project is out of
> question. My reading of your proposal is that we should extend the size
> of d_namlen to uint16_t, am I right ? Should we go to 32bit directly
> then, perhaps ?

Yes, my proposal is to change d_namlen to uint16_t.

Making it 32 bits is not useful with the 16-bit d_reclen, and increasing
d_reclen does not seem useful to me with the current model of
getdirentries() where the whole dirent must fit into the caller's
buffer.

> I did not committed the change below, nor did I tested or even build it.

I'd like to skip overlong names in the native readdir_r() as well, so
that long name support can be added to the kernel later without causing
buffer overflows with applications using FreeBSD 12.0 libc.

The native readdir() does not seem to have such a problem.

> [patch snipped]

-- 
Jilles Tjoelker



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20170521140355.GC21613>