sound/oss: remove offset from load_patch callbacks
authorDan Rosenberg <drosenberg@vsecurity.com>
Wed, 23 Mar 2011 14:53:41 +0000 (10:53 -0400)
committerBrad Figg <brad.figg@canonical.com>
Wed, 27 Apr 2011 18:41:29 +0000 (11:41 -0700)
commitd1a8ada59e924548c6ee79448f8a1d59fa1218d6
tree876c1f6f5e3b385f8c67abbdd839fa76852efe3f
parent9f28ed0114fe86f2ad2014472b968502d688c14f
sound/oss: remove offset from load_patch callbacks

BugLink: http://bugs.launchpad.net/bugs/761134

commit b769f49463711205d57286e64cf535ed4daf59e9 upstream.

Was: [PATCH] sound/oss/midi_synth: prevent underflow, use of
uninitialized value, and signedness issue

The offset passed to midi_synth_load_patch() can be essentially
arbitrary.  If it's greater than the header length, this will result in
a copy_from_user(dst, src, negative_val).  While this will just return
-EFAULT on x86, on other architectures this may cause memory corruption.
Additionally, the length field of the sysex_info structure may not be
initialized prior to its use.  Finally, a signed comparison may result
in an unintentionally large loop.

On suggestion by Takashi Iwai, version two removes the offset argument
from the load_patch callbacks entirely, which also resolves similar
issues in opl3.  Compile tested only.

v3 adjusts comments and hopefully gets copy offsets right.

Signed-off-by: Dan Rosenberg <drosenberg@vsecurity.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Signed-off-by: Tim Gardner <tim.gardner@canonical.com>
sound/oss/dev_table.h
sound/oss/midi_synth.c
sound/oss/midi_synth.h
sound/oss/opl3.c
sound/oss/sequencer.c