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

[xen master] xen/rangeset: fix incorrect subtraction



commit e118fc98e7ae652a188d227bd7ea22f132724150
Author:     Roger Pau Monne <roger.pau@xxxxxxxxxx>
AuthorDate: Wed Apr 2 18:50:46 2025 +0200
Commit:     Roger Pau Monne <roger.pau@xxxxxxxxxx>
CommitDate: Fri Apr 11 12:20:10 2025 +0200

    xen/rangeset: fix incorrect subtraction
    
    Given the following rangset operation:
    
    { [0, 1], [4, 5] } - { [3, 4] }
    
    The current rangeset logic will output a rangeset:
    
    { [0, 2], [5, 5] }
    
    This is incorrect, and also has the undesirable property of being bogus in
    a way that the resulting rangeset is expanded.
    
    Fix this by making sure the bounds are correctly checked before modifying
    the previous range.
    
    Fixes: 484a058c4828 ('Add auto-destructing per-domain rangeset data 
structure...')
    Signed-off-by: Roger Pau Monné <roger.pau@xxxxxxxxxx>
    Reviewed-by: Jan Beulich <jbeulich@xxxxxxxx>
---
 xen/common/rangeset.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/xen/common/rangeset.c b/xen/common/rangeset.c
index b75590f907..e758710390 100644
--- a/xen/common/rangeset.c
+++ b/xen/common/rangeset.c
@@ -227,7 +227,8 @@ int rangeset_remove_range(
 
         if ( x->s < s )
         {
-            x->e = s - 1;
+            if ( x->e >= s )
+                x->e = s - 1;
             x = next_range(r, x);
         }
 
--
generated by git-patchbot for /home/xen/git/xen.git#master



 


Rackspace

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