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

[Xen-changelog] [qemu-xen master] 9pfs: check the size of transport buffer before marshaling



commit a83858fdb57e91945f2ea95f7ec31b89ccfd46ca
Author:     Jan Dakinevich <jan.dakinevich@xxxxxxxxx>
AuthorDate: Wed Sep 20 08:48:52 2017 +0200
Commit:     Michael Roth <mdroth@xxxxxxxxxxxxxxxxxx>
CommitDate: Fri Sep 22 18:23:16 2017 -0500

    9pfs: check the size of transport buffer before marshaling
    
    v9fs_do_readdir_with_stat() should check for a maximum buffer size
    before an attempt to marshal gathered data. Otherwise, buffers assumed
    as misconfigured and the transport would be broken.
    
    The patch brings v9fs_do_readdir_with_stat() in conformity with
    v9fs_do_readdir() behavior.
    
    Signed-off-by: Jan Dakinevich <jan.dakinevich@xxxxxxxxx>
    [groug, regression caused my commit 8d37de41cab1 # 2.10]
    Signed-off-by: Greg Kurz <groug@xxxxxxxx>
    
    (cherry picked from commit 772a73692ecb52bace0cff6f95df62f59b8cabe0)
    Signed-off-by: Michael Roth <mdroth@xxxxxxxxxxxxxxxxxx>
---
 hw/9pfs/9p.c | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)

diff --git a/hw/9pfs/9p.c b/hw/9pfs/9p.c
index db9ec59..8e9490c 100644
--- a/hw/9pfs/9p.c
+++ b/hw/9pfs/9p.c
@@ -1750,17 +1750,26 @@ static int coroutine_fn 
v9fs_do_readdir_with_stat(V9fsPDU *pdu,
         if (err < 0) {
             break;
         }
+        if ((count + v9stat.size + 2) > max_count) {
+            v9fs_readdir_unlock(&fidp->fs.dir);
+
+            /* Ran out of buffer. Set dir back to old position and return */
+            v9fs_co_seekdir(pdu, fidp, saved_dir_pos);
+            v9fs_stat_free(&v9stat);
+            v9fs_path_free(&path);
+            return count;
+        }
+
         /* 11 = 7 + 4 (7 = start offset, 4 = space for storing count) */
         len = pdu_marshal(pdu, 11 + count, "S", &v9stat);
 
         v9fs_readdir_unlock(&fidp->fs.dir);
 
-        if ((len != (v9stat.size + 2)) || ((count + len) > max_count)) {
-            /* Ran out of buffer. Set dir back to old position and return */
+        if (len < 0) {
             v9fs_co_seekdir(pdu, fidp, saved_dir_pos);
             v9fs_stat_free(&v9stat);
             v9fs_path_free(&path);
-            return count;
+            return len;
         }
         count += len;
         v9fs_stat_free(&v9stat);
--
generated by git-patchbot for /home/xen/git/qemu-xen.git#master

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxx
https://lists.xenproject.org/xen-changelog

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.