qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH] hw/9pfs: Add CephFS support in VirtFS


From: Eric Blake
Subject: Re: [Qemu-devel] [PATCH] hw/9pfs: Add CephFS support in VirtFS
Date: Wed, 9 Mar 2016 13:09:58 -0700
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.6.0

On 03/09/2016 12:02 PM, Greg Kurz wrote:
> On Wed,  2 Mar 2016 23:41:43 +0800
> Jevon Qiao <address@hidden> wrote:
> 

>> +}
>> +
>> +static int cephfs_readdir_r(FsContext *ctx, V9fsFidOpenState *fs,
>> +                            struct dirent *entry,
>> +                            struct dirent **result)
>> +{
>> +    int ret;

>> +    
>> +    return ret;
> 
> This function should behave like the original readdir_r() function from the
> C library, but it doesn't.
> 

readdir_r() is hopelessly broken.  POSIX is withdrawing it as such.
http://austingroupbugs.net/view.php?id=696

readdir() should be all the more any sane program needs, because it
should already be thread-safe.

> According to the the libcephfs.h header:
> 
>  * @returns 1 if the next entry was filled in, 0 if the end of the directory 
> stream was reached,
>  *          and a negative error code on failure.
>  */
> int ceph_readdir_r(struct ceph_mount_info *cmount, struct ceph_dir_result 
> *dirp, struct dirent *de);
> 
> and the readdir_r() manual page says:
> 
>    The  readdir_r() function returns 0 on success.  On error, it returns a
>    positive error number (listed under ERRORS).  If the end of the  direcā€
>    tory  stream  is  reached,  readdir_r()  returns 0, and returns NULL in
>    *result.

readdir_r() can silently overflow buffers, with no recourse.  Its use
should not be encouraged.

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]