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

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


  • To: Jan Beulich <jbeulich@xxxxxxxx>
  • From: Bertrand Marquis <Bertrand.Marquis@xxxxxxx>
  • Date: Fri, 10 Dec 2021 13:50:47 +0000
  • Accept-language: en-GB, en-US
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=arm.com; dmarc=pass action=none header.from=arm.com; dkim=pass header.d=arm.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=Wv8keQ3kUpPKIGej8rfrMI7eQyQ5bUkDwjnga82nFEY=; b=ZNhfUEsDFgRdl1DC067pHLfYX99vdQ+1PUiqDgz8boVwezJneeMpHd9geRem1ZOZyVRUG/+XBxlWbKbqXqZNOkh30QO/TBrRucTspdM1KybFgH1gyfu6WKZsiRydHKj8+Np9CRGDzGi8KXsie/EWllkeBPkML0zEoerxpinPqzipSDhqlGveXdvuIBFnmbS/8BpXPzzf+2jKgjgVMawYkpl5smL5kEBVl5BwXMVlGiPykhBURkUuaiGGKvoEa0IH1KaAB4VNxGH/yC1gnuFgjhoaXRMyq2zJn8f0DuER0APnFCzxu7qJASErYFqw9/+KC2G/XwWK+5UWcc3vDcfogA==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=VdtKy3QcXWtv+9v0oiEA7MX8/nY93/9WmBpM01GB6IEQDXZVNP5UmPUAEQWQ9zh6j0TsLTz9wD+PlW+t9EUQgp5plmj7ZGDeUe2GJBthqS3FDeHzuYVv6hFM+8kBFaIoYtp4vWh+DVSLdXj9/N/WBA8UjNk6r0Ux4QH9Ba6kHEsH/JaBjCbFJv1InAhSpnD4QP0wKQ9ohLTMUeBZsTNe1f0T8I8kJbAOvwoYHClgojgFSxLSnVjITYIAD0ee5bVnLsAmslOvAtkgG2cTEyCfX7vteDN8J9tyZeEyTx1f9LLxoy/D1pliLoVxl8SZtw0tVkIiV8iwieLRbSta3iAhXw==
  • Authentication-results-original: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com;
  • Cc: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, Anthony Perard <anthony.perard@xxxxxxxxxx>, Juergen Gross <jgross@xxxxxxxx>
  • Delivery-date: Fri, 10 Dec 2021 13:51:17 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Nodisclaimer: true
  • Original-authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com;
  • Thread-index: AQHX7ceTNtjLavE+e0K+in6YCJvpZawrvk0A
  • Thread-topic: [PATCH v2] libxc: avoid clobbering errno in xc_domain_pod_target()

Hi Jan

> On 10 Dec 2021, at 13:11, Jan Beulich <jbeulich@xxxxxxxx> 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). There's
> also no reason to overwrite "err".
> 
> Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>
Reviewed-by: Bertrand Marquis <bertrand.marquis@xxxxxxx>

But if err can really only be 0 or -1, I do wonder if the else forcing err to 0 
could
be removed but I must say I have no idea if do_memory_op could return a value 
>0.

Anyway not related to the patch itself.

Cheers
Bertrand

> ---
> 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, and hence its setting to zero may also be
> worthwhile to drop.
> ---
> v2: Don't save/restore errno, as DPRINTF() already does so.
> 
> --- a/tools/libs/ctrl/xc_domain.c
> +++ b/tools/libs/ctrl/xc_domain.c
> @@ -1230,13 +1230,9 @@ static int xc_domain_pod_target(xc_inter
>     err = do_memory_op(xch, op, &pod_target, sizeof(pod_target));
> 
>     if ( err < 0 )
> -    {
>         DPRINTF("Failed %s_pod_target dom %d\n",
>                 (op==XENMEM_set_pod_target)?"set":"get",
>                 domid);
> -        errno = -err;
> -        err = -1;
> -    }
>     else
>         err = 0;
> 
> 
> 




 


Rackspace

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