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: <20140515155844.041ee0bc17aae5f3b8eacd70@linux-foundation.org>
Date:	Thu, 15 May 2014 15:58:44 -0700
From:	Andrew Morton <akpm@...ux-foundation.org>
To:	Joe Perches <joe@...ches.com>
Cc:	Andy Whitcroft <apw@...onical.com>,
	LKML <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] checkpatch: Add --strict test for kmalloc/kzalloc with
 multiply

On Tue, 13 May 2014 16:48:49 -0700 Joe Perches <joe@...ches.com> wrote:

> Protect against sizeof overflows by preferring
> kmalloc_array and kcalloc to kmalloc/kzalloc
> with a sizeof multiply.
> 
> ...
>
> --- a/scripts/checkpatch.pl
> +++ b/scripts/checkpatch.pl
> @@ -4378,6 +4378,20 @@ sub process {
>  			    "Prefer $3(sizeof(*$1)...) over $3($4...)\n" . $herecurr);
>  		}
>  
> +# check for k[mz]alloc with multiplies that could be kmalloc_array/kcalloc
> +		if ($^V && $^V ge 5.10.0 &&
> +		    $line =~ /\b($Lval)\s*\=\s*(?:$balanced_parens)?\s*(k[mz]alloc)\s*\(\s*($FuncArg)\s*\*\s*($FuncArg)/) {
> +			my $oldfunc = $3;
> +			my $a1 = $4;
> +			my $a2 = $10;
> +			my $newfunc = "kmalloc_array";
> +			$newfunc = "kcalloc" if ($oldfunc eq "kzalloc");
> +			if ($a1 =~ /^sizeof\s*\S/ || $a2 =~ /^sizeof\s*\S/) {
> +				CHK("ALLOC_WITH_MULTIPLY",
> +				    "Prefer $newfunc over $oldfunc with multiply\n" . $herecurr);
> +			}
> +		}
> +

Why hide this behind --strict?
--
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