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]
Date:	Tue, 26 Jun 2012 14:32:46 +0200
From:	Jean Delvare <khali@...ux-fr.org>
To:	mingo@...nel.org, hpa@...or.com, linux-kernel@...r.kernel.org,
	JBeulich@...e.com, khali@...ux-fr.org, tglx@...utronix.de,
	hpa@...ux.intel.com
Cc:	linux-tip-commits@...r.kernel.org
Subject: Re: [tip:x86/urgent] x86, cpufeature:   Catch duplicate CPU feature
 strings

On Mon, 25 Jun 2012 09:14:29 -0700, tip-bot for H. Peter Anvin wrote:
> Commit-ID:  55f6cb9d0b364e7e8cb65b51193f5e4743c44fde
> Gitweb:     http://git.kernel.org/tip/55f6cb9d0b364e7e8cb65b51193f5e4743c44fde
> Author:     H. Peter Anvin <hpa@...ux.intel.com>
> AuthorDate: Fri, 22 Jun 2012 11:47:15 -0700
> Committer:  H. Peter Anvin <hpa@...ux.intel.com>
> CommitDate: Mon, 25 Jun 2012 09:02:13 -0700
> 
> x86, cpufeature: Catch duplicate CPU feature strings
> 
> We had a case of duplicate CPU feature strings, a user space ABI
> violation, for almost two years.  Make it a build error so that
> doesn't happen again.
> 
> Link: http://lkml.kernel.org/r/4FE34BCB.5050305@linux.intel.com
> Cc: Jan Beulich <JBeulich@...e.com>
> Cc: Jean Delvare <khali@...ux-fr.org>
> ---
>  arch/x86/kernel/cpu/mkcapflags.pl |   23 ++++++++++++++++++-----
>  1 files changed, 18 insertions(+), 5 deletions(-)
> 
> diff --git a/arch/x86/kernel/cpu/mkcapflags.pl b/arch/x86/kernel/cpu/mkcapflags.pl
> index dfea390..0c5b549 100644
> --- a/arch/x86/kernel/cpu/mkcapflags.pl
> +++ b/arch/x86/kernel/cpu/mkcapflags.pl
> @@ -11,22 +11,35 @@ open(OUT, "> $out\0") or die "$0: cannot create: $out: $!\n";
>  print OUT "#include <asm/cpufeature.h>\n\n";
>  print OUT "const char * const x86_cap_flags[NCAPINTS*32] = {\n";
>  
> +%features = ();
> +$err = 0;
> +
>  while (defined($line = <IN>)) {
>  	if ($line =~ /^\s*\#\s*define\s+(X86_FEATURE_(\S+))\s+(.*)$/) {
>  		$macro = $1;
> -		$feature = $2;
> +		$feature = "\L$2";
>  		$tail = $3;
>  		if ($tail =~ /\/\*\s*\"([^"]*)\".*\*\//) {
> -			$feature = $1;
> +			$feature = "\L$1";
>  		}
>  
> -		if ($feature ne '') {
> -			printf OUT "\t%-32s = \"%s\",\n",
> -				"[$macro]", "\L$feature";
> +		next if ($feature eq '');
> +
> +		if ($features{$feature}++) {
> +			print STDERR "$in: duplicate feature name: $feature\n";
> +			$err++;
>  		}
> +		printf OUT "\t%-32s = \"%s\",%s\n", "[$macro]", $feature;

You added an extra %s in the string, can't think of a good reason for
it. perl -w would have told you, I think we should add it.

Other than this, the code looks good and the improvement reasonable, so
you can add:

Acked-by: Jean Delvare <khali@...ux-fr.org>

after fixing it.

>  	}
>  }
>  print OUT "};\n";
>  
>  close(IN);
>  close(OUT);
> +
> +if ($err) {
> +	unlink($out);
> +	exit(1);
> +}
> +
> +exit(0);


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