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

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

 



On 03/09/2016 12:02 PM, Greg Kurz wrote:
> On Wed,  2 Mar 2016 23:41:43 +0800
> Jevon Qiao <scaleqiao@xxxxxxxxx> 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


[Index of Archives]     [CEPH Users]     [Ceph Large]     [Information on CEPH]     [Linux BTRFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]
  Powered by Linux