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: <20130914030521.GZ13318@ZenIV.linux.org.uk>
Date:	Sat, 14 Sep 2013 04:05:21 +0100
From:	Al Viro <viro@...IV.linux.org.uk>
To:	Tetsuo Handa <penguin-kernel@...ove.SAKURA.ne.jp>
Cc:	keescook@...omium.org, joe@...ches.com, linux@...izon.com,
	akpm@...ux-foundation.org, dan.carpenter@...cle.com,
	davem@...emloft.net, eldad@...refinery.com, jbeulich@...e.com,
	jkosina@...e.cz, linux-kernel@...r.kernel.org,
	rdunlap@...radead.org
Subject: Re: [PATCH] vsprintf: drop comment claiming %n is ignored

On Sat, Sep 14, 2013 at 11:49:51AM +0900, Tetsuo Handa wrote:

> Even bad code which has never tested failure case, the authors should already
> know that "seq_printf() returns 0 on success case".

It is designed so that not testing failure case is normal approach for the
majority of users.

>   -	pos += seq_printf(s, "\tChannel number: %d\n", num_dma_channels);
>   +	seq_puts(s, "DMA engine status\n");
>   +	seq_printf(s, "\tChannel number: %d\n", num_dma_channels);
>    
>   - 	return pos;
>   +	return seq_overflow(s) : -1 : 0;
> 
> for keeping the functionality.

ITYM "for keeping the bug".  Read seq_read(), please.  Any negative value
returned by ->show() is a hard error.  It won't be retried with bigger
buffer; read(2) will *fail*.  With -EINVAL, in your case.

We really, really should not return non-zero on overflow.  Moreover, returning
a _positive_ value (SEQ_SKIP, normally, but any positive will do the same thing)
means "silently discard everything ->show() might have produced"

Again, the normal return value of ->show() is 0 and that includes the case of
overflow.  THE ONLY reason to check for overflow early is when subsequent
output of ->show() takes long to generate and we want to skip that and
have seq_read() do realloc-and-call-show-again immediately.  And in that
case the right fix is often to get saner iterator and stop shoving everything
into a single ->show() call...
--
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