From: Andi Kleen <andi@firstfloor.org>
To: drosenberg@vsecurity.com, tiwai@suse.de, gregkh@suse.de,
ak@linux.intel.com, linux-kernel@vger.kernel.org,
stable@kernel.org, tim.bird@am.sony.com
Subject: [PATCH] [38/106] sound/oss: remove offset from load_patch callbacks
Date: Tue, 26 Apr 2011 14:13:17 -0700 (PDT) [thread overview]
Message-ID: <20110426211317.B9CDF3E1886@tassilo.jf.intel.com> (raw)
In-Reply-To: <20110426212.641772347@firstfloor.org>
2.6.35-longterm review patch. If anyone has any objections, please let me know.
------------------
From: Dan Rosenberg <drosenberg@vsecurity.com>
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: Andi Kleen <ak@linux.intel.com>
---
sound/oss/dev_table.h | 2 +-
sound/oss/midi_synth.c | 30 +++++++++++++-----------------
sound/oss/midi_synth.h | 2 +-
sound/oss/opl3.c | 8 ++------
sound/oss/sequencer.c | 2 +-
5 files changed, 18 insertions(+), 26 deletions(-)
Index: linux-2.6.35.y/sound/oss/dev_table.h
===================================================================
--- linux-2.6.35.y.orig/sound/oss/dev_table.h
+++ linux-2.6.35.y/sound/oss/dev_table.h
@@ -271,7 +271,7 @@ struct synth_operations
void (*reset) (int dev);
void (*hw_control) (int dev, unsigned char *event);
int (*load_patch) (int dev, int format, const char __user *addr,
- int offs, int count, int pmgr_flag);
+ int count, int pmgr_flag);
void (*aftertouch) (int dev, int voice, int pressure);
void (*controller) (int dev, int voice, int ctrl_num, int value);
void (*panning) (int dev, int voice, int value);
Index: linux-2.6.35.y/sound/oss/midi_synth.c
===================================================================
--- linux-2.6.35.y.orig/sound/oss/midi_synth.c
+++ linux-2.6.35.y/sound/oss/midi_synth.c
@@ -476,7 +476,7 @@ EXPORT_SYMBOL(midi_synth_hw_control);
int
midi_synth_load_patch(int dev, int format, const char __user *addr,
- int offs, int count, int pmgr_flag)
+ int count, int pmgr_flag)
{
int orig_dev = synth_devs[dev]->midi_dev;
@@ -491,33 +491,29 @@ midi_synth_load_patch(int dev, int forma
if (!prefix_cmd(orig_dev, 0xf0))
return 0;
+ /* Invalid patch format */
if (format != SYSEX_PATCH)
- {
-/* printk("MIDI Error: Invalid patch format (key) 0x%x\n", format);*/
return -EINVAL;
- }
+
+ /* Patch header too short */
if (count < hdr_size)
- {
-/* printk("MIDI Error: Patch header too short\n");*/
return -EINVAL;
- }
+
count -= hdr_size;
/*
- * Copy the header from user space but ignore the first bytes which have
- * been transferred already.
+ * Copy the header from user space
*/
- if(copy_from_user(&((char *) &sysex)[offs], &(addr)[offs], hdr_size - offs))
+ if (copy_from_user(&sysex, addr, hdr_size))
return -EFAULT;
-
- if (count < sysex.len)
- {
-/* printk(KERN_WARNING "MIDI Warning: Sysex record too short (%d<%d)\n", count, (int) sysex.len);*/
+
+ /* Sysex record too short */
+ if ((unsigned)count < (unsigned)sysex.len)
sysex.len = count;
- }
- left = sysex.len;
- src_offs = 0;
+
+ left = sysex.len;
+ src_offs = 0;
for (i = 0; i < left && !signal_pending(current); i++)
{
Index: linux-2.6.35.y/sound/oss/midi_synth.h
===================================================================
--- linux-2.6.35.y.orig/sound/oss/midi_synth.h
+++ linux-2.6.35.y/sound/oss/midi_synth.h
@@ -8,7 +8,7 @@ int midi_synth_open (int dev, int mode);
void midi_synth_close (int dev);
void midi_synth_hw_control (int dev, unsigned char *event);
int midi_synth_load_patch (int dev, int format, const char __user * addr,
- int offs, int count, int pmgr_flag);
+ int count, int pmgr_flag);
void midi_synth_panning (int dev, int channel, int pressure);
void midi_synth_aftertouch (int dev, int channel, int pressure);
void midi_synth_controller (int dev, int channel, int ctrl_num, int value);
Index: linux-2.6.35.y/sound/oss/opl3.c
===================================================================
--- linux-2.6.35.y.orig/sound/oss/opl3.c
+++ linux-2.6.35.y/sound/oss/opl3.c
@@ -820,7 +820,7 @@ static void opl3_hw_control(int dev, uns
}
static int opl3_load_patch(int dev, int format, const char __user *addr,
- int offs, int count, int pmgr_flag)
+ int count, int pmgr_flag)
{
struct sbi_instrument ins;
@@ -830,11 +830,7 @@ static int opl3_load_patch(int dev, int
return -EINVAL;
}
- /*
- * What the fuck is going on here? We leave junk in the beginning
- * of ins and then check the field pretty close to that beginning?
- */
- if(copy_from_user(&((char *) &ins)[offs], addr + offs, sizeof(ins) - offs))
+ if (copy_from_user(&ins, addr, sizeof(ins)))
return -EFAULT;
if (ins.channel < 0 || ins.channel >= SBFM_MAXINSTR)
Index: linux-2.6.35.y/sound/oss/sequencer.c
===================================================================
--- linux-2.6.35.y.orig/sound/oss/sequencer.c
+++ linux-2.6.35.y/sound/oss/sequencer.c
@@ -241,7 +241,7 @@ int sequencer_write(int dev, struct file
return -ENXIO;
fmt = (*(short *) &event_rec[0]) & 0xffff;
- err = synth_devs[dev]->load_patch(dev, fmt, buf, p + 4, c, 0);
+ err = synth_devs[dev]->load_patch(dev, fmt, buf + p, c, 0);
if (err < 0)
return err;
next prev parent reply other threads:[~2011-04-26 21:32 UTC|newest]
Thread overview: 125+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-04-26 21:12 [PATCH] [0/106] 2.6.35.13 longterm review Andi Kleen
2011-04-26 21:12 ` [PATCH] [1/106] mm: page allocator: adjust the per-cpu counter threshold when memory is low Andi Kleen
2011-04-26 21:12 ` [PATCH] [2/106] qla2xxx: Make the FC port capability mutual exclusive Andi Kleen
2011-04-26 21:12 ` [PATCH] [3/106] staging: usbip: bugfixes related to kthread conversion Andi Kleen
2011-04-26 21:12 ` [PATCH] [4/106] staging: usbip: bugfix add number of packets for isochronous frames Andi Kleen
2011-04-26 21:12 ` [PATCH] [5/106] staging: usbip: bugfix for isochronous packets and optimization Andi Kleen
2011-04-26 21:12 ` [PATCH] [6/106] staging: hv: Fix GARP not sent after Quick Migration Andi Kleen
2011-04-26 21:12 ` [PATCH] [7/106] staging: hv: use sync_bitops when interacting with the hypervisor Andi Kleen
2011-04-26 21:12 ` [PATCH] [8/106] xfs: prevent leaking uninitialized stack memory in FSGEOMETRY_V1 Andi Kleen
2011-04-27 5:26 ` Dave Chinner
2011-04-27 15:00 ` Andi Kleen
2011-04-28 0:04 ` Dave Chinner
2011-04-26 21:12 ` [PATCH] [9/106] irda: validate peer name and attribute lengths Andi Kleen
2011-04-26 21:12 ` [PATCH] [10/106] irda: prevent heap corruption on invalid nickname Andi Kleen
2011-04-26 21:12 ` [PATCH] [11/106] nilfs2: fix data loss in mmap page write for hole blocks Andi Kleen
2011-04-26 21:12 ` [PATCH] [12/106] ASoC: Explicitly say registerless widgets have no register Andi Kleen
2011-04-26 21:12 ` [PATCH] [13/106] ALSA: ens1371: fix Creative Ectiva support Andi Kleen
2011-04-26 21:12 ` [PATCH] [14/106] ROSE: prevent heap corruption with bad facilities Andi Kleen
2011-04-26 21:12 ` [PATCH] [15/106] Btrfs: Fix uninitialized root flags for subvolumes Andi Kleen
2011-04-26 21:12 ` [PATCH] [16/106] x86, mtrr, pat: Fix one cpu getting out of sync during resume Andi Kleen
2011-04-26 21:12 ` [PATCH] [17/106] UBIFS: do not read flash unnecessarily Andi Kleen
2011-04-26 21:12 ` [PATCH] [18/106] UBIFS: fix oops on error path in read_pnode Andi Kleen
2011-04-26 21:12 ` [PATCH] [19/106] UBIFS: fix debugging failure in dbg_check_space_info Andi Kleen
2011-04-26 21:12 ` [PATCH] [20/106] quota: Don't write quota info in dquot_commit() Andi Kleen
2011-04-26 21:12 ` [PATCH] [21/106] mm: avoid wrapping vm_pgoff in mremap() Andi Kleen
2011-04-26 21:13 ` [PATCH] [22/106] p54usb: IDs for two new devices Andi Kleen
2011-04-26 21:13 ` [PATCH] [23/106] b43: allocate receive buffers big enough for max frame len + offset Andi Kleen
2011-04-26 21:13 ` [PATCH] [24/106] Bluetooth: sco: fix information leak to userspace Andi Kleen
2011-04-26 21:13 ` [PATCH] [25/106] bridge: netfilter: fix information leak Andi Kleen
2011-04-26 21:13 ` [PATCH] [26/106] Bluetooth: bnep: fix buffer overflow Andi Kleen
2011-04-26 21:13 ` [PATCH] [27/106] Bluetooth: add support for Apple MacBook Pro 8,2 Andi Kleen
2011-04-26 21:13 ` [PATCH] [28/106] Treat writes as new when holes span across page boundaries Andi Kleen
2011-04-26 21:13 ` [PATCH] [29/106] char/tpm: Fix unitialized usage of data buffer Andi Kleen
2011-04-26 21:13 ` [PATCH] [30/106] netfilter: ip_tables: fix infoleak to userspace Andi Kleen
2011-04-26 21:13 ` [PATCH] [31/106] netfilter: arp_tables: " Andi Kleen
2011-04-26 21:13 ` [PATCH] [32/106] netfilter: ipt_CLUSTERIP: fix buffer overflow Andi Kleen
2011-04-26 21:13 ` [PATCH] [33/106] ipv6: netfilter: ip6_tables: fix infoleak to userspace Andi Kleen
2011-04-26 21:13 ` [PATCH] [34/106] mfd: ab3100: world-writable debugfs *_priv files Andi Kleen
2011-04-26 21:13 ` [PATCH] [35/106] drivers/rtc/rtc-ds1511.c: world-writable sysfs nvram file Andi Kleen
2011-04-26 21:13 ` [PATCH] [36/106] drivers/misc/ep93xx_pwm.c: world-writable sysfs files Andi Kleen
2011-04-26 21:13 ` [PATCH] [37/106] econet: 4 byte infoleak to the network Andi Kleen
2011-04-26 21:13 ` Andi Kleen [this message]
2011-04-26 21:13 ` [PATCH] [39/106] sound: oss: midi_synth: check get_user() return value Andi Kleen
2011-04-26 21:13 ` [PATCH] [40/106] gro: Reset dev pointer on reuse Andi Kleen
2011-04-26 21:13 ` [PATCH] [41/106] gro: reset skb_iif " Andi Kleen
2011-04-26 21:13 ` [PATCH] [42/106] x86, microcode, AMD: Extend ucode size verification Andi Kleen
2011-04-26 22:44 ` Paul Gortmaker
2011-04-26 23:03 ` Andi Kleen
2011-04-26 21:13 ` [PATCH] [43/106] Squashfs: handle corruption of directory structure Andi Kleen
2011-04-26 21:13 ` [PATCH] [44/106] atm/solos-pci: Don't include frame pseudo-header on transmit hex-dump Andi Kleen
2011-04-26 21:13 ` [PATCH] [45/106] ext4: fix credits computing for indirect mapped files Andi Kleen
2011-04-26 21:13 ` [PATCH] [46/106] nfsd: fix auth_domain reference leak on nlm operations Andi Kleen
2011-04-26 21:13 ` [PATCH] [47/106] net: tipc: fix information leak to userland Andi Kleen
2011-04-26 21:13 ` [PATCH] [48/106] inet_diag: Make sure we actually run the same bytecode we audited Andi Kleen
2011-04-26 21:13 ` [PATCH] [49/106] irda: prevent integer underflow in IRLMP_ENUMDEVICES Andi Kleen
2011-04-26 21:13 ` [PATCH] [50/106] CAN: Use inode instead of kernel address for /proc file Andi Kleen
2011-04-26 21:13 ` [PATCH] [51/106] net: fix rds_iovec page count overflow Andi Kleen
2011-04-26 21:13 ` [PATCH] [52/106] xfs: zero proper structure size for geometry calls Andi Kleen
2011-04-26 21:13 ` [PATCH] [53/106] cifs: always do is_path_accessible check in cifs_mount Andi Kleen
2011-04-26 21:13 ` [PATCH] [54/106] video: sn9c102: world-wirtable sysfs files Andi Kleen
2011-04-26 21:13 ` [PATCH] [55/106] UBIFS: restrict world-writable debugfs files Andi Kleen
2011-04-26 21:13 ` [PATCH] [56/106] NET: cdc-phonet, handle empty phonet header Andi Kleen
2011-04-26 21:13 ` [PATCH] [57/106] x86: Fix a bogus unwind annotation in lib/semaphore_32.S Andi Kleen
2011-04-26 21:13 ` [PATCH] [58/106] tioca: Fix assignment from incompatible pointer warnings Andi Kleen
2011-04-26 21:13 ` [PATCH] [59/106] mca.c: Fix cast from integer to pointer warning Andi Kleen
2011-04-26 21:13 ` [PATCH] [60/106] ramfs: fix memleak on no-mmu arch Andi Kleen
2011-04-26 21:13 ` [PATCH] [61/106] MAINTAINERS: update STABLE BRANCH info Andi Kleen
2011-04-26 21:13 ` [PATCH] [62/106] UBIFS: fix oops when R/O file-system is fsync'ed Andi Kleen
2011-04-26 21:13 ` [PATCH] [63/106] x86, cpu: AMD errata checking framework Andi Kleen
2011-04-26 21:13 ` [PATCH] [64/106] x86, cpu: Clean up AMD erratum 400 workaround Andi Kleen
2011-04-26 21:13 ` [PATCH] [65/106] x86, AMD: Set ARAT feature on AMD processors Andi Kleen
2011-04-26 21:13 ` [PATCH] [66/106] x86, amd: Disable GartTlbWlkErr when BIOS forgets it Andi Kleen
2011-04-26 21:13 ` [PATCH] [67/106] USB: ftdi_sio: Added IDs for CTI USB Serial Devices Andi Kleen
2011-04-26 21:13 ` [PATCH] [68/106] USB: ftdi_sio: add PID for OCT DK201 docking station Andi Kleen
2011-04-26 21:13 ` [PATCH] [69/106] USB: ftdi_sio: add ids for Hameg HO720 and HO730 Andi Kleen
2011-04-26 21:13 ` [PATCH] [70/106] USB: option: Add new ONDA vendor id and product id for ONDA MT825UP Andi Kleen
2011-04-26 21:13 ` [PATCH] [71/106] USB: option: Added support for Samsung GT-B3730/GT-B3710 LTE USB modem Andi Kleen
2011-04-26 21:13 ` [PATCH] [72/106] next_pidmap: fix overflow condition Andi Kleen
2011-04-26 21:13 ` [PATCH] [73/106] proc: do proper range check on readdir offset Andi Kleen
2011-04-26 21:13 ` [PATCH] [74/106] USB: EHCI: unlink unused QHs when the controller is stopped Andi Kleen
2011-04-26 21:13 ` [PATCH] [75/106] USB: fix formatting of SuperSpeed endpoints in /proc/bus/usb/devices Andi Kleen
2011-04-26 21:13 ` [PATCH] [76/106] USB: xhci - fix unsafe macro definitions Andi Kleen
2011-04-26 21:13 ` [PATCH] [77/106] USB: xhci - fix math in xhci_get_endpoint_interval() Andi Kleen
2011-04-26 21:13 ` [PATCH] [78/106] x86, cpu: Fix regression in AMD errata checking code Andi Kleen
2011-04-26 21:14 ` [PATCH] [79/106] net: ax25: fix information leak to userland harder Andi Kleen
2011-04-26 21:14 ` [PATCH] [80/106] Input: synaptics - fix crash in synaptics_module_init() Andi Kleen
2011-04-26 21:14 ` [PATCH] [81/106] ath9k: fix a chip wakeup related crash in ath9k_start Andi Kleen
2011-04-26 21:14 ` [PATCH] [82/106] ath: add missing regdomain pair 0x5c mapping Andi Kleen
2011-04-26 21:14 ` [PATCH] [83/106] block, blk-sysfs: Fix an err return path in blk_register_queue() Andi Kleen
2011-04-26 21:14 ` [PATCH] [84/106] p54: Initialize extra_len in p54_tx_80211 Andi Kleen
2011-04-26 21:14 ` [PATCH] [85/106] x86, gart: Make sure GART does not map physmem above 1TB Andi Kleen
2011-04-26 21:14 ` [PATCH] [86/106] intel-iommu: Unlink domain from iommu Andi Kleen
2011-04-26 21:14 ` [PATCH] [87/106] intel-iommu: Fix get_domain_for_dev() error path Andi Kleen
2011-04-26 21:14 ` [PATCH] [88/106] drm/radeon/kms: fix bad shift in atom iio table parser Andi Kleen
2011-04-26 21:14 ` [PATCH] [89/106] NFS: nfs_wcc_update_inode() should set nfsi->attr_gencount Andi Kleen
2011-04-26 21:14 ` [PATCH] [90/106] serial/imx: read cts state only after acking cts change irq Andi Kleen
2011-04-26 21:14 ` [PATCH] [91/106] ASoC: Fix output PGA enabling in wm_hubs CODECs Andi Kleen
2011-04-26 21:14 ` [PATCH] [92/106] kconfig: Avoid buffer underrun in choice input Andi Kleen
2011-04-26 21:14 ` [PATCH] [93/106] UBIFS: fix master node recovery Andi Kleen
2011-04-26 21:14 ` [PATCH] [94/106] Remove extra struct page member from the buffer info structure Andi Kleen
2011-04-26 21:14 ` [PATCH] [95/106] dasd: correct device table Andi Kleen
2011-04-26 21:14 ` [PATCH] [96/106] iwlagn: Support new 5000 microcode Andi Kleen
2011-04-27 17:42 ` Tim Gardner
2011-04-27 20:47 ` Valdis.Kletnieks
2011-04-27 22:20 ` Andi Kleen
2011-04-27 22:32 ` wwguy
2011-04-27 22:41 ` Andi Kleen
2011-04-27 22:42 ` wwguy
2011-04-27 22:46 ` Andi Kleen
2011-04-28 2:42 ` Tim Gardner
2011-04-26 21:14 ` [PATCH] [97/106] uvcvideo: Fix descriptor parsing for video output devices Andi Kleen
2011-04-26 21:14 ` [PATCH] [98/106] Revert "intel_idle: PCI quirk to prevent Lenovo Ideapad s10-3 boot hang" Andi Kleen
2011-04-26 21:14 ` [PATCH] [99/106] ALSA: hda - VIA: Add missing support for VT1718S in A-A path Andi Kleen
2011-04-26 21:14 ` [PATCH] [100/106] ALSA: hda - VIA: Fix stereo mixer recording no sound issue Andi Kleen
2011-04-26 21:14 ` [PATCH] [101/106] From: iwlwifi: fix skb usage after free Andi Kleen
2011-04-26 21:14 ` [PATCH] [102/106] From: intel-iommu: Fix use after release during device attach Andi Kleen
2011-04-26 21:14 ` [PATCH] [103/106] From: USB: Fix unplug of device with active streams Andi Kleen
2011-04-26 21:14 ` [PATCH] [104/106] From: USB: xhci - also free streams when resetting devices Andi Kleen
2011-04-26 21:14 ` [PATCH] [105/106] From: 2.6.35.y: Revert "SH: Add missing consts to sys_execve() declaration" Andi Kleen
2011-04-26 21:14 ` [PATCH] [106/106] Release 2.6.35.13 Andi Kleen
2011-04-27 0:08 ` [stable] [PATCH] [0/106] 2.6.35.13 longterm review Chuck Ebbert
2011-04-27 2:58 ` Andi Kleen
2011-04-27 0:17 ` Tim Bird
2011-04-27 0:21 ` [stable] " Chuck Ebbert
2011-04-27 3:08 ` Andi Kleen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20110426211317.B9CDF3E1886@tassilo.jf.intel.com \
--to=andi@firstfloor.org \
--cc=ak@linux.intel.com \
--cc=drosenberg@vsecurity.com \
--cc=gregkh@suse.de \
--cc=linux-kernel@vger.kernel.org \
--cc=stable@kernel.org \
--cc=tim.bird@am.sony.com \
--cc=tiwai@suse.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome