Skip to contentSkip to conversation

9pfs-local: open2() deletes existing data?

Qemu-devel Michael Tokarev 2 participants 2 messages Mar 4, 2015 – Mar 5, 2015

lore
Share & tools
lore
#0 lore raw

I was looking at various interesting functions in hw/9pfs/virtio-9p-local.c and noticed local_open2() which basically tries to open a file in a filesystem, and if that is successful, it tries to set file credentials using a configured mechanism, and if that fails, it deletes the file.

Now I wonder what happens if we tried to open an existing file but was not able to set credentials for whatever reason -- eg, because the underlying filesystem does not support xattrs, or whatever. It looks to me that we will remove the user file!

If that's the case, it looks like it is a very serious bug...

Thanks,

/mjt

#1 lore raw
Quoted 11 lines · Michael Tokarev

I was looking at various interesting functions in hw/9pfs/virtio-9p-local.c and noticed local_open2() which basically tries to open a file in a filesystem, and if that is successful, it tries to set file credentials using a configured mechanism, and if that fails, it deletes the file.

Now I wonder what happens if we tried to open an existing file but was not able to set credentials for whatever reason -- eg, because the underlying filesystem does not support xattrs, or whatever. It looks to me that we will remove the user file!

If that's the case, it looks like it is a very serious bug...

That callback is used for create. What is used for open is local_open()

-aneesh