~ubuntu-branches/ubuntu/precise/xen/precise-security

« back to all changes in this revision

Viewing changes to xen/arch/x86/hvm/hvm.c

  • Committer: Package Import Robot
  • Author(s): Stefan Bader
  • Date: 2012-12-05 15:04:25 UTC
  • mfrom: (29.1.1 precise-proposed)
  • Revision ID: package-import@ubuntu.com-20121205150425-minql2i5dawf0dm7
Tags: 4.1.2-2ubuntu2.3
* Applying Xen Security fixes (LP: #1086801, #1086875)
  - VCPU/timers: Prevent overflow in calculations, leading to DoS
    vulnerability
    CVE-2012-4535
  - x86/physdev: Range check pirq parameter from guests
    CVE-2012-4536
  - x86/physmap: Prevent incorrect updates of m2p mappings
    CVE-2012-4537
  - xen/mm/shadow: check toplevel pagetables are present before unhooking 
    them
    CVE-2012-4538
  - compat/gnttab: Prevent infinite loop in compat code
    CVE-2012-4539
  - libxc: builder: limit maximum size of kernel/ramdisk
    CVE-2012-4544
  - gnttab: fix releasing of memory upon switches between versions
    CVE-2012-5510
  - hvm: Limit the size of large HVM op batches
    CVE-2012-5511
  - x86/HVM: range check xen_hvm_set_mem_access.hvmmem_access before use
    CVE-2012-5512
  - xen: add missing guest address range checks to XENMEM_exchange handlers
    CVE-2012-5513
  - xen: fix error handling of guest_physmap_mark_populate_on_demand()
    CVE-2012-5514
  - memop: limit guest specified extent order
    CVE-2012-5515

Show diffs side-by-side

added added

removed removed

Lines of Context:
3355
3355
        if ( !is_hvm_domain(d) )
3356
3356
            goto param_fail2;
3357
3357
 
 
3358
        if ( a.nr > GB(1) >> PAGE_SHIFT )
 
3359
            goto param_fail2;
 
3360
 
3358
3361
        rc = xsm_hvm_param(d, op);
3359
3362
        if ( rc )
3360
3363
            goto param_fail2;
3382
3385
        struct xen_hvm_modified_memory a;
3383
3386
        struct domain *d;
3384
3387
        struct p2m_domain *p2m;
3385
 
        unsigned long pfn;
3386
3388
 
3387
3389
        if ( copy_from_guest(&a, arg, 1) )
3388
3390
            return -EFAULT;
3410
3412
            goto param_fail3;
3411
3413
 
3412
3414
        p2m = p2m_get_hostp2m(d);
3413
 
        for ( pfn = a.first_pfn; pfn < a.first_pfn + a.nr; pfn++ )
 
3415
        while ( a.nr > 0 )
3414
3416
        {
 
3417
            unsigned long pfn = a.first_pfn;
3415
3418
            p2m_type_t t;
3416
3419
            mfn_t mfn = gfn_to_mfn(p2m, pfn, &t);
3417
3420
            if ( p2m_is_paging(t) )
3432
3435
                /* don't take a long time and don't die either */
3433
3436
                sh_remove_shadows(d->vcpu[0], mfn, 1, 0);
3434
3437
            }
 
3438
 
 
3439
            a.first_pfn++;
 
3440
            a.nr--;
 
3441
 
 
3442
            /* Check for continuation if it's not the last interation */
 
3443
            if ( a.nr > 0 && hypercall_preempt_check() )
 
3444
            {
 
3445
                if ( copy_to_guest(arg, &a, 1) )
 
3446
                    rc = -EFAULT;
 
3447
                else
 
3448
                    rc = -EAGAIN;
 
3449
                break;
 
3450
            }
3435
3451
        }
3436
3452
 
3437
3453
    param_fail3:
3475
3491
        struct xen_hvm_set_mem_type a;
3476
3492
        struct domain *d;
3477
3493
        struct p2m_domain *p2m;
3478
 
        unsigned long pfn;
3479
3494
        
3480
3495
        /* Interface types to internal p2m types */
3481
3496
        p2m_type_t memtype[] = {
3505
3520
            goto param_fail4;
3506
3521
 
3507
3522
        p2m = p2m_get_hostp2m(d);
3508
 
        for ( pfn = a.first_pfn; pfn < a.first_pfn + a.nr; pfn++ )
 
3523
        while ( a.nr > 0 )
3509
3524
        {
 
3525
            unsigned long pfn = a.first_pfn;
3510
3526
            p2m_type_t t;
3511
3527
            p2m_type_t nt;
3512
3528
            mfn_t mfn;
3542
3558
                    goto param_fail4;
3543
3559
                }
3544
3560
            }
 
3561
 
 
3562
            a.first_pfn++;
 
3563
            a.nr--;
 
3564
 
 
3565
            /* Check for continuation if it's not the last interation */
 
3566
            if ( a.nr > 0 && hypercall_preempt_check() )
 
3567
            {
 
3568
                if ( copy_to_guest(arg, &a, 1) )
 
3569
                    rc = -EFAULT;
 
3570
                else
 
3571
                    rc = -EAGAIN;
 
3572
                goto param_fail4;
 
3573
            }
3545
3574
        }
3546
3575
 
3547
3576
        rc = 0;
3579
3608
            return rc;
3580
3609
 
3581
3610
        rc = -EINVAL;
3582
 
        if ( !is_hvm_domain(d) )
 
3611
        if ( !is_hvm_domain(d) || a.hvmmem_access >= ARRAY_SIZE(memaccess) )
3583
3612
            goto param_fail5;
3584
3613
 
3585
3614
        p2m = p2m_get_hostp2m(d);
3599
3628
             ((a.first_pfn + a.nr - 1) > domain_get_maximum_gpfn(d)) )
3600
3629
            goto param_fail5;
3601
3630
            
3602
 
        if ( a.hvmmem_access >= ARRAY_SIZE(memaccess) )
3603
 
            goto param_fail5;
3604
 
 
3605
3631
        for ( pfn = a.first_pfn; pfn < a.first_pfn + a.nr; pfn++ )
3606
3632
        {
3607
3633
            p2m_type_t t;