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:	Mon, 27 Apr 2015 12:14:34 -0400
From:	Tejun Heo <tj@...nel.org>
To:	Sudeep Holla <sudeep.holla@....com>
Cc:	linux-kernel@...r.kernel.org, Pawel Moll <Pawel.Moll@....com>,
	Andrew Morton <akpm@...ux-foundation.org>,
	"Peter Zijlstra (Intel)" <peterz@...radead.org>
Subject: Re: [PATCH] bitmap: remove explicit newline handling using scnprintf
 format string

Hello, Sudeep.

On Mon, Apr 27, 2015 at 10:46:58AM +0100, Sudeep Holla wrote:
>  int bitmap_print_to_pagebuf(bool list, char *buf, const unsigned long *maskp,
>  			    int nmaskbits)
>  {
> -	ptrdiff_t len = PTR_ALIGN(buf + PAGE_SIZE - 1, PAGE_SIZE) - buf - 2;
> +	ptrdiff_t len = PTR_ALIGN(buf + PAGE_SIZE - 1, PAGE_SIZE) - buf;
>  	int n = 0;
> 
> -	if (len > 1) {
> -		n = list ? scnprintf(buf, len, "%*pbl", nmaskbits, maskp) :
> -			   scnprintf(buf, len, "%*pb", nmaskbits, maskp);
> -		buf[n++] = '\n';
> -		buf[n] = '\0';
> -	}
> +	if (len > 1)
> +		n = list ? scnprintf(buf, len, "%*pbl\n", nmaskbits, maskp) :
> +			   scnprintf(buf, len, "%*pb\n", nmaskbits, maskp);
>  	return n;
>  }
>  EXPORT_SYMBOL(bitmap_print_to_pagebuf);

So, there's one behavior difference stemming from this.  When the
buffer is too small, the original code would still output '\n' at the
end while the new code would just continue to print the formatted
string.  Given that bitmap outputs can be pretty long, this behavior
difference has a minute but still non-zero chance of causing something
surprising.  There are multiple copies of the above function in arch
codes too.  We prolly want to audit the usages to verify that the
passed in buffer is always big enough at which point the above
function and its copies can simply be replaced with direct scnprintf()
calls.  This function doesn't actually add anything.

Thanks.

-- 
tejun
--
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