lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <86a9f7f1-1b6d-5c89-2bb5-a6fa2833fdce@suse.com>
Date:   Tue, 12 Jan 2021 07:01:03 +0100
From:   Jürgen Groß <jgross@...e.com>
To:     Andrew Cooper <amc96@....ac.uk>, boris.ostrovsky@...cle.com,
        Roger Pau Monne <roger.pau@...rix.com>,
        linux-kernel@...r.kernel.org
Cc:     Stefano Stabellini <sstabellini@...nel.org>,
        Paul Durrant <paul.durrant@...rix.com>,
        xen-devel@...ts.xenproject.org,
        Andrew Cooper <andrew.cooper3@...rix.com>
Subject: Re: [PATCH] xen/privcmd: allow fetching resource sizes

On 12.01.21 06:50, Jürgen Groß wrote:
> On 11.01.21 23:39, Andrew Cooper wrote:
>> On 11/01/2021 22:09, boris.ostrovsky@...cle.com wrote:
>>> On 1/11/21 10:29 AM, Roger Pau Monne wrote:
>>>> +    xdata.domid = kdata.dom;
>>>> +    xdata.type = kdata.type;
>>>> +    xdata.id = kdata.id;
>>>> +
>>>> +    if (!kdata.addr && !kdata.num) {
>>>
>>> I think we should not allow only one of them to be zero. If it's only 
>>> kdata.num then we will end up with pfns array set to ZERO_SIZE_PTR 
>>> (which is 0x10). We seem to be OK in that we are not derefencing pfns 
>>> (either in kernel or in hypervisor) if number of frames is zero but 
>>> IMO we shouldn't be tempting the fate.
>>>
>>>
>>> (And if it's only kdata.addr then we will get a vma but I am not sure 
>>> it will do what we want.)
>>
>> Passing addr == 0 without num being 0 is already an error in Xen, and
>> passing num == 0 without addr being 0 is bogus and will be an error by
>> the time I'm finished fixing this.
>>
>> FWIW, the common usecase for non-trivial examples will be:
>>
>> xenforeignmem_resource_size(domid, type, id, &size);
>> xenforeignmem_map_resource(domid, type, id, NULL, size, ...);
>>
>> which translates into:
>>
>> ioctl(MAP_RESOURCE, NULL, 0) => size
>> mmap(NULL, size, ...) => ptr
>> ioctl(MAP_RESOURCE, ptr, size)
>>
>> from the kernels point of view, and two hypercalls from Xen's point of
>> view.  The NULL's above are expected to be the common case for letting
>> the kernel chose the vma, but ought to be filled in by the time the
>> second ioctl() occurs.
>>
>> See
>> https://lore.kernel.org/xen-devel/20200922182444.12350-1-andrew.cooper3@citrix.com/T/#u 
>>
>> for all the gory details.
> 
> I don't think the kernel should rely on the hypervisor to return
> an error in case addr != 0 and num == 0.
> 
> The driver should return -EINVAL in that case IMO.

And additionally I think the kernel should check num to be not too
large (in the interface it is u64, while intermediate values are
stored in unsigned int), limiting it to something below INT_MAX
seems to be sensible.


Juergen

Download attachment "OpenPGP_0xB0DE9DD628BF132F.asc" of type "application/pgp-keys" (3092 bytes)

Download attachment "OpenPGP_signature" of type "application/pgp-signature" (496 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ