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: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Date:	Tue, 13 Oct 2009 21:11:37 +0000
From:	Frederik Deweerdt <frederik.deweerdt@...og.eu>
To:	Glauber Costa <glommer@...hat.com>
Cc:	kvm@...r.kernel.org, linux-kernel@...r.kernel.org, avi@...hat.com
Subject: Re: [PATCH] v3: allow userspace to adjust kvmclock offset

On Tue, Oct 13, 2009 at 04:55:05PM -0400, Glauber Costa wrote:
> +	case KVM_SET_CLOCK: {
> +		struct timespec now;
> +		struct kvm_clock_data user_ns;
> +		u64 now_ns;
> +		long delta;
		^^^^
Should'nt that read s64? I guess such a large value won't happen in
practice, but the 32bits case would truncate the value differently in
the substraction below.

Regards,
Frederik
> +
> +		r =  -EFAULT;
> +		if (copy_from_user(&user_ns, argp, sizeof(user_ns)))
> +			goto out;
> +
> +		r = 0;
> +		ktime_get_ts(&now);
> +		now_ns = timespec_to_ns(&now);
> +		delta = user_ns.clock - now_ns;
> +		kvm->arch.kvmclock_offset = delta;
> +		break;	
> +	}
> +	case KVM_GET_CLOCK: {
> +		struct timespec now;
> +		struct kvm_clock_data user_ns;
> +		u64 now_ns;
> +
> +		ktime_get_ts(&now);
> +		now_ns = timespec_to_ns(&now);
> +		user_ns.clock = kvm->arch.kvmclock_offset + now_ns;
> +
> +		if (copy_to_user(argp, &user_ns, sizeof(user_ns)))
> +			r =  -EFAULT;
> +
> +		break;	
> +	}
> +
>  	default:
>  		;
>  	}
> diff --git a/include/linux/kvm.h b/include/linux/kvm.h
> index f8f8900..ad0ecbc 100644
> --- a/include/linux/kvm.h
> +++ b/include/linux/kvm.h
> @@ -497,6 +497,11 @@ struct kvm_irqfd {
>  	__u8  pad[20];
>  };
>  
> +struct kvm_clock_data {
> +	__u64 clock;
> +	__u64 pad[2];
> +};
> +
>  /*
>   * ioctls for VM fds
>   */
> @@ -546,6 +551,8 @@ struct kvm_irqfd {
>  #define KVM_CREATE_PIT2		   _IOW(KVMIO, 0x77, struct kvm_pit_config)
>  #define KVM_SET_BOOT_CPU_ID        _IO(KVMIO, 0x78)
>  #define KVM_IOEVENTFD             _IOW(KVMIO, 0x79, struct kvm_ioeventfd)
> +#define KVM_SET_CLOCK		  _IOW(KVMIO, 0x7a, struct kvm_clock_data)
> +#define KVM_GET_CLOCK		  _IOW(KVMIO, 0x7b, struct kvm_clock_data)
>  
>  /*
>   * ioctls for vcpu fds
> -- 
> 1.6.2.2
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@...r.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ