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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <mhng-eba72823-400f-40a2-b76a-4132385840bd@palmerdabbelt-glaptop1>
Date:   Tue, 04 Aug 2020 19:01:02 -0700 (PDT)
From:   Palmer Dabbelt <palmer@...belt.com>
To:     macro@....com
CC:     linux-riscv@...ts.infradead.org,
        Paul Walmsley <paul.walmsley@...ive.com>,
        aou@...s.berkeley.edu, linux-kernel@...r.kernel.org
Subject:     Re: [PATCH 2/2] riscv: ptrace: Improve the style in NT_PRFPREG regset handling

On Thu, 23 Jul 2020 16:22:30 PDT (-0700), macro@....com wrote:
> Use an auxiliary variable for the size taken by floating point general
> registers in `struct __riscv_d_ext_state' to improve the readability of
> code in the `riscv_fpr_get' and `riscv_fpr_set' handlers, by avoiding
> excessive line wrapping and extending beyond 80 columns.  Also shuffle
> local variables in the reverse Christmas tree order.  No functional
> change.
>
> Signed-off-by: Maciej W. Rozycki <macro@....com>
> ---
>  arch/riscv/kernel/ptrace.c |   24 ++++++++++--------------
>  1 file changed, 10 insertions(+), 14 deletions(-)
>
> linux-riscv-ptrace-fpr-style.diff
> Index: linux-hv/arch/riscv/kernel/ptrace.c
> ===================================================================
> --- linux-hv.orig/arch/riscv/kernel/ptrace.c
> +++ linux-hv/arch/riscv/kernel/ptrace.c
> @@ -58,18 +58,16 @@ static int riscv_fpr_get(struct task_str
>  			 unsigned int pos, unsigned int count,
>  			 void *kbuf, void __user *ubuf)
>  {
> -	int ret;
> +	const size_t fgr_size = offsetof(struct __riscv_d_ext_state, fcsr);
>  	struct __riscv_d_ext_state *fstate = &target->thread.fstate;
> +	int ret;
>
>  	ret = user_regset_copyout(&pos, &count, &kbuf, &ubuf, &fstate->f, 0,
> -				  offsetof(struct __riscv_d_ext_state, fcsr));
> +				  fgr_size);
>  	if (!ret) {
>  		ret = user_regset_copyout(&pos, &count, &kbuf, &ubuf,
> -					  &fstate->fcsr,
> -					  offsetof(struct __riscv_d_ext_state,
> -						   fcsr),
> -					  offsetof(struct __riscv_d_ext_state, fcsr) +
> -					  sizeof(fstate->fcsr));
> +					  &fstate->fcsr, fgr_size,
> +					  fgr_size + sizeof(fstate->fcsr));
>  	}
>
>  	return ret;
> @@ -80,18 +78,16 @@ static int riscv_fpr_set(struct task_str
>  			 unsigned int pos, unsigned int count,
>  			 const void *kbuf, const void __user *ubuf)
>  {
> -	int ret;
> +	const size_t fgr_size = offsetof(struct __riscv_d_ext_state, fcsr);
>  	struct __riscv_d_ext_state *fstate = &target->thread.fstate;
> +	int ret;
>
>  	ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf, &fstate->f, 0,
> -				 offsetof(struct __riscv_d_ext_state, fcsr));
> +				 fgr_size);
>  	if (!ret) {
>  		ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf,
> -					 &fstate->fcsr,
> -					 offsetof(struct __riscv_d_ext_state,
> -						  fcsr),
> -					 offsetof(struct __riscv_d_ext_state, fcsr) +
> -					 sizeof(fstate->fcsr));
> +					 &fstate->fcsr, fgr_size,
> +					 fgr_size + sizeof(fstate->fcsr));
>  	}
>
>  	return ret;

Reviewed-by: Palmer Dabbelt <palmerdabbelt@...gle.com>

(Though the comments in the first patch apply here)

Thanks!

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ