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] [day] [month] [year] [list]
Message-ID: <20130314163904.GA11384@roeck-us.net>
Date:	Thu, 14 Mar 2013 09:39:04 -0700
From:	Guenter Roeck <linux@...ck-us.net>
To:	Joe Perches <joe@...ches.com>
Cc:	David Woodhouse <dwmw2@...radead.org>,
	Andrew Morton <akpm@...ux-foundation.org>,
	Andy Whitcroft <apw@...onical.com>,
	Jean Delvare <khali@...ux-fr.org>, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] checkpatch: Add check for reuse of krealloc arg

On Thu, Mar 14, 2013 at 09:18:05AM -0700, Joe Perches wrote:
> On Thu, 2013-03-14 at 13:30 +0000, David Woodhouse wrote:
> > If krealloc() returns NULL, it *doesn't* free the original. So any code
> > of the form 'foo = krealloc(foo, …);' is almost certainly a bug.
> 
> So add a check for it to checkpatch.
> 
> Signed-off-by: Joe Perches <joe@...ches.com>

Excellent idea.

Tested-by: Guenter Roeck <linux@...ck-us.net>
Acked-by: Guenter Roeck <linux@...ck-us.net>

> ---
>  scripts/checkpatch.pl | 7 +++++++
>  1 file changed, 7 insertions(+)
> 
> diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
> index b28cc38..7ef2b4b 100755
> --- a/scripts/checkpatch.pl
> +++ b/scripts/checkpatch.pl
> @@ -3476,6 +3476,13 @@ sub process {
>  			     "unnecessary cast may hide bugs, see http://c-faq.com/malloc/mallocnocast.html\n" . $herecurr);
>  		}
>  
> +# check for krealloc arg reuse
> +		if ($^V && $^V ge 5.10.0 &&
> +		    $line =~ /\b($Lval)\s*\=\s*(?:$balanced_parens)?\s*krealloc\s*\(\s*\1\s*,/) {
> +			WARN("KREALLOC_ARG_REUSE",
> +			     "Reusing the krealloc arg is almost always a bug\n" . $herecurr);
> +		}
> +
>  # check for alloc argument mismatch
>  		if ($line =~ /\b(kcalloc|kmalloc_array)\s*\(\s*sizeof\b/) {
>  			WARN("ALLOC_ARRAY_ARGS",
> 
> 
> 
--
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