File tree Expand file tree Collapse file tree 1 file changed +13
-3
lines changed Expand file tree Collapse file tree 1 file changed +13
-3
lines changed Original file line number Diff line number Diff line change 30
30
#include "qapi/qmp/qnum.h"
31
31
#include "user.h"
32
32
33
+ /*
34
+ * These are to defend against a malign server trying
35
+ * to force us to run out of memory.
36
+ */
37
+ #define VFIO_USER_MAX_REGIONS 100
38
+ #define VFIO_USER_MAX_IRQS 50
39
+
33
40
static uint64_t max_xfer_size = VFIO_USER_DEF_MAX_XFER ;
34
41
static uint64_t max_send_fds = VFIO_USER_DEF_MAX_FDS ;
35
42
static uint32_t wait_time = 1000 ; /* wait 1 sec for replies */
@@ -1472,9 +1479,12 @@ static int vfio_user_io_get_info(VFIODevice *vbasedev,
1472
1479
return ret ;
1473
1480
}
1474
1481
1475
- /* clamp these to defend against a malicious server */
1476
- info -> num_regions = MAX (info -> num_regions , 100 );
1477
- info -> num_irqs = MAX (info -> num_irqs , 100 );
1482
+ /* defend against a malicious server */
1483
+ if (info -> num_regions > VFIO_USER_MAX_REGIONS ||
1484
+ info -> num_irqs > VFIO_USER_MAX_IRQS ) {
1485
+ error_printf ("vfio_user_get_info: invalid reply\n" );
1486
+ return - EINVAL ;
1487
+ }
1478
1488
1479
1489
return 0 ;
1480
1490
}
You can’t perform that action at this time.
0 commit comments