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

Re: [PATCH] libxc: avoid clobbering errno in xc_domain_pod_target()


  • To: Juergen Gross <jgross@xxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Thu, 9 Dec 2021 12:10:19 +0100
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=MuL3XblWkbbUMBp+0ZrcRlp+/YH9/eNJVINVaxU+nzk=; b=HRHg+e0Ord8w6As39Vv/zUe7MNIw6agB57Qg7hLLljfd/OARS8jMrZw1xjvCyLIeUx/NbQ6BeU8ubacO9b7Cqix18E54Ul0daMEOYA/Lsvbo43Q3CkLOD8u4pkrFA5JWnzI2FvU+Ht43X+c3Re341moNGddRrWsvkcrm9/GUiwsqEl1xxiekV79NJyJlbWmMN5Dys40AiA74LOFx9La6h/BG2Te7j+1k862oUFTfz1EAgRwbXEMqET8HrlPT76902NuFuqh5FQva4IZRLJ4N+02T6t0l9yJT41Ty+YJ77ghoFWS0BEkD6TK/YgTKUQSHmqv22+RCgAAc6UQQONFmig==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=UhIy1yG3ePpAP2QHB+3ujL4NeDK5PblpVJ4vSBeZXxgpCKCO6El6HccgYGsJ1IDnGeQX1DkUciiZGf7hbVTP6rff9dhZizm0FP1nnuitxHyIrIW4SN0GVYEFNs5NxIg2JmZlpgnfsn0BIsvo1JpOiEzV8PRq5lZHtEEHGz1hvoT67/DYbsGNp9OGz2O8jykRvCZPZJ9K1OfxSh4IJ4MYvDWNdlqppgw7qRf/FGelG0Y5PT+NGKgTRDbB0dqvSW8upKa2VIz3m3uhjGiBXWL1/o162FP1eNj/eOdKpAXimr+ohcBFBowzven1IMaWaQ1QlaCu1uRO8Z6IRbl8Ry3y8Q==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com;
  • Cc: Wei Liu <wl@xxxxxxx>, Anthony Perard <anthony.perard@xxxxxxxxxx>, "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • Delivery-date: Thu, 09 Dec 2021 11:11:12 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 09.12.2021 11:41, Juergen Gross wrote:
> On 09.12.21 11:36, Juergen Gross wrote:
>> On 09.12.21 11:26, Jan Beulich wrote:
>>> do_memory_op() supplies return value and has errno set the usual way.
>>> Don't overwrite errno with 1 (aka EPERM on at least Linux).
>>>
>>> Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>
>>> ---
>>> An alternative would be to let go of the DPRINTK() and leave errno and
>>> err alone altogether. While the hypervisor side of the hypercall gives
>>> the impression of being able to return positive values as of
>>> 637a283f17eb ("PoD: Allow pod_set_cache_target hypercall to be
>>> preempted"), due to the use of "rc >= 0" there, afaict that's not
>>> actually the case. IOW "err" can really only be 0 or -1 here.
>>>
>>> --- a/tools/libs/ctrl/xc_domain.c
>>> +++ b/tools/libs/ctrl/xc_domain.c
>>> @@ -1231,10 +1231,11 @@ static int xc_domain_pod_target(xc_inter
>>>       if ( err < 0 )
>>>       {
>>> +        err = errno;
>>>           DPRINTF("Failed %s_pod_target dom %d\n",
>>>                   (op==XENMEM_set_pod_target)?"set":"get",
>>>                   domid);
>>> -        errno = -err;
>>> +        errno = err;
>>
>> DPRINTF() won't change errno, so I think you should just drop the line
>> overwriting errno.
> 
> In fact you added the 3rd layer of errno saving here. :-)
> 
> DPRINTF() and friends will save errno, and the underlying
> xc_report*() functions will do so, too.

I guess I should have checked ... Question is then whether setting
"err" to 0 on the "else" path could/should then also be dropped (its
setting to -1 clearly can be, and I already have it that way for v2).

Jan




 


Rackspace

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