public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Greg KH <gregkh@suse.de>
To: linux-kernel@vger.kernel.org, stable@kernel.org
Cc: stable-review@kernel.org, torvalds@linux-foundation.org,
	akpm@linux-foundation.org, alan@lxorguk.ukuu.org.uk,
	Clemens Ladisch <clemens@ladisch.de>,
	Stefan Richter <stefanr@s5r6.in-berlin.de>
Subject: [050/127] firewire: ohci: fix race in AR split packet handling
Date: Tue, 07 Dec 2010 16:43:56 -0800	[thread overview]
Message-ID: <20101208004429.317061630@clark.site> (raw)
In-Reply-To: <20101208004456.GA23578@kroah.com>

2.6.32-stable review patch.  If anyone has any objections, please let us know.

------------------

From: Clemens Ladisch <clemens@ladisch.de>

commit a1f805e5e73a8fe166b71c6592d3837df0cd5e2e upstream.

When handling an AR buffer that has been completely filled, we assumed
that its descriptor will not be read by the controller and can be
overwritten.  However, when the last received packet happens to end at
the end of the buffer, the controller might not yet have moved on to the
next buffer and might read the branch address later.  If we overwrite
and free the page before that, the DMA context will either go dead
because of an invalid Z value, or go off into some random memory.

To fix this, ensure that the descriptor does not get overwritten by
using only the actual buffer instead of the entire page for reassembling
the split packet.  Furthermore, to avoid freeing the page too early,
move on to the next buffer only when some data in it guarantees that the
controller has moved on.

This should eliminate the remaining firewire-net problems.

Signed-off-by: Clemens Ladisch <clemens@ladisch.de>
Tested-by: Maxim Levitsky <maximlevitsky@gmail.com>
Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>

---
 drivers/firewire/ohci.c |   39 +++++++++++++++++++++++----------------
 1 file changed, 23 insertions(+), 16 deletions(-)

--- a/drivers/firewire/ohci.c
+++ b/drivers/firewire/ohci.c
@@ -639,20 +639,19 @@ static void ar_context_tasklet(unsigned
 		 */
 
 		offset = offsetof(struct ar_buffer, data);
-		start = buffer = ab;
+		start = ab;
 		start_bus = le32_to_cpu(ab->descriptor.data_address) - offset;
+		buffer = ab->data;
 
 		ab = ab->next;
 		d = &ab->descriptor;
-		size = buffer + PAGE_SIZE - ctx->pointer;
+		size = start + PAGE_SIZE - ctx->pointer;
 		/* valid buffer data in the next page */
 		rest = le16_to_cpu(d->req_count) - le16_to_cpu(d->res_count);
 		/* what actually fits in this page */
-		size2 = min(rest, (size_t)PAGE_SIZE - size);
+		size2 = min(rest, (size_t)PAGE_SIZE - offset - size);
 		memmove(buffer, ctx->pointer, size);
 		memcpy(buffer + size, ab->data, size2);
-		ctx->current_buffer = ab;
-		ctx->pointer = (void *) ab->data + rest;
 
 		while (size > 0) {
 			void *next = handle_ar_packet(ctx, buffer);
@@ -671,22 +670,30 @@ static void ar_context_tasklet(unsigned
 			size -= pktsize;
 			/* fill up this page again */
 			size3 = min(rest - size2,
-				    (size_t)PAGE_SIZE - size - size2);
+				    (size_t)PAGE_SIZE - offset - size - size2);
 			memcpy(buffer + size + size2,
 			       (void *) ab->data + size2, size3);
 			size2 += size3;
 		}
 
-		/* handle the packets that are fully in the next page */
-		buffer = (void *) ab->data + (buffer - (start + size));
-		end = (void *) ab->data + rest;
-
-		while (buffer < end)
-			buffer = handle_ar_packet(ctx, buffer);
-
-		dma_free_coherent(ohci->card.device, PAGE_SIZE,
-				  start, start_bus);
-		ar_context_add_page(ctx);
+		if (rest > 0) {
+			/* handle the packets that are fully in the next page */
+			buffer = (void *) ab->data +
+					(buffer - (start + offset + size));
+			end = (void *) ab->data + rest;
+
+			while (buffer < end)
+				buffer = handle_ar_packet(ctx, buffer);
+
+			ctx->current_buffer = ab;
+			ctx->pointer = end;
+
+			dma_free_coherent(ohci->card.device, PAGE_SIZE,
+					  start, start_bus);
+			ar_context_add_page(ctx);
+		} else {
+			ctx->pointer = start + PAGE_SIZE;
+		}
 	} else {
 		buffer = ctx->pointer;
 		ctx->pointer = end =



  parent reply	other threads:[~2010-12-08  0:47 UTC|newest]

Thread overview: 138+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-12-08  0:44 [000/127] 2.6.32.27-stable review Greg KH
2010-12-08  0:43 ` [001/127] block: Ensure physical block size is unsigned int Greg KH
2010-12-08  0:43 ` [002/127] block: limit vec count in bio_kmalloc() and bio_alloc_map_data() Greg KH
2010-12-08  0:43 ` [003/127] block: take care not to overflow when calculating total iov length Greg KH
2010-12-08  0:43 ` [004/127] block: check for proper length of iov entries in blk_rq_map_user_iov() Greg KH
2010-12-08  0:43 ` [005/127] jme: Fix PHY power-off error Greg KH
2010-12-08  0:43 ` [006/127] irda: Fix parameter extraction stack overflow Greg KH
2010-12-08  0:43 ` [007/127] irda: Fix heap memory corruption in iriap.c Greg KH
2010-12-08  0:43 ` [008/127] i2c-pca-platform: Change device name of request_irq Greg KH
2010-12-08  0:43 ` [009/127] microblaze: Fix build with make 3.82 Greg KH
2010-12-08  0:43 ` [010/127] net: clear heap allocation for ETHTOOL_GRXCLSRLALL Greg KH
2010-12-08  0:43 ` [011/127] Staging: asus_oled: fix up some sysfs attribute permissions Greg KH
2010-12-08  0:43 ` [012/127] Staging: asus_oled: fix up my fixup for " Greg KH
2010-12-08  0:43 ` [013/127] Staging: line6: fix up " Greg KH
2010-12-08  0:43 ` [014/127] hpet: fix unwanted interrupt due to stale irq status bit Greg KH
2010-12-08  0:43 ` [015/127] hpet: unmap unused I/O space Greg KH
2010-12-08  0:43 ` [016/127] olpc_battery: Fix endian neutral breakage for s16 values Greg KH
2010-12-08  0:43 ` [017/127] percpu: fix list_head init bug in __percpu_counter_init() Greg KH
2010-12-08  0:43 ` [018/127] um: remove PAGE_SIZE alignment in linker script causing kernel segfault Greg KH
2010-12-08  0:43 ` [019/127] um: fix global timer issue when using CONFIG_NO_HZ Greg KH
2010-12-08  0:43 ` [020/127] numa: fix slab_node(MPOL_BIND) Greg KH
2010-12-08  0:43 ` [021/127] hwmon: (lm85) Fix ADT7468 frequency table Greg KH
2010-12-08  0:43 ` [022/127] mm: fix return value of scan_lru_pages in memory unplug Greg KH
2010-12-08  0:43 ` [023/127] mm: fix is_mem_section_removable() page_order BUG_ON check Greg KH
2010-12-08  0:43 ` [024/127] ahci,ata_generic: let ata_generic handle new MBP w/ MCP89 Greg KH
2010-12-08  0:43 ` [025/127] ata_generic: implement ATA_GEN_* flags and force enable DMA on MBP 7,1 Greg KH
2010-12-08  0:43 ` [026/127] ssb: b43-pci-bridge: Add new vendor for BCM4318 Greg KH
2010-12-08  0:43 ` [027/127] sgi-xpc: XPC fails to discover partitions with all nasids above 128 Greg KH
2010-12-08  0:43 ` [028/127] xen: ensure that all event channels start off bound to VCPU 0 Greg KH
2010-12-08  0:43 ` [029/127] xen: dont bother to stop other cpus on shutdown/reboot Greg KH
2010-12-08  0:43 ` [030/127] ipc: initialize structure memory to zero for compat functions Greg KH
2010-12-08  0:43 ` [031/127] ipc: shm: fix information leak to userland Greg KH
2010-12-08  0:43 ` [032/127] sys_semctl: fix kernel stack leakage Greg KH
2010-12-08  0:43 ` [033/127] net: NETIF_F_HW_CSUM does not imply FCoE CRC offload Greg KH
2010-12-08  0:43 ` [034/127] drivers/char/vt_ioctl.c: fix VT_OPENQRY error value Greg KH
2010-12-08  0:43 ` [035/127] viafb: use proper register for colour when doing fill ops Greg KH
2010-12-08  0:43 ` [036/127] eCryptfs: Clear LOOKUP_OPEN flag when creating lower file Greg KH
2010-12-08  0:43 ` [037/127] md/raid1: really fix recovery looping when single good device fails Greg KH
2010-12-08  0:43 ` [038/127] md: fix return value of rdev_size_change() Greg KH
2010-12-08  0:43 ` [039/127] x86: AMD Northbridge: Verify NBs node is online Greg KH
2010-12-08  0:43 ` [040/127] tty: prevent DOS in the flush_to_ldisc Greg KH
2010-12-08  0:43 ` [041/127] TTY: restore tty_ldisc_wait_idle Greg KH
2010-12-08  0:43 ` [042/127] tty_ldisc: Fix BUG() on hangup Greg KH
2010-12-08  0:43 ` [043/127] TTY: ldisc, fix open flag handling Greg KH
2010-12-08  6:24   ` Jiri Slaby
2010-12-08 15:02     ` Greg KH
2010-12-08 15:09       ` Jiri Slaby
2010-12-08 15:50         ` Greg KH
2010-12-08  0:43 ` [044/127] KVM: VMX: fix vmx null pointer dereference on debug register access Greg KH
2010-12-08  0:43 ` [045/127] KVM: x86: fix information leak to userland Greg KH
2010-12-08  0:43 ` [046/127] KVM: VMX: Fix host userspace gsbase corruption Greg KH
2010-12-08  2:12   ` [Stable-review] " Ben Hutchings
2010-12-08  3:58     ` Greg KH
2010-12-08  0:43 ` [047/127] firewire: cdev: fix information leak Greg KH
2010-12-08  0:43 ` [048/127] firewire: core: fix an " Greg KH
2010-12-08  0:43 ` [049/127] firewire: ohci: fix buffer overflow in AR split packet handling Greg KH
2010-12-08  0:43 ` Greg KH [this message]
2010-12-08  0:43 ` [051/127] ALSA: ac97: Apply quirk for Dell Latitude D610 binding Master and Headphone controls Greg KH
2010-12-08  0:43 ` [052/127] ALSA: HDA: Add an extra DAC for Realtek ALC887-VD Greg KH
2010-12-08  0:43 ` [053/127] ALSA: hda: Use "alienware" model quirk for another SSID Greg KH
2010-12-08  0:44 ` [054/127] netfilter: nf_conntrack: allow nf_ct_alloc_hashtable() to get highmem pages Greg KH
2010-12-08  0:44 ` [055/127] latencytop: fix per task accumulator Greg KH
2010-12-08  0:44 ` [056/127] mm/vfs: revalidate page->mapping in do_generic_file_read() Greg KH
2010-12-08  0:44 ` [057/127] bio: take care not overflow page count when mapping/copying user data Greg KH
2010-12-08  0:44 ` [058/127] drm/ttm: Clear the ghost cpu_writers flag on ttm_buffer_object_transfer Greg KH
2010-12-08  0:44 ` [059/127] libata-scsi passthru: fix bug which truncated LBA48 return values Greg KH
2010-12-08  0:44 ` [060/127] libata: fix NULL sdev dereference race in atapi_qc_complete() Greg KH
2010-12-08  0:44 ` [061/127] PCI: fix size checks for mmap() on /proc/bus/pci files Greg KH
2010-12-08  0:44 ` [062/127] PCI: fix offset check for sysfs mmapped files Greg KH
2010-12-08  0:44 ` [063/127] efifb: check that the base address is plausible on pci systems Greg KH
2010-12-08  0:44 ` [064/127] USB: gadget: AT91: fix typo in atmel_usba_udc driver Greg KH
2010-12-08  0:44 ` [065/127] USB: ftdi_sio: add device IDs for Milkymist One JTAG/serial Greg KH
2010-12-08  0:44 ` [066/127] USB: option: fix when the driver is loaded incorrectly for some Huawei devices Greg KH
2010-12-08  0:44 ` [067/127] usb: misc: sisusbvga: fix information leak to userland Greg KH
2010-12-08  0:44 ` [068/127] usb: misc: iowarrior: " Greg KH
2010-12-08  0:44 ` [069/127] usb: core: " Greg KH
2010-12-08  0:44 ` [070/127] USB: EHCI: fix obscure race in ehci_endpoint_disable Greg KH
2010-12-08  0:44 ` [071/127] USB: storage: sierra_ms: fix sysfs file attribute Greg KH
2010-12-08  0:44 ` [072/127] USB: atm: ueagle-atm: fix up some permissions on the sysfs files Greg KH
2010-12-08  0:44 ` [073/127] USB: misc: cypress_cy7c63: fix up some sysfs attribute permissions Greg KH
2010-12-08  0:44 ` [074/127] USB: misc: usbled: " Greg KH
2010-12-08  0:44 ` [075/127] USB: ftdi_sio: revert "USB: ftdi_sio: fix DTR/RTS line modes" Greg KH
2010-12-08  0:44 ` [076/127] USB: misc: trancevibrator: fix up a sysfs attribute permission Greg KH
2010-12-08  0:44 ` [077/127] USB: misc: usbsevseg: fix up some sysfs attribute permissions Greg KH
2010-12-08  0:44 ` [078/127] USB: ftdi_sio: Add ID for RT Systems USB-29B radio cable Greg KH
2010-12-08  0:44 ` [079/127] USB: serial: ftdi_sio: Vardaan USB RS422/485 converter PID added Greg KH
2010-12-08  0:44 ` [080/127] acpi-cpufreq: fix a memleak when unloading driver Greg KH
2010-12-08  0:44 ` [081/127] ACPI: EC: add Vista incompatibility DMI entry for Toshiba Satellite L355 Greg KH
2010-12-08  0:44 ` [082/127] fuse: fix attributes after open(O_TRUNC) Greg KH
2010-12-08  0:44 ` [083/127] do_exit(): make sure that we run with get_fs() == USER_DS Greg KH
2010-12-08  0:44 ` [084/127] uml: disable winch irq before freeing handler data Greg KH
2010-12-08  0:44 ` [085/127] backlight: grab ops_lock before testing bd->ops Greg KH
2010-12-08  0:44 ` [086/127] nommu: yield CPU while disposing VM Greg KH
2010-12-08  0:44 ` [087/127] DECnet: dont leak uninitialized stack byte Greg KH
2010-12-08  0:44 ` [088/127] perf_events: Fix perf_counter_mmap() hook in mprotect() Greg KH
2010-12-08  0:44 ` [089/127] ARM: 6489/1: thumb2: fix incorrect optimisation in usracc Greg KH
2010-12-08  0:44 ` [090/127] ARM: 6482/2: Fix find_next_zero_bit and related assembly Greg KH
2010-12-08  0:44 ` [091/127] Staging: frontier: fix up some sysfs attribute permissions Greg KH
2010-12-08  0:44 ` [092/127] staging: rtl8187se: Change panic to warn when RF switch turned off Greg KH
2010-12-08  0:44 ` [093/127] net sched: fix kernel leak in act_police Greg KH
2010-12-08  0:44 ` [094/127] HID: hidraw, fix a NULL pointer dereference in hidraw_ioctl Greg KH
2010-12-08  0:44 ` [095/127] HID: hidraw, fix a NULL pointer dereference in hidraw_write Greg KH
2010-12-08  0:44 ` [096/127] gianfar: Fix crashes on RX path (Was Re: [Bugme-new] [Bug 19692] New: linux-2.6.36-rc5 crash with gianfar ethernet at full line rate traffic) Greg KH
2010-12-08  0:44 ` [097/127] Limit sysctl_tcp_mem and sysctl_udp_mem initializers to prevent integer overflows Greg KH
2010-12-08  0:44 ` [098/127] sparc64: Fix race in signal instruction flushing Greg KH
2010-12-08  0:44 ` [099/127] sparc: Dont mask signal when we cant setup signal frame Greg KH
2010-12-08  0:44 ` [100/127] sparc: Prevent no-handler signal syscall restart recursion Greg KH
2010-12-08  0:44 ` [101/127] x86, UV: Delete unneeded boot messages Greg KH
2010-12-08  0:44 ` [102/127] x86, UV: Fix initialization of max_pnode Greg KH
2010-12-08  0:44 ` [103/127] drivers/video/efifb.c: support framebuffer for NVIDIA 9400M in MacBook Pro 5,1 Greg KH
2010-12-08  0:44 ` [104/127] efifb: support the EFI framebuffer on more Apple hardware Greg KH
2010-12-08  0:44 ` [105/127] V4L/DVB (13154): uvcvideo: Handle garbage at the end of streaming interface descriptors Greg KH
2010-12-08  0:44 ` [106/127] Input: i8042 - add Sony VAIO VPCZ122GX to nomux list Greg KH
2010-12-08  0:44 ` [107/127] x25: Patch to fix bug 15678 - x25 accesses fields beyond end of packet Greg KH
2010-12-08  0:44 ` [108/127] memory corruption in X.25 facilities parsing Greg KH
2010-12-08  0:44 ` [109/127] can-bcm: fix minor heap overflow Greg KH
2010-12-08  0:44 ` [110/127] V4L/DVB: ivtvfb: prevent reading uninitialized stack memory Greg KH
2010-12-08  0:44 ` [111/127] x25: Prevent crashing when parsing bad X.25 facilities Greg KH
2010-12-08  0:44 ` [112/127] crypto: padlock - Fix AES-CBC handling on odd-block-sized input Greg KH
2010-12-08  0:44 ` [113/127] x86-32: Separate 1:1 pagetables from swapper_pg_dir Greg KH
2010-12-08  0:45 ` [114/127] x86, mm: Fix CONFIG_VMSPLIT_1G and 2G_OPT trampoline Greg KH
2010-12-08  0:45 ` [115/127] x86-32: Fix dummy trampoline-related inline stubs Greg KH
2010-12-08  0:45 ` [116/127] econet: disallow NULL remote addr for sendmsg(), fixes CVE-2010-3849 Greg KH
2010-12-08  0:45 ` [117/127] econet: fix CVE-2010-3850 Greg KH
2010-12-08  0:45 ` [118/127] rds: Integer overflow in RDS cmsg handling Greg KH
2010-12-08  0:45 ` [119/127] net: Truncate recvfrom and sendto length to INT_MAX Greg KH
2010-12-08  0:45 ` [120/127] net: Limit socket I/O iovec total " Greg KH
2010-12-08  0:45 ` [121/127] [S390] nmi: fix clock comparator revalidation Greg KH
2010-12-08  8:04   ` Heiko Carstens
2010-12-08 17:13     ` Greg KH
2010-12-09  6:23       ` Heiko Carstens
2010-12-08 23:10     ` Greg KH
2010-12-08  0:45 ` [122/127] act_nat: use stack variable Greg KH
2010-12-08  0:45 ` [123/127] net sched: fix some kernel memory leaks Greg KH
2010-12-08  0:45 ` [124/127] UV - XPC: pass nasid instead of nid to gru_create_message_queue Greg KH
2010-12-08  0:45 ` [125/127] x86: uv: XPC receive message reuse triggers invalid BUG_ON() Greg KH
2010-12-08  0:45 ` [126/127] X86: uv: xpc_make_first_contact hang due to not accepting ACTIVE state Greg KH
2010-12-08  0:45 ` [127/127] x86: uv: xpc NULL deref when mesq becomes empty Greg KH

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=20101208004429.317061630@clark.site \
    --to=gregkh@suse.de \
    --cc=akpm@linux-foundation.org \
    --cc=alan@lxorguk.ukuu.org.uk \
    --cc=clemens@ladisch.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=stable-review@kernel.org \
    --cc=stable@kernel.org \
    --cc=stefanr@s5r6.in-berlin.de \
    --cc=torvalds@linux-foundation.org \
    /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