diff options
author | Dan Rosenberg <drosenberg@vsecurity.com> | 2011-03-23 10:53:41 -0400 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2011-03-23 17:47:46 -0400 |
commit | b769f49463711205d57286e64cf535ed4daf59e9 (patch) | |
tree | 1c674fdbed533434d2ba9b7b1b3646243160e55c /sound/oss/opl3.c | |
parent | ce24f58a1187ca3058d72c3f897e3b574209ab20 (diff) |
sound/oss: remove offset from load_patch callbacks
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>
Diffstat (limited to 'sound/oss/opl3.c')
-rw-r--r-- | sound/oss/opl3.c | 8 |
1 files changed, 2 insertions, 6 deletions
diff --git a/sound/oss/opl3.c b/sound/oss/opl3.c index 938c48c43585..cbf957424d5c 100644 --- a/sound/oss/opl3.c +++ b/sound/oss/opl3.c | |||
@@ -820,7 +820,7 @@ static void opl3_hw_control(int dev, unsigned char *event) | |||
820 | } | 820 | } |
821 | 821 | ||
822 | static int opl3_load_patch(int dev, int format, const char __user *addr, | 822 | static int opl3_load_patch(int dev, int format, const char __user *addr, |
823 | int offs, int count, int pmgr_flag) | 823 | int count, int pmgr_flag) |
824 | { | 824 | { |
825 | struct sbi_instrument ins; | 825 | struct sbi_instrument ins; |
826 | 826 | ||
@@ -830,11 +830,7 @@ static int opl3_load_patch(int dev, int format, const char __user *addr, | |||
830 | return -EINVAL; | 830 | return -EINVAL; |
831 | } | 831 | } |
832 | 832 | ||
833 | /* | 833 | if (copy_from_user(&ins, addr, sizeof(ins))) |
834 | * What the fuck is going on here? We leave junk in the beginning | ||
835 | * of ins and then check the field pretty close to that beginning? | ||
836 | */ | ||
837 | if(copy_from_user(&((char *) &ins)[offs], addr + offs, sizeof(ins) - offs)) | ||
838 | return -EFAULT; | 834 | return -EFAULT; |
839 | 835 | ||
840 | if (ins.channel < 0 || ins.channel >= SBFM_MAXINSTR) | 836 | if (ins.channel < 0 || ins.channel >= SBFM_MAXINSTR) |