[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH] libxc: avoid clobbering errno in xc_domain_pod_target()
- To: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
- From: Jan Beulich <jbeulich@xxxxxxxx>
- Date: Thu, 9 Dec 2021 11:26:35 +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=Ktr193pS08mX1sljE5M2Ea+ogUG4Xlq9xwDI7AlWsFI=; b=ayVp0oLd2XCSx1hR+c38uLTCrVljHY7cs1y7LDkDNdX9KvUia3lo+ItK3qUWIYdMZdTjYq7LZivc1qclz8Ii4IvzDATfOmdE80QNTk+gG0tv5CfAS/rlxnjJLd5DxgPXaVo3g9394Ak1igNxj14yIVGybXpOL30UifpibjP2yqrQl4bCIRnZn2D6/oJDwnDiDHBoNJX/5TOQ/kfBFIKl53ivEj6BPSe3zRS/jtx5Td3V+y7B+afT/XlGj9MSzXHN24ohPcWkCm9yvUS2/eWX5HbFvz5H0N02lCsOC8gw6JuQ4zNdT51bdqcrGwjb7nQ0QpaSq7t8LldZ/eB5i2N4tA==
- Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=XIozplYWqsEfD/ZPkksusTqqpOF6A/QVPaj5OM6CgIq9ZMsRgESIPCLR6QL5bZMTvgsZZOZmXVvjy4x69jSzqLqXSaa0GbGgvBrdwcIVLzDz0uRPR96XNErnTbm0v8FCZJzwDrm/EQnrAxqu/9wwnHA5JMYQnLMNNXG2K9vcz1r0DusiWYMrFUccsJHxR1uYudGF1zU9BMpEVNVMpinyyWIOC6EEufHbvczyzapLSxY3EZFazUJ4RsrjJDkMBlVLz40HyptzoZodT+UYytlC5FWqxyXgLtlfArZThddv0WUYCgmloGSILbyC2EtItQxd1s7hhH5nfwgP+BgnMheb+Q==
- 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>, Juergen Gross <jgross@xxxxxxxx>
- Delivery-date: Thu, 09 Dec 2021 10:26:54 +0000
- List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
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;
err = -1;
}
else
|