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: <20110527063804.GB16811@liondog.tnic>
Date:	Fri, 27 May 2011 08:38:05 +0200
From:	Borislav Petkov <bp@...en8.de>
To:	Hidetoshi Seto <seto.hidetoshi@...fujitsu.com>
Cc:	linux-kernel@...r.kernel.org, Ingo Molnar <mingo@...hat.com>,
	"H. Peter Anvin" <hpa@...or.com>,
	Thomas Gleixner <tglx@...utronix.de>,
	Tony Luck <tony.luck@...el.com>
Subject: Re: [PATCH 10/12] x86, mce: cleanup mce_read

On Fri, May 27, 2011 at 01:11:34PM +0900, Hidetoshi Seto wrote:
> Use temporary local entry to make code simple.
> No change in logic.
> 
> Signed-off-by: Hidetoshi Seto <seto.hidetoshi@...fujitsu.com>
> ---
>  arch/x86/kernel/cpu/mcheck/mce.c |   19 +++++++++----------
>  1 files changed, 9 insertions(+), 10 deletions(-)
> 
> diff --git a/arch/x86/kernel/cpu/mcheck/mce.c b/arch/x86/kernel/cpu/mcheck/mce.c
> index 9fe9e6e..4ba4040 100644
> --- a/arch/x86/kernel/cpu/mcheck/mce.c
> +++ b/arch/x86/kernel/cpu/mcheck/mce.c
> @@ -1533,18 +1533,17 @@ static ssize_t mce_read(struct file *filp, char __user *ubuf, size_t usize,
>  	do {
>  		for (i = prev; i < next; i++) {
>  			unsigned long start = jiffies;
> +			struct mce *entry = &mcelog.entry[i];

Just go ahead and call it m:

			struct mce *m = ...

we know it's an mce struct.

>  
> -			while (!mcelog.entry[i].finished) {
> +			while (!entry->finished) {
>  				if (time_after_eq(jiffies, start + 2)) {
> -					memset(mcelog.entry + i, 0,
> -					       sizeof(struct mce));
> +					memset(entry, 0, sizeof(struct mce));

..and thus you can do

					memset(m, 0, sizeof(*m));

and that's too short for some taste but since the definition is close
enough, we should still be readable.

>  					goto timeout;
>  				}
>  				cpu_relax();
>  			}
>  			smp_rmb();
> -			err |= copy_to_user(buf, mcelog.entry + i,
> -					    sizeof(struct mce));
> +			err |= copy_to_user(buf, entry, sizeof(struct mce));
>  			buf += sizeof(struct mce);
>  timeout:
>  			;
> @@ -1565,13 +1564,13 @@ timeout:
>  	on_each_cpu(collect_tscs, cpu_tsc, 1);
>  
>  	for (i = next; i < MCE_LOG_LEN; i++) {
> -		if (mcelog.entry[i].finished &&
> -		    mcelog.entry[i].tsc < cpu_tsc[mcelog.entry[i].cpu]) {
> -			err |= copy_to_user(buf, mcelog.entry+i,
> -					    sizeof(struct mce));
> +		struct mce *entry = &mcelog.entry[i];
> +
> +		if (entry->finished && entry->tsc < cpu_tsc[entry->cpu]) {
> +			err |= copy_to_user(buf, entry, sizeof(struct mce));
>  			smp_rmb();
>  			buf += sizeof(struct mce);
> -			memset(&mcelog.entry[i], 0, sizeof(struct mce));
> +			memset(entry, 0, sizeof(struct mce));
>  		}
>  	}
>  
> -- 
> 1.7.1
> 
> 
> --
> 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/

-- 
Regards/Gruss,
    Boris.
--
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