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] [thread-next>] [day] [month] [year] [list]
Message-ID: <20100210112822.GB4546@redhat.com>
Date:	Wed, 10 Feb 2010 12:28:22 +0100
From:	Oleg Nesterov <oleg@...hat.com>
To:	Suresh Siddha <suresh.b.siddha@...el.com>
Cc:	Roland McGrath <roland@...hat.com>,
	"H. Peter Anvin" <hpa@...or.com>, Ingo Molnar <mingo@...e.hu>,
	Thomas Gleixner <tglx@...utronix.de>,
	LKML <linux-kernel@...r.kernel.org>, hjl.tools@...il.com
Subject: Re: [patch v2 2/4] x86, ptrace: regset extensions to support xstate

On 02/09, Suresh Siddha wrote:
>
> +int xstateregs_get(struct task_struct *target, const struct user_regset *regset,
> +		unsigned int pos, unsigned int count,
> +		void *kbuf, void __user *ubuf)
> +{
> +	int ret;
> +	int size = regset->n * regset->size;
> +	struct xsave_hdr_struct *xsave_hdr =
> +				&target->thread.xstate->xsave.xsave_hdr;
> +
> +	if (!cpu_has_xsave)
> +		return -ENODEV;
> +
> +	ret = init_fpu(target);
> +	if (ret)
> +		return ret;
> +
> +	/*
> +	 * First copy the fxsave bytes 0..463
> +	 */
> +	ret = user_regset_copyout(&pos, &count, &kbuf, &ubuf,
> +				  &target->thread.xstate->xsave, 0,
> +				  offsetof(struct i387_fxsave_struct,
> +					   sw_reserved));
> +	if (!ret)
> +		/*
> +		 * Copy the 48bytes defined by software
> +		 */
> +		ret = user_regset_copyout(&pos, &count, &kbuf, &ubuf,
> +					  xstate_fx_sw_bytes,
> +					  offsetof(struct i387_fxsave_struct,
> +						   sw_reserved),
> +					  offsetof(struct xsave_struct,
> +						   xsave_hdr));

Hmm. Suresh, could you confirm these offsetof's are correct?

We are copying xstate_fx_sw_bytes array which is u64[6], but
start_pos == sizeof(i387_fxsave_struct) - padding ?

While we are here. Perhaps it would be more symmetrical to do

	ret = user_regset_copyout();
	if (ret)
		return ret;

instead of "if (!ret)" which needs a tab, but this is up to you.

> +	if (!ret)
> +		/*
> +		 * Copy the rest of xstate memory layout
> +		 */
> +		ret = user_regset_copyout(&pos, &count, &kbuf, &ubuf,
> +					  xsave_hdr,

Another very minor nit, this is the only user of xsave_hdr, but this
var was defined at the top. Perhaps it would be a bit more clean to
have

	struct xsave_struct *xsave = target->thread.xstate->xsave;

and use it in 1st and 3rd copyout?

Speaking about the first user_regset_copyout(), perhaps xsave->i387
would be more clear than xsave?

Oleg.

--
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