]> git.karo-electronics.de Git - karo-tx-linux.git/commit
nvram: Fix write beyond end condition; prove to gcc copy is safe
authorH. Peter Anvin <hpa@zytor.com>
Fri, 11 Dec 2009 23:48:23 +0000 (15:48 -0800)
committerGreg Kroah-Hartman <gregkh@suse.de>
Fri, 13 Aug 2010 20:19:31 +0000 (13:19 -0700)
commit607398aa9fa5ad63546a1c6ef2c1cfd6cf7cd408
tree1a8f984896d9618ae2e44abd47835a9d2a1285cf
parent5f7cfdb44e65760a08fe557c5ebd079dc766eb00
nvram: Fix write beyond end condition; prove to gcc copy is safe

commit a01c7800420d2c294ca403988488a635d4087a6d upstream.

In nvram_write, first of all, correctly handle the case where the file
pointer is already beyond the end; we should return EOF in that case.

Second, make the logic a bit more explicit so that gcc can statically
prove that the copy_from_user() is safe.  Once the condition of the
beyond-end filepointer is eliminated, the copy is safe but gcc can't
prove it, causing build failures for i386 allyesconfig.

Third, eliminate the entirely superfluous variable "len", and just use
the passed-in variable "count" instead.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
Cc: Arjan van de Ven <arjan@infradead.org>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Wim Van Sebroeck <wim@iguana.be>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
LKML-Reference: <tip-*@git.kernel.org>
Cc: Stephen Hemminger <shemminger@vyatta.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
drivers/char/nvram.c