Skip to contentSkip to conversation

block/vvfat: Fix crash when reporting error about too many files in directory

PATCH Applied Thomas Huth 2 participants 3 messages Jul 24, 2018 – Oct 4, 2018 Block layer

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 block/vvfat: Fix crash when reporting error about too many files in directory

When using the vvfat driver with a directory that contains too many files, QEMU currently crashes. This can be triggered like this for example:

mkdir /tmp/vvfattest
cd /tmp/vvfattest
for ((x=0;x<=513;x++)); do mkdir $x; done qemu-system-x86_64 -drive \
file.driver=vvfat,file.dir=.,read-only=on,media=cdrom

Seems like read_directory() is changing the mapping->path variable. Make sure we use the right pointer instead.

---
 block/vvfat.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
block/vvfat.c +2 -2
index fc41841..f2e7d50 100644
@@ -973,10 +973,10 @@ static int init_directories(BDRVVVFATState* s,
         mapping = array_get(&(s->mapping), i);
 
         if (mapping->mode & MODE_DIRECTORY) {
+            char *path = mapping->path;
             mapping->begin = cluster;
             if(read_directory(s, i)) {
-                error_setg(errp, "Could not read directory %s",
-                           mapping->path);
+                error_setg(errp, "Could not read directory %s", path);
                 return -1;
             }
             mapping = array_get(&(s->mapping), i);
Signature · 1 line
1.8.3.1
#1 lore raw
Quoted 25 lines · Thomas Huth

When using the vvfat driver with a directory that contains too many files, QEMU currently crashes. This can be triggered like this for example:

mkdir /tmp/vvfattest
cd /tmp/vvfattest
for ((x=0;x<=513;x++)); do mkdir $x; done qemu-system-x86_64 -drive \
file.driver=vvfat,file.dir=.,read-only=on,media=cdrom

Seems like read_directory() is changing the mapping->path variable. Make sure we use the right pointer instead.

---
 block/vvfat.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
block/vvfat.c +0 -0
index fc41841..f2e7d50 100644
@@ -973,10 +973,10 @@ static int init_directories(BDRVVVFATState* s,
         mapping = array_get(&(s->mapping), i);
 

block/vvfat.c static int init_directories(BDRVVVFATState* s, · line 982

Quoted 10 lines
block/vvfat.c +2 -2
         if (mapping->mode & MODE_DIRECTORY) {
+            char *path = mapping->path;
             mapping->begin = cluster;
             if(read_directory(s, i)) {
-                error_setg(errp, "Could not read directory %s",
-                           mapping->path);
+                error_setg(errp, "Could not read directory %s", path);
                 return -1;
             }
             mapping = array_get(&(s->mapping), i);

Ping?

Applied
#2 lore raw
In reply to Thomas Huth

Am 24.07.2018 um 13:52 hat Thomas Huth geschrieben:

Quoted 9 lines

When using the vvfat driver with a directory that contains too many files, QEMU currently crashes. This can be triggered like this for example:

mkdir /tmp/vvfattest
cd /tmp/vvfattest
for ((x=0;x<=513;x++)); do mkdir $x; done qemu-system-x86_64 -drive \
file.driver=vvfat,file.dir=.,read-only=on,media=cdrom

Quoted 4 lines

Seems like read_directory() is changing the mapping->path variable. Make sure we use the right pointer instead.

Thanks, applied to the block branch.

Kevin